Skip to content

Commit ad16c09

Browse files
committed
docs for 1.3
1 parent a0d7fd5 commit ad16c09

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

README.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,6 @@ This method attepts to move the agent to the given (x,y) location. If something
233233
> `void teleport(double x, double y, double theta)`<br>
234234
This method instantaneously moves the agent to the given position and orientation.
235235
236-
> `double sensor_value(int index)`<br>
237-
This method returns the value of the specificed index. It is the distance from the location of the sensor to the nearest object in the direction the sensor is pointing. The index refers to the position in the sensor list in the agent's JSON definition.
238-
239-
> `std::vector<double> sensor_values()`<br>
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.
241-
242236
Motion Control For Omni Directional Agents
243237
---
244238
@@ -254,6 +248,21 @@ This method slows the agent down using the linear and angular friction coefficie
254248
> `void omni_move_toward(double x, double y, double v=1)`<br>
255249
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. &#x246A; New in 1.1.
256250
251+
Sensors
252+
---
253+
254+
> `double sensor_value(int index)`<br>
255+
This method returns the value of the specificed index. It is the distance from the location of the sensor to the nearest object in the direction the sensor is pointing. The index refers to the position in the sensor list in the agent's JSON definition.
256+
257+
> `std::vector<double> sensor_values()`<br>
258+
This method returns a list of all the sensor values, in the same order as the sensors appear in the agent's JSON definition.
259+
260+
> `std::string sensor_reflection_type(int index)`<br>
261+
This method returns the name of object type the sensor of the specificed index is seeing. The index refers to the position in the sensor list in the agent's JSON definition. &#x246C; New in 1.3.
262+
263+
> `std::vector<std::string> sensor_values()`<br>
264+
This method returns a list of all the sensor reflection types, in the same order as the sensors appear in the agent's JSON definition. &#x246C; New in 1.3.
265+
257266
Collisions
258267
---
259268
@@ -270,6 +279,7 @@ Collisions
270279
> });
271280
> }
272281
> ```
282+
> The value associated with the event `e` is a json object with a single key, `id`, which is the id of the other agent.
273283
> &#x246B; New in 1.2.
274284
275285
> `void ignore_collisions_with(const std::string agent_type)` <br>
@@ -327,6 +337,27 @@ Styling
327337
> Any valid svg styling will work.
328338
> &#x246B; New in 1.2.
329339
340+
> `void decorate(const std::string svg)`<br>
341+
> Add an aribtrary svg element to the agent's rendering method on the client side.
342+
> The svg element will be transformed and rotated to the agent's coordinate system.
343+
> For example, to place a red dot in the middle of the agent do:
344+
> ```c++
345+
> decorate("<circle x='-5' y='5' r='5' style='fill: red'></circle>");
346+
> ```
347+
> To clear the decoration later, simple call
348+
> ```c++
349+
> decorate("");
350+
> ```
351+
> &#x246C; New in 1.3.
352+
353+
> `void label(const string str, double x, double y )` <br>
354+
> Add a textual label to the agent's icon. The x and y values are relative to the origin of the agent's coordinate system.
355+
> &#x246C; New in 1.3.
356+
357+
> `void clear_label()` <br>
358+
> Clear the label associated with the agent.
359+
> &#x246C; New in 1.3.
360+
330361
Project Configuration
331362
===
332363

examples/avoiders/src/wanderer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ namespace {
2929
public:
3030
void entry(const Event& e) {
3131
rate = rand() % 2 == 0 ? 2 : -2;
32-
char buffer[1000];
33-
sprintf(buffer, "<circle x='-5' y='5' r='5' style='fill: red'>%s</text>");
34-
decorate(buffer);
32+
decorate("<circle x='-5' y='5' r='5' style='fill: red'></circle>");
3533
label(sensor_reflection_type(0), 20, 5);
3634
}
3735
void during() {

0 commit comments

Comments
 (0)