Given that you use Arduino only to drive motors I would recommend using ros2_control instead of micro-ROS. ros2_control provides a hardware_interface
in which you implement write/read methods (send commands/receive encoder readings). You just need to implement a motor control and communication protocol for each joint.
The advantage of the ros2_control is that you bring the control complexity from the Arduino board to the Linux board. Then, you can easily load off-the-shelf controllers or create your own. Furthermore, simulation software such as Webots and Gazebo have ros2_control already implemented so you just need to load controllers (great for controller development and sim2real transfer).
To give you more perspective on off-the-shelf controllers, a typical example of a ros2_control controller would be diff_drive_controller
. An amazing thing about diff_drive_controller
and other ros2_controllers is that they are really well implemented. E.g. diff_drive_controller
creates Twist and Odometry topics, but also publishes TFs, supports velocity, acceleration, and jerk limits, implements velocity command timeout behavior, and much more.
See more about ros2_control:
http://control.ros.org/
Originally posted by lukicdarkoo with karma: 486 on 2022-03-07
This answer was NOT ACCEPTED on the original site
Post score: 1
Original comments
Comment by elnkl on 2022-03-31:
Thank you I'll definitely check it out!
Comment by rosbotcom on 2022-08-13:
@lukicdarkoo does your setup imply that the motor drive is connected directly to the Pi?
Comment by lukicdarkoo on 2022-08-15:
It can work with or without some microcontroller in the middle. If motors are directly connected to Raspberry Pi then it is even easier to write a hardware_interface. Although, in that case, you may have problems with peripherals (like interrupts or PWM) and voltage levels on Raspberry Pi.