This is a part of rosserial repository to communicate with ROS system through a USART for STM32 embedded system.
The original code is focused on STM32F3xx, 4xx, and 7xx series and it uses the STM32CubeIDE or STM32CubeMX HAL.
Although we ran this code on STM32G0xx which leads us to believe, this code will run on any STM device supporting HAL.
If you use the package for other series, please edit the following line on src/ros_lib/STM32Hardware.h with corresponding HAL library.
It may happen code will work even with HAL library for other STM32 processor family.
If you run into troubles, please check src/ros_lib/STM32Hardware.h first
An Attached example consists of a STM32Cube project without generated Ros libraries and STM32CubeIDE generated header and C files.
Project implements simple publishers and subscriber.
Project demonstrates blocking behaviour in case of communication being too slow to flush output buffer fast enough.
Application uses baud rate 480600bps and when one publisher is used, can achieve up to ~2.5kHz
publish rate.
$ cd target_workspace (It should contain Inc and Src directories).
$ rosrun rosserial_stm32 make_libraries.py .
Never forget to change the project type to cpp project in STM32CubeIDE
- Generate headers for STM32 (use rosserial_client or rosserial_arduino)
- Paste all generated header files into
Core/Inc
directory - Copy files
ros.h
andSTM32Hardware.h
toCore/Inc
- In your
.ioc
file underconnectivity
and selectUART2
and set DMA same as in the examplar fileg031_rosserial.ioc
- Make sure your code implements iterrupt function void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) same as in examplar file
main.cpp
- When generating a code useing STM32CubeIDE, make sure you either generate
main.cpp
, ifmain.c
keeps getting generated, you can simply copy changes intomain.cpp
and removemain.c