1
$\begingroup$

Rosanswers logo

Hey guys,

I'm a ROS newbie and I'm trying to build a robot car using an Arduino Uno and a Pi 4B, connected with each other via usb. I have ROS2 foxy running on the pi and connected my motors+encoders on the uno. I want to publish the encoder data from uno to the pi but Im having trouble finding the right packages. micro-ROS doesnt support the uno board and ros2arduino needs the dashing distro to work. I've found a ros1 bridge to ros2 package but can this be used for the arduino? Should it be installed on both sides? (arduino + pi) Any advice on how should I move forward?


Originally posted by elnkl on ROS Answers with karma: 11 on 2022-03-06

Post score: 1

$\endgroup$

2 Answers 2

1
$\begingroup$

Rosanswers logo

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.

$\endgroup$
1
$\begingroup$

Rosanswers logo

Would you consider using a Teensy 4 instead of the Uno? Teensy works with micro-ros, and you’ll likely be able to reuse most of the code you wrote for the Arduino. On the downside, you’ll have a little extra work to learn the Teensy and you might run into a few other issues that will require resolving.


Originally posted by dognaught47 with karma: 91 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 for your response! Unfortunately Im on a strict deadline for this project and learning a new micro controller, although interesting, its not something I can do now

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.