ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Arduino Uno and ROS2 bridge

asked 2022-03-06 16:45:26 -0600

elnkl gravatar image

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?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
1

answered 2022-03-07 16:37:53 -0600

lukicdarkoo gravatar image

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/

edit flag offensive delete link more

Comments

Thank you I'll definitely check it out!

elnkl gravatar image elnkl  ( 2022-03-31 01:21:31 -0600 )edit

@lukicdarkoo does your setup imply that the motor drive is connected directly to the Pi?

rosbotcom gravatar image rosbotcom  ( 2022-08-13 14:47:39 -0600 )edit
1

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.

lukicdarkoo gravatar image lukicdarkoo  ( 2022-08-15 03:11:17 -0600 )edit
1

answered 2022-03-07 22:55:18 -0600

dognaught47 gravatar image

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.

edit flag offensive delete link more

Comments

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

elnkl gravatar image elnkl  ( 2022-03-31 01:23:05 -0600 )edit
0

answered 2022-03-10 07:32:22 -0600

kak13 gravatar image

I used a lot of different stuff on 8bits and 32 bits ardiuno through raspberry pi

32 bits = micro-ros 8 bits = Python Firmata mixed with ros2 (just import FIrmata while using ros2)

FYI, there's a ton of ways to do this but I feel FIrmata is easiest option for you since you just need motors+encoder, right? Firmata is simple like that.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-03-06 16:45:26 -0600

Seen: 2,895 times

Last updated: Mar 10 '22