An open API service indexing awesome lists of open source software.

https://github.com/bringauto/virtual-vehicle

Virtual Vehicle for Fleet Protocol
https://github.com/bringauto/virtual-vehicle

fleet-protocol

Last synced: 4 months ago
JSON representation

Virtual Vehicle for Fleet Protocol

Awesome Lists containing this project

README

          

# Virtual Vehicle

Virtual vehicle simulates a robot movement on a map fulfilling orders from Fleet Management.

It also serves as a backup autonomy. It sends GPS location from a GPS device to Fleet Management.
In this case, it doesn't drive but still can fulfill orders, if it is at the target station.

**Functionality:**
- GPS location reporting
- Non-trivial set of cars. Each of them has its own route
- Each car reacts to orders from Fleet Management

**Use cases:**
- Backup autonomy
- Testing of Fleet Management
- Load testing of Fleet Management
- Presentation purposes

## Prerequisites

* [cxxopts](https://github.com/jarro2783/cxxopts) >= 3.0.0
* [protobuf](https://github.com/protocolbuffers/protobuf/tree/main/src) = 3.17.3
* [balogger](https://github.com/bringauto/ba-logger) >= 1.2.0
* [statesmurf](https://github.com/Melky-Phoe/StateSmurf) >= 2.0.1
* [modbuspp](https://github.com/bringauto/modbuspp) >= 0.3.1

* [libosmium](https://github.com/osmcode/libosmium) >= 2.17.3

``` bash
sudo apt install libosmium2-dev
```

* [cmlib](https://github.com/cmakelib/cmakelib), need to export CMLIB_DIR

## Arguments

* `--config=` path to JSON configuration file
* `--map=` full path to .osm file containing map
* `--default-route=` - name of the route that will be set as default
* `--module-gateway-ip=` IPv4 or hostname of ba daemon
* `--module-gateway-port=` ba daemon port
* `-h | --help` print help
* `--wait-at-stop-s=` how many seconds will the car wait in a stop, default is 10s (simulation)
* `--period-ms=` maximum time period between two status messages sent to Module Gateway
* `--speed-override=` override map speed
* `--fleet-provider-type=` choose fleet provider, `internal-protocol` to use of Internal Fleet Protocol `no-connection`
to use of dummy connection
* `--vehicle-provider-type=` choose vehicle provider, `simulation` for use of OSM map `gps` for use of GPS provider
* `--gps-provider-type=` choose GPS provider, `rutx09` or `ublox`
* `--rutx-ip=` IP address to Modbus server on rutx09
* `--rutx-port=` port of Modbus server on rutx09
* `--rutx-slave-id=` slave id of Modbus server on rutx09
* `--stop-radius-m=` distance from a stop that will be determined as arrival at the stop
* `--in-stop-delay-s=` how many seconds will the car wait in a stop, default is 10s (gps)

## Settings

JSON file is used for setting all parameters of the program. Those settings can be overwritten by command line arguments.
examples in `./config/*.json`

## general settings

* `period` - the time period between two status messages sent to Module Gateway, int

## logging

### console

* `level` - console logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
* `use` - if logs will be printed to console, bool

### file

* `level` - file logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
* `use` - if logs will be printed to files, bool
* `path` - logs will be saved to provided folder, path can be both relative and absolute, string

Note: at least one logging sink needs to be used

## vehicle settings

* `vehicle-provider-type` - vehicle provider, `simulation` for use of OSM map **or** `gps` for use of GPS provider, string
* `provider-simulation-settings` - simulation provider settings object
* `provider-gps-settings` - gps provider settings object

### gps provider settings

* `gps-provider-type` - gps provider, `rutx09`, `ublox`, or `map` (serving for testing purposes), string
* `stop-radius` - distance from a stop that will be determined as arrival to the stop, int
* `rutx09-settings` - rutx09 settings object
* `map-settings` - map settings object

#### rutx09 settings

* `rutx-ip` - IP address to Modbus server on rutx09, string
* `rutx-port` - port of Modbus server on rutx09, int
* `rutx-slave-id` - slave id of Modbus server on rutx09, int

#### map settings
* `map` - full path to .osm file containing map, string
* `default-route` - the name of the route that will be set as default, string

### simulation provider settings

* `speed-override` - override map speed enable, bool
* `map-override-mps` - override map speed, int
* `wait-at-stop` - how many seconds will car wait in stop, int
* `map` - full path to .osm file containing map, string
* `default-route` - the name of the route that will be set as default, string

## Fleet settings

* `fleet-provider-type` - fleet provider, `internal-protocol` for use of internal protocol `no-connection` for use of dummy
connection, string
* `provider-internal-protocol-settings` - internal protocol provider settings object - module 1, device type 1 is hardcoded

### internal protocol provider settings

* `module-gateway-ip` - IPv4 or hostname of module gateway, string
* `module-gateway-port` - ba module gateway port, int
* `device-role` - device role, string - part of device identification
* `device-name` - device name, string - part of device identification
* `device-priority` - device priority, int - part of device identification
* `reconnect-period-s` - period of reconnection to module gateway, int

## Fleet provider type

Virtual vehicle provides the ability to choose a fleet communication provider with `--fleet-provider-type=` argument. The
options are:

* `internal-protocol` - connection to Module Gateway by Internal Client will be established, requires `--ip=`
and `--port=` arguments to specify module gateway connection
* `no-connection` - no connection will be established, statuses will be discarded and the default command will be returned,
for testing purposes

## Vehicle provider type

Virtual vehicle provides the ability to choose different simulation implementation with `--vehicle-provider-type=`
argument. The options are:

* `simulation` - car movement will be simulated and position will be based on the given map file (.osm format). Required
parameters: `--map=`, `--route=`,
optional arguments: `--speed-override=`, `--wait=`
* `gps` - virtual vehicle will report position based on external GPS source, no mission logic is implemented. Required
parameters: `--gps-provider-type=`

## Gps provider

Provider used for GPS-based position reporting. The options are:

* `rutx09` - position is obtained from RUTX09 router from Teltonika. Required
parameters: `--rutx-ip=`, `--rutx-port=`, `rutx-slave-id=`
* `ublox` - position is obtained from ublox device, NOT IMPLEMENTED
* `map` - position is obtained from the map, for testing purposes. It is always driving on the route gained from settings.
Required parameters: `--map=` and `--default-route=`

## Cmake parameters

* `BRINGAUTO_TESTS` - if set to ON, tests will also be compiled, tests can be run with command ctest after successful build
build
* `BRINGAUTO_PACKAGE` - if set to ON creates a package of vvu
* `BRINGAUTO_INSTALL` - if set to ON enables make install command
* `BRINGAUTO_SYSTEM_DEP` - if set to ON cmake will use system dependencies instead of CMlib storage packages
* `BRINGAUTO_SAMPLES` - if set to ON sample app will be compiled
* `STATE_SMURF` - enable state smurf compilation
* `CMLIB_DIR` - specify the path to cmakelib

## Build

``` bash
git clone https://github.com/bringauto/virtual-vehicle.git
git submodule update --init --recursive
mkdir _build && cd _build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j 8
```

## Tests

Documentation for tests is in [test/README.md](test/README.md)

## Smurf integration tests

Smurf integration tests are used to test Virtual vehicle integration with who Fleet Protocol stack using [Etna](https://github.com/bringauto/etna).

Details and usage are described in [StateSmurf](test/smurf/README.md) documentation.

## Map creation

For creating maps we use openstreet map editor. Maps are saved in open street map format (.osm). Each map contains a list
of nodes (points on the route), a list of ways (parts of routes, connecting points), and a list of routes (composed of ways). One
.osm file can contain multiple routes and they have to be named. Routes can share points and ways. A point can represent
a stop and if it is a stop, it has to be named.

## Start a new map

* Install java openstreet map editor ()
* Under Imagery choose map source to visualize map (b&w open street map recommended)
* Under File create a new layer, name it (right side of the app), layer represents .osm file

## Route creation

* Choose the draw nodes tool (left toolbar) and draw way (list of points connected by a line) by adding points, press ESC when
finished, repeat until you have all the ways you need (usually one is enough if you do not want to share ways in multiple
routes)
* With the select/move tool select all ways you want to include in the route and in the relation tab add a relation with the plus button
* in pop-up add required tags - `type=` and `name=`
* in the same pop-up window add ways (selection tab) to route (members tab) and apply role "way"
* repeat if you want multiple routes, routes can share some parts with each other, that is why they consist of ways. If
you do not intend to share parts of routes use one way per route

![pop up image](documentation/josm_selection.png)

## Stop addition

* select the point you want to make into stop (yellow dot and stop can be defined only on nodes, not on the line between them)
* in tags/membership tab click the plus button with the selected point and add tag `stop=true` and `name=` (name has to
be unique)
* you can also add `speed=` as a tag to ANY point, it will set the MAXIMUM speed on that point

## Export map

* Under file save map as `.osm` file
* .osm map example:

``` xml




































































```

## Build and run docker image

Build docker image using

``` bash
git clone https://github.com/bringauto/virtual-vehicle.git
git submodule update --init --recursive
docker build --tag virtual-vehicle-utility .
```

Run docker with parameters

``` bash
docker run -ti --rm virtual-vehicle-utility --config= --map= --route= --module-gateway-ip= --module-gateway-port= --wait-at-stop-s=

Examples:

``` bash
docker run -ti --rm virtual-vehicle-utility --config=/virtual-vehicle-utility/config/example.json
```

``` bash
docker run -ti --rm virtual-vehicle-utility --config=/virtual-vehicle-utility/config/example.json --map=/virtual-vehicle-utility/tests/maps/BorsodChem.osm --route=borsodchem --module-gateway-ip=127.0.0.1 --module-gateway-port=1536 --wait-at-stop-s=10
```

## Troubleshooting

#### RUTX09 GPS provider sending invalid data

Make sure that the RUTX09 firmware version is >= RUTX_R_00.07.08.3