Skip to content
README.md 4.25 KiB
Newer Older
Ambroise Vincent's avatar
Ambroise Vincent committed
# Autoware Safety Island Demo

A repository providing the elements to build the different components of the Autoware on Safety Island demo.

## Dependencies

Use `git submodule init` and `git submodule update` to check out the external git subdirectories.

A suitable environment is needed to build the Autoware packages, for example: https://autowarefoundation.gitlab.io/autoware.auto/AutowareAuto/installation-ade.html#installation-and-development-install-ade.
Ambroise Vincent's avatar
Ambroise Vincent committed
`.aderc-amd64` and `.aderc-arm64` are provided for convenience when using ade, with the Autoware docker image set to the same commit as the submodule.

Install Zephyr's dependencies:
```bash
wget https://apt.kitware.com/kitware-archive.sh
sudo bash kitware-archive.sh
sudo apt install --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc libsdl2-dev
pip3 install --user -U west
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc
west init .
west update
west zephyr-export
pip3 install --user -r zephyr/scripts/requirements.txt
```
(from https://docs.zephyrproject.org/latest/getting_started/index.html#install-dependencies)

Ambroise Vincent's avatar
Ambroise Vincent committed
The Zephyr SDK is required to build the Zephyr app: https://docs.zephyrproject.org/latest/getting_started/index.html#install-a-toolchain (tested with 0.13.1).

## Building

Use `build.sh` to build all components.
Ambroise Vincent's avatar
Ambroise Vincent committed
### Network

A network interface will need to be setup to get a network communication between the host and the Zephyr app.

Once Zephyr has been configured, it will provide a script to create such an interface: `tools/net-tools/net-setup.sh` (to be run as root).

A configuration file is provided for CycloneDDS to use that same interface (`cyclonedds.xml`), with `zeth` as the interface name.
CycloneDDS will use this file with:
```bash
export CYCLONEDDS_URI=`pwd`/cyclonedds.xml
```

Ambroise Vincent's avatar
Ambroise Vincent committed
### Simulator (optional, for visualization)

Follow the instructions at https://autowarefoundation.gitlab.io/autoware.auto/AutowareAuto/lgsvl.html to launch and use the simulator.

Ambroise Vincent's avatar
Ambroise Vincent committed
### Zephyr app

Run `west build -d build/zephyr_app -t run` to start the Zephyr app.

### Actuation demo

Ambroise Vincent's avatar
Ambroise Vincent committed
The execution environment of the following `ros2` commands must be setup with `source install/setup.bash` and by setting `CYCLONEDDS_URI` as described above.

Run `ros2 launch actuation_demos recordreplay_planner_demo.launch.py` to launch the Autoware pipeline of the actuation demo.

In a separate terminal, run `ros2 action send_goal /planning/replaytrajectory autoware_auto_planning_msgs/action/ReplayTrajectory "{replay_path: "waypoints.csv"}"` to start playing the recorded waypoints.
Ambroise Vincent's avatar
Ambroise Vincent committed

## Testing

The test design can be found [here](TESTING.md).

The testing requires the CycloneDDS host tools as well as the `actuation_message_converter` package to have been built first.

Run `testing.sh` to start the tests.

Ambroise Vincent's avatar
Ambroise Vincent committed
## Development notes

The CycloneDDS code uses posix functions to manipulate threads.
Zephyr provides 2 ways to initialize and create threads: one through its `z_` or `k_` functions and the other using the posix API.
The result of the two initializations is not the same: either the internal data structures are not the same or they are not initialized in the same way.
The result is that some posix thread functions will fail when using the non-posix initialization (seems related to some internal slist state).
Conclusion: threads that handle CycloneDDS code need to be created with the posix API.

The floating point operations in Zephyr are inconsistent: at the start of the subscriber thread it works fine, but inside of the while loop handling the incoming messages it doesn't work, return + or - 0 (but the sign of the operation is correct).
Workaround: do the floating point operation (conversion from rad to deg) on the Compute Island.

Using the default multicasting configuration for CycloneDDS has it be used for discovery + communication.
But doing so spams the network device/driver with messages exchanged within Autoware during the demo that are not intended for the SI, making Zephyr complains about buffer size and preventing correct communication with the host.
Workaround: use multicast for discovery only ("spdp" mode). The `cyclonedds.xml` file can be used to that end.