SoDeV Demo manual with the STM32 board and CARLA
1. CARLA setup
Overview
This manual describes the procedures for setup CARLA of the AGL SoDeV demo environment.
Official quick start guide
OS(Ubuntu22.04)
Procedure
Download CARLA
Download CARLA_0.9.16.tar.gz from hereMake work directory
$ mkdir ~/CARLA_0.9.16
$ tar zxf CARLA_0.9.16.tar.gz -C ~/CARLA_0.9.16Set python env
$ python3 -m venv .venv
$ source .venv/bin/activate
$ python3 -m pip install --upgrade pip
$ python3 -m pip install carla==0.9.16
$ cd ~/CARLA_0.9.16/PythonAPI/carla/dist
$ python3 -m pip install carla-0.9.16-cp310-cp310-manylinux_2_31_x86_64.whl
->If you encounter the error:
ERROR: carla-0.9.16-cp310-cp310-manylinux_2_31_x86_64.whl is not a supported wheel on this platform.
your host PC may not be running Ubuntu 22.04.
Please verify this.Install Client example script
$ cd ~/CARLA_0.9.16/PythonAPI/examples
$ python3 -m pip install -r requirements.txtstart CARLA
$ cd ~/CARLA_0.9.16
$ ./CarlaUE4.sh -RenderOffScreen &
Launch a new console
$ cd ~/CARLA_0.9.16/PythonAPI
$ source ~/.venv/bin/activate
(.venv) $ cd ./examples
(.venv) $ python3 ./manual_control.py -a --sync
Launch a new console
$ cd ~/CARLA_0.9.16/PythonAPI
$ source ~/.venv/bin/activate
(.venv) $ cd ./examples
(.venv) $ python3 ./generate_traffic.py -n X --safe
->This will run X vehicles. Adjust the value of X according to the GPU capability of the host PC.clone agl-demo-control-panel
$ cd $HOME
$ git clone https://gerrit.automotivelinux.org/gerrit/src/agl-demo-control-panelsetup can0 for STM32
$ sudo slcand -o -c -s4 -t hw -S 3000000 /dev/ttyXXX can0
→Edit /dev/ttyXXX to match the device file of the target CAN device.
$ sudo ip link set can0 txqueuelen 1000
$ sudo ip link set can0 type can bitrate 125000
$ sudo ip link set can0 up
$ ip link show can0send can data to STM32
$ cd ~/agl-demo-control-panel/Scripts
$ python3 -u carla_to_CAN.py --interface can0
2. STM32 setup
Overview
This manual describes the procedures for setup STM32 of the AGL SoDeV demo environment.
How to convert vehicle-speed CAN data from CARLA in a Zephyr program on an STM32 and output it to the target GPIO.
Equipment
nucleo-h753zi
CAN Converter
CAN Bus Tranciever
Patch file
Preparation
To prepare for West Flash, install the Linux version of CubeProgrammer by referring to the following page: https://www.st.com/en/development-tools/stm32cubeprog.html .
After installation, add it to your PATH.
Procedure
Setup Zephyr build environment
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget python3-dev python3-venv python3-tk \
xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
// setup python virtualenv and activate
$ python3 -m venv ~/zephyrproject/.venv
$ source ~/zephyrproject/.venv/bin/activate
// setup zephyr
$ pip install west
$ west init -m https://github.com/zephyrproject-rtos/zephyr --mr v4.3.0 ~/zephyrproject
$ cd ~/zephyrproject
$ west update
$ west zephyr-export
$ west packages pip --install
# install the Zephyr SDK
$ cd ~/zephyrproject/zephyr
$ west sdk installApply PATCH-can_pwm_vehicle_speed.patch to ~/zephyrproject/zephyr
$ cd zephyrproject/zephyr
$ mv <path>/PATCH-can_pwm_vehicle_speed.patch .
$ patch -p1 < PATCH-can_pwm_vehicle_speed.patchBuild zephyr with "can_pwm_vehicle_speed" application
$ cd zephyrproject/zephyr
$ west build -b nucleo_h753zi samples/net/can_pwm_vehicle_speed -pConnect nucleo-h753zi to PC by USB cable
Flash image
$ west flash*If you encounter an error such as:
libusb: error [get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/003/011, errno=13when running west flash, you need to create a udev rule.
Connect the board to your PC and run:
$ lsusb | grep -i stExample output:
Bus 003 Device 011: ID 0483:374e STMicroelectronics STLINK-V3Based on this output, create the file:
/etc/udev/rules.d/49-stlink.rulesThe contents should match the IDs detected by lsusb. For example:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", MODE:="0666", TAG+="uaccess", SYMLINK+="stlinkv3_%n"Then reload udev rules and trigger them:
$ sudo udevadm control --reload-rules
$ sudo udevadm triggerUnplug and reconnect the USB cable of the board.
After that, run west flash again.
3. How to connect CARLA and STM32 and V4H sparrow hawk
How to connect CARLA and STM32
connect nucleo-h753zi to PC
how to connect can converter and can tranciever and STM board
Pinout for the CAN connection
How to connect STM32 and V4H sparrow hawk
Pinout for the GPIO connection
V4H sparrow hawk
Build the Zephyr Guest VM as DomZ using the Xen BSP.
The detailed build procedure is omitted.
Demo Execution
After the system boots, enter the following commands in the console to connect to the UART of DomZ.
After connecting, the vehicle speed information will be output on the UART.
generic-armv8-xt-dom0 login: root
...
root@generic-armv8-xt-dom0:~# xl console DomZ
Vehicle speed: 20.7 km/h
Vehicle speed: 18.0 km/h
Vehicle speed: 18.9 km/h
Vehicle speed: 18.0 km/h
...