You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+97-18Lines changed: 97 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ src/
60
60
my_robot.cc // Contains the implementation of the classes in my_robot.h
61
61
```
62
62
63
-
Note that `esm generate` only makes directional robots. For an omni-directional robot, you need to subsequently edit the `defs/my_robot.json` file and change "shape" to "omni" and add a "radius" field (see below). 🔷 New in 1.1.
63
+
Note that `esm generate` only makes directional robots. For an omni-directional robot, you need to subsequently edit the `defs/my_robot.json` file and change "shape" to "omni" and add a "radius" field (see below). ⑪ New in 1.1.
64
64
65
65
To compile the robot code, do
66
66
```
@@ -126,10 +126,10 @@ A string describing the agent.
126
126
127
127
> `shape`<br>
128
128
> ***polygon shaped:*** A list of pairs of the form `{ "x": 10, "y": 12 }` defining the vertices of a polygon. The physics engine will use this to determine the moment of initial and collision shape of the robot, and the user interface will use it to render the agent. All points are relative to the robot's center.<br>
129
-
> ***circular:*** The string "omni", which makes a circular omni-directional agent. If you choose this option, you also need to specify a "radius". 🔷 New in 1.1.
129
+
> ***circular:*** The string "omni", which makes a circular omni-directional agent. If you choose this option, you also need to specify a "radius". ⑪ New in 1.1.
130
130
131
131
> `radius`<br>
132
-
The radius of a circular, omnidirectional robot. Only used when the `shape` field is "omni". 🔷 New in 1.1.
132
+
The radius of a circular, omnidirectional robot. Only used when the `shape` field is "omni". ⑪ New in 1.1.
133
133
134
134
> `friction`<br>
135
135
An object with three numerical fields, `collision`, `linear`, and `rotational` defining the fricition coefficients of the robot with other robots and with the environment. Note that the latter two coefficients are only used if you apply a control in your `update()` methods such as `damp_movement()` or `track_velocity()`.
@@ -194,14 +194,17 @@ Processes and state machines that are added to agents are both elma processes an
194
194
195
195
The agent interface class methods are described below. They are available in the `init()`, `start()`, `update()`, and `stop()` methods of your process, as well as the `entry()`, `during()` and `exit()` methods of any states in your state machines.
196
196
197
+
Agent State
198
+
---
199
+
197
200
> `cpVect position()` <br>
198
201
This method returns the position of the agent. The `cpVect` structure has fields `x` and `y` that can be treated as `doubles`.
199
202
200
203
> `cpVect velocity()`<br>
201
204
This method returns the velocity of the agent. The `cpVect` structure has fields `x` and `y` that can be treated as `doubles`.
202
205
203
206
> `x()`, `y()`, `vx()`, `vy()`<br>
204
-
The horizontal and verical positions, and the horizonal and vertical velocities -- separated out so you do not need to about the structure. 🔷 New in 1.1.
207
+
The horizontal and verical positions, and the horizonal and vertical velocities -- separated out so you do not need to about the structure. ⑪ New in 1.1.
205
208
206
209
> `double angle()`<br>
207
210
This method returns the angle of the agent in radians and can be treated as a `double`.
@@ -212,6 +215,9 @@ This method returns the angular velocity of the agent in radians per second and
This methied applies a force specified by the `thrust` argument in the direction the agent is currently facing, and applies a torque specified by the `torque` argument around the center of the agent. The agent's mass comes in to play here using Newton's laws of motion.
217
223
@@ -233,20 +239,93 @@ This method returns the value of the specificed index. It is the distance from t
233
239
> `std::vector<double> sensor_values()`<br>
234
240
This method returns a list of all the sensor values, in the same order as the sensors appear in the agent's JSON definition.
This method makes the agent attempty to track the given translational velocity. If other elements are in the way, or if it is experience collisions, it may not be able to exactly track these values. The optional argument is the proportional gain on the feedback controller that implements the tracking controller. 🔷 New in 1.1.
249
+
This method makes the agent attempty to track the given translational velocity. If other elements are in the way, or if it is experience collisions, it may not be able to exactly track these values. The optional argument is the proportional gain on the feedback controller that implements the tracking controller. ⑪ New in 1.1.
244
250
245
251
> `void omni_damp_movement()`<br>
246
-
This method slows the agent down using the linear and angular friction coefficients defined in the agent's JSON definition file. 🔷 New in 1.1.
252
+
This method slows the agent down using the linear and angular friction coefficients defined in the agent's JSON definition file. ⑪ New in 1.1.
247
253
248
254
> `void omni_move_toward(double x, double y, double v=1)`<br>
249
-
This method attepts to move the agent to the given (x,y) location. If something in the way, the agent will not get there. The robot simultaneously attempts to rotate so that it is pointing toward the target and also moves forward, going faster as its angular error is reduced. The optional argument is the desired velocity of rotation and forward motion. 🔷 New in 1.1.
255
+
This method attepts to move the agent to the given (x,y) location. If something in the way, the agent will not get there. The robot simultaneously attempts to rotate so that it is pointing toward the target and also moves forward, going faster as its angular error is reduced. The optional argument is the desired velocity of rotation and forward motion. ⑪ New in 1.1.
> Change the agent's style, just as in the configuration file.
327
+
> Any valid svg styling will work.
328
+
> ⑫ New in 1.2.
250
329
251
330
Project Configuration
252
331
===
@@ -273,7 +352,7 @@ The port for the server. Use `8765` for now.
273
352
> ```
274
353
> The name field is used to catch button click events (see below). The label field defines the string displayed on the button.
275
354
> The style field is an `css` code you want to add to the stying of the button.
276
-
> 🔶 New in 1.0.
355
+
> ⑩ New in 1.0.
277
356
278
357
> `agents`<br>
279
358
> A list of agents to put in the simulation. For example,
@@ -310,29 +389,29 @@ Responding to Front End Events
310
389
311
390
The brower client relays mouse click, button press, and keyboard events to the enviro server, which your process can watch for. The event types and associated information are:
312
391
313
-
> Name: `screen_click`
392
+
> Name: `screen_click`<br>
314
393
> Value: An object with `x` and `y` fields holding the location of the click in world coordinates.
315
394
316
-
> Name: `agent_click`
395
+
> Name: `agent_click`<br>
317
396
> Value: An object with `id`, `x` and `y` fields holding the agent's id and the location of the click in **agent** coordinates.
318
397
319
-
> Name: `button_click`
398
+
> Name: `button_click`<br>
320
399
> Value: An object with the a `name` field that matches the name field used in `config.json`.
321
-
> 🔶 New in 1.0.
400
+
> ⑩ New in 1.0.
322
401
323
-
> Name: `keydown`
402
+
> Name: `keydown`<br>
324
403
> Value: An object with a `key` field, which is the character pressed, as well as the following boolean fields
325
404
> ```
326
405
> ctrlKey
327
406
> shiftKey
328
407
> altKey
329
408
> metaKey
330
409
> ```
331
-
> 🔶 New in 1.0.
410
+
> ⑩ New in 1.0.
332
411
333
-
> Name: `keyup`
412
+
> Name: `keyup`<br>
334
413
> Value: Same as for `keydown`.
335
-
> 🔶 New in 1.0.
414
+
> ⑩ New in 1.0.
336
415
337
416
To respond to events in your code, you should put elma watchers into the `init()` method of some process. For example, to respond to an agent click, you might do
0 commit comments