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

Revision history [back]

click to hide/show revision 1
initial version

Yes, you'd need to connect the motors to an Arduino. The motors don't publish anything. You'd need encoders (and read them). That can be used to calculate the speed of the wheels.

then do i need to have micro Ros installed on the Arduino ? Or can the pi control the motors using i2c / SPI ?

Simple answer, you could do either. Note that micro-ros requires a 32bit controller. Your default Arduino uno/mega are 8bit, so you'd need to go the i2c/spi way.

are the motors no longer part of the Ros graph?

If I understand your question correctly, motors are never part of the ROS graph. Motor controllers on the other hand, they can be, but aren't required.

Simple example:

I've got an Arduino connected to my raspberry using I2C. I'm using ros2_control to control my robot. In my hardware_interface I've written the part to send the desired speeds over I2C to the Arduino and receive the actual speed (from the encoders). My hardware_interface is part of the ROS graph. My Arduino (the motor controller) isn't.

If I were to use micro-ros, I could publish the desired speed on a topic and have the Arduino subscribe to it and control the motors that way. In that case the Arduino (motor controller) is visible in the ROS graph. The motors are never part of the graph though (in the same way that your lidar technically isn't part of the ROS graph. Your lidar driver, on the other hand, is.

I do not fully understand, however, why that matters. Maybe I'm missing something you want to do.

Yes, you'd need to connect the motors to an Arduino. The motors don't publish anything. You'd need encoders (and read them). That can be used to calculate the speed of the wheels.

then do i need to have micro Ros installed on the Arduino ? Or can the pi control the motors using i2c / SPI ?

Simple answer, you could do either. Note that micro-ros requires a 32bit controller. Your default Arduino uno/mega are 8bit, so you'd need to go the i2c/spi way.

are the motors no longer part of the Ros graph?

If I understand your question correctly, motors are never part of the ROS graph. Motor controllers on the other hand, they can be, but aren't required.

Simple example:

I've got an Arduino connected to my raspberry using I2C. I'm using ros2_control to control my robot. In my hardware_interface I've written the part to send the desired speeds over I2C to the Arduino and receive the actual speed (from the encoders). My hardware_interface is part of the ROS graph. My Arduino (the motor controller) isn't.

If I were to use micro-ros, I could publish the desired speed on a topic and have the Arduino subscribe to it and control the motors that way. In that case the Arduino (motor controller) is visible in the ROS graph. The motors are never part of the graph though (in the same way that your lidar technically isn't part of the ROS graph. Your lidar driver, on the other hand, is.

I do not fully understand, however, why that matters. Maybe I'm missing something you want to do.

ETA:

No, the hardware interface is a plugin. Basically, ros2_control doesn't know how to access your motors.

I've had a project where we had the motors hooked up to a PLC and we send the motor commands to the PLC over an ethernet cable. I've also had a project where we used a good old fashioned CAN bus. It would literally be impossible for ros2_control to write code that could interface with every type of hardware (see where the name comes from?). They solved this by creating the hardware_interface plugin.

ros2_control assumes that the plugin has some functions (read() and write() are 2 of them). It then simply calls those functions. You need to write the hardware_interface yourself, and make sure those functions do what you want them to do (communicate with your motors). You could compare it to a subscriber. You create the subscriber and say what the callback function is. ROS will then call that function for you every time there's a message. You need to be the one to actually program that the function does what you want it to do.

BTW, the documentation for ros2_control