"Update: add example subscribe and publish to main.cpp"
During wait for answer I've search and try some. I think I got it working now. Maybe not perfect since I'm still learning C++
Here is my file:
https://github.com/nquantum/stm32_ros...
from install for arduino:
http://wiki.ros.org/rosserial_arduino...
I install rosserial libraries on PC-Linux
sudo apt-get install ros-kinetic-rosserial
sudo apt-get install ros-rosserial-arduino
building Arduino library >> after this we get ros_lib for our microcontroller , can copy to linux or windows
cd <some_empty_directory>
rosrun rosserial_arduino make_libraries.py .
get ros_lib ready to import to Arduino or other micro
- get working project & set preprocessor c , c++ > I use from cubeF4 example project uart_polling to make sure usart work
- copy ros_lib into project
- exclude from build , right click folder then untick exclude so it will compile this source in this folder
- include ros_lib in project property for c, c++
- rename main.c to main.cpp
- in main try #include <ros.h> compile error because it for arduino ros.h,ArduinoHardware.h, ArduinoTcpHardware.h
- replace ros.h and copy STM32Hardware.h
- adjust usart parameter in main.h to usartx, x = your number , I should move these parameter to STM32Hardware.h or from STM32Hardware.h to main.h to make it centralize. Maybe later...
test
1st terminal
1. roscore
2nd terminal
1. rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=57600
3rd terminal
1. rostopic list
2. rostopic echo /chatter
Now you can see from those topic. Which I adjust from Hello World (example publisher) - Arduino :
http://wiki.ros.org/rosserial_arduino...
Also reference from AVR and Adding Support for New Hardware
http://wiki.ros.org/rosserial_client/... http://wiki.ros.org/rosserial_client/...
Another example:
https://github.com/bosch-ros-pkg/stm32 https://github.com/spiralray/stm32f1_...
These two also interface stm32 to rosserial but they use library C++ of HAL. I see it not convenience for me , new in C++ and I like to use ST HAL which can easy import to Eclipse and generate from CubeMX.
Let me know if it work or recommendation. Since I now learn to make it work with FreeRTOS. I'm also new in ROS so still learn from tutorial.
Now is more happy coz since Arduino Uno have SRAM 2048 or 2K, simple Hello World already take 1358 or 66%. If I try more code it take 70% above then it unable to communicate with rosserial already.
But now I use STM32F469 Discovery Board have SRAM 320K with Hello World take for 1.3K-1.5K I've plenty of room to play with plus power of 32bit and HAL library.
I use HAL_UART function in polling mode in client-side rosserial implementation. Maybe interupt mode should be better. I don't know if/how I can use interupt mode for the rosserial coz it seem like function read() and void write(uint8_t* data, int length) get call periodically. Shold I interupt read then place in buffer and read from those buffer? Anyway so far it work in polling..
FYI ... (more)