This short "how to" will show how to parse a gpx-file with xmlstarlet and send the positions timed with oscsim.
- You need a gpx-file with a route.
- xmlstarlet need to be installed.
Find out, how to install xmlstarlet here.
If you want to dive into this great tool, please refer to its documentation.
There are lots of Tools out there letting you define a route and export it in gpx format.
As an example, I will show how to achieve this with GPX Generator.
- Open the website.
- Start creating the route by clicking waypoints.
Note: The timespan between two waypoints is calculated by the distance and the chosen speed. You can even simulate velocity by increasing the speed from point to point. - When ready, export the route in gpx-format into a file (e.g.
sample.gpx).
The exported file will look like:
<?xml version="1.0"?>
<gpx version="1.1" creator="gpxgenerator.com">
<wpt lat="51.726578514305174" lon="8.759472002022175">
<ele>112.62</ele>
<time>2021-03-30T09:53:58Z</time>
</wpt>
<wpt lat="51.72652534946479" lon="8.759300340645222">
<ele>112.75</ele>
<time>2021-03-30T09:53:59Z</time>
</wpt>
<wpt
...
</wpt>
</gpx>Find a short gpx-file (sample.gpx) in the files-folder for a first try.
Take the script from the files-folder and change
- the filename of the gpx-file to your needs (line #4)
- the call to oscsim to your needs (line #60)
Let the script run and voilá - we are simulating a bus driving through your city continuously sending its location!