Robotics StackExchange | Archived questions

ROS2 Control and Arduino Uno

Hello!

I am very much a newbie in both ROS and I was trying to make a fun project to get a bit more familiar. In my project I want to have communication between Raspberry PI and Arduino Uno.

I wanted to use ROS2 for the serial communication, but I realize that some of the popular ways to do it roserial, MicroRos ros2Arduino either do not have support for ROS2 or for Arduino UNO.

Then I fell upon ROS2 Control and got a bit fascinated. However reading the documentation I have a bit of a hard time to understand how to get things started. I think things will become clear automagically at some point, but in the meantime, do you think my project is possible at all using the ROS2 Control Framework?

Asked by KiD on 2022-06-01 12:00:34 UTC

Comments

Is it possible? Yes. However, you won't be able to directly use ROS2 to communicate with your Arduino, but you'll need to google for solutions to transfer data from the Arduino UNO to a Raspberry Pi

Asked by Joe28965 on 2022-06-02 03:33:51 UTC

Thanks @Joe28965! I see, I think my understanding of ROS2 Control might have been wrong.

The way I thought it works is like this:

Imagine (for simplicity) that we have an arduino led that we want to turn on and off from Raspberry Pi using ROS2. We have a topic named "led" that takes values 1 and 0 ("on" and "off"). We have a hardware interface (in ROS2 Control) that knows how to deal with the serial communication for writing to an arduino. We also have a ROS2 publisher running in ROS2.

I thought our publisher would publish to the topic and ROS2 Control would handle the "translation" to the hardware communication. So every time we publish to a topic we would write to the Arduino serial port "automagically".

Is my understanding way off?

Asked by KiD on 2022-06-02 11:12:07 UTC

So to use the actual example of a diff drive, because it's a bit easier IMO.

ros2_control has a controller manager, a plugin and a hardware_interface. The controller manager simply only manages the other two. The plugin (in this case the diff drive controller) gets the values from cmd_vel and calculates the speed that each wheel should have.

You need to write the hardware interface, in there you need to add a vector and tell the diff drive controller to write the speeds for each wheel to that vector. You also add a vector and tell the diff drive controller that you will write the actual speeds to that vector (so it can calculate the odom for you).

The actual "knows how to deal with the serial communication" you need to add to the hardware interface yourself. ROS2 doesn't have a standard solution for it like ROS1 had (In ROS1 easy solution: ros_serial, have your Arduino subscribe to motor_speeds and publish to encoder_speeds have your hardware interface connect with..

Asked by Joe28965 on 2022-06-02 11:20:38 UTC

that (ran out of characters on my comment).

In ROS2, you will need to write the serial communication yourself. You can use ros2_control to do the conversion from cmd_vel to motor speeds and from encoder ticks to odom, but how you get that communication between the raspberry and arduino is something you need to do yourself.

Asked by Joe28965 on 2022-06-02 11:22:11 UTC

@Joe28965 thanks for a great comment, I was not aware of that difference between ROS1 and ROS2. So by using ros2_control, the Arduino would need only to send raw encoder ticks, and receive motor speed commands?

Asked by rosbotcom on 2022-08-14 02:59:34 UTC

Answers