• 2018
• 2017
• 2016

Blog from May, 2018

`control-speed` utility sets the speed of each waypoint in the path based on its position in a curve.

`turn` operation calculates the angle at each waypoint with respect to its adjacent waypoints and assigns the speed according to given maximum lateral acceleration. By passing `--stop-on-sharp-turn` or `--pivot`, `control-speed` can implement spot turn by outputting an extra waypoint with relative heading and no speed, for each sharp turn in the trajectory.

```\$ ( echo '0.0,0.0'; echo '0.3,0.3'; echo '0.6,0.6'; echo '0.6,0.9'; echo '0.6,1.2'; echo '0.9,1.2'; echo '1.2,1.2'; echo '1.5,0.9'; echo '1.8,0.6' ) > trajectory.csv

# moderate speed
\$ control-speed turn --max-acceleration=0.5 --approach-speed=0.2 --fields=x,y --speed=1 < trajectory.csv > speed-turn.csv

# stop on sharp turns
control-speed turn --max-acceleration=0.5 --approach-speed=0.2 --fields=x,y --speed=1 --pivot < trajectory.csv > speed-pivot.csv

# visualise with trajectory as blue and speed as z axis in yellow
\$ view-points "trajectory.csv;fields=x,y;shape=lines;title=trajectory" <( echo 0,0,begin )";fields=x,y,label;weight=8;color=red;title=origin" "speed-pivot.csv;fields=x,y,z;shape=lines;color=yellow;title=turn"```

`control-speed decelerate` operation moderates the sudden decrease in speed in the trajectory by a given deceleration.

```\$ control-speed decelerate --fields=x,y,speed --deceleration=0.5 < speed-pivot.csv > speed-decelerate.csv

# visualise with speed as z-axis and orange color as the decelerated speed
\$ view-points "trajectory.csv;fields=x,y;shape=lines;title=trajectory" <( echo 0,0,begin )";fields=x,y,label;weight=8;color=red;title=origin" \
"speed-pivot.csv;fields=x,y,z;shape=lines;color=yellow;title=turn" "speed-decelerate.csv;fields=x,y,z;shape=lines;color=orange;title=decelerate"```

If you need to quickly deploy a bunch services for line-based or fixed-width data over TCP, local sockets, ZeroMQ, etc, now you can use io-topics, a utility in comma. You can deploy services that run continuously or start only in case if there is at least one client (e.g. if they are too resource greedy).

Perhaps, it is not a replacement for a more proper middleware like ROS or simply systemd, but the advantages of io-publish-topics are its light weight, ad-hoc nature, ability to run a mix of transport protocols.

Try the following toy example of io-topics publish:

```> # run publisher with topics a and b, with b on demand
> io-topics publish --config <( echo "a/command=csv-paste line-number"; echo "a/port=8888"; echo "b/command=csv-paste line-number"; echo "b/port=9999"; echo "b/on_demand=1" )
io-topics: publish: will run 'comma_execute_and_wait --group' with commands:
io-topics: publish:    io-publish tcp:8888   -- csv-paste line-number
io-topics: publish:    io-publish tcp:9999  --on-demand -- csv-paste line-number

> # in a different shell, observe that topic a keeps running even if no-one is listening,
> # whereas topic b runs only if at least one client is connected:
> socat tcp:localhost:8888 | head -n5 # will output something like, since the service keeps running even if there are no clients connected:
16648534
16648535
16648536
16648537
16648538

> socat tcp:localhost:9999 - | head -n5 # whenever the first client connects, will start from 0, since it runs only if at least one client is connected
0
1
2
3
4```

You also can create - on the fly, if you want - a light-weight subscriber, as in example below. Run publishing as in the example above and then run io-topics cat:

```> io-topics cat --config <( echo "a/command=head -n5 > a.csv"; echo "a/address=tcp:localhost:8888"; echo "b/command=head -n5 > b.csv"; echo "b/address=tcp:localhost:9999" )
io-topics: cat: will run 'comma_execute_and_wait --group' with commands:
io-topics: cat:     bash -c io-cat tcp:localhost:8888   | head -n5 > a.csv
io-topics: cat:     bash -c io-cat tcp:localhost:9999   | head -n5 > b.csv
> # check output
> cat a.csv
203740462
203740463
203740464
203740465
203740466
> cat b.csv
0
1
2
3
4```

If you would like to suspend your log playback (e.g. for demo purposes, when, e.g. visualising point cloud stream - or any kind of CSV data - or while browsing your data), now you could use csv-play --interactive or csv-play -i, pressing <whitespace> to pause and resume. Try to run the example below:

```> echo 0 | csv-repeat --period 0.1 --yes | csv-time-stamp | csv-play --interactive
csv-play: running in interactive mode; press <whitespace> to pause or resume
20180503T032156.234658,0
20180503T032156.334336,0
20180503T032156.434497,0
20180503T032156.534721,0
20180503T032156.635077,0
20180503T032156.735428,0
20180503T032156.835511,0
20180503T032156.935653,0
20180503T032157.035926,0
csv-play: paused
csv-play: resumed
20180503T032157.136239,0
20180503T032157.236530,0```

Press left or down arrow keys to output one record at a time. (Keys for outputting one block at a time: todo.)