Rosanswers logo

These are basic questions. I've been wondering how does ROS work with real robot, in GENERAL. Please help me to clarify these things

  1. When we install ROS packages, we install it in our PC, and not in the actual robot. So the ROS library, driver,etc isonly in our PC, and not in the microprocessor of the robot. Is that right?
  2. Which means that only our PC knows/recogizes ROS message types (e.g. cmd_vel) ,but the actual robot does not recognize the ROS message types. The actual robot only recognizes primitive data types (e.g. int) or whatever data types are present in its microcontroller.
  3. So when we publish message to a topic e.g. cmd_vel to velocity topic. This topic is only known in our PC, and not in the robot's computer?
  4. For a ROS package (e.g. navigation) working , the ROS package actually do all the works in our PC and just send result or information to the actual robot right.
  5. So when we use/code all these ROS packages, we actually code just on our PC, meaning that we do not change anything on the robot's microcontroller itself. The robot has its own microcontroller and program, and what we do is just sending info to the microcontroller from our PC. Is that correct?
  6. For a specific robot, Where/how to find out what data(message, command) an actual robot expects to receive?

Please elaborate on those things. If possible, please give step by step example on those things e.g. when sending velocity command to an actual robot, how's the process? The data that we send from our PC is of cmd_vel type. does the robot knows this type, or it is being converted first in our PC before sending? and after the data is received on the robot, does the robot has its own program to react on that data?

PS: I've worked with a drone with ROS before. And I got the impression that we only send info to the drone.. cause I didn't install ROS to the drone, I just install it to my PC. I'm so confused how do we send the info to the drone?

Originally posted by alienmon on ROS Answers with karma: 582 on 2016-10-13

Post score: 3


2 Answers 2


Rosanswers logo

  1. Yes, but not every robot has a microprocessor. Bigger/more complex robots typically only have a PC communicating directly with the motor drivers, sensors, ...
  2. Yes, ROS messages are for ROS, you need to translate this to whatever your actuators/sensors understand. For cmd_vel you typically have a base driver which translates the velocity of the robot base link to motor commands and sends those to the motor drives. This could be a message to a microprocessor which then sets the motor velocities or a CAN message going to a motor drive over CAN bus.
  3. Well, yes
  4. yes. but it needs information from the robot (sensor data, odometry, ...)
  5. Not necessarily. You have to interface the PC with the microcontroller. If the microcontroller has a defined interface, you could do anything on the PC, but probably you have to write the microcontroller interface to the PC as well.
  6. This is up to your hardware. Check how the microcontroller commands the robot, this is what you need to do in the end. How you send the data from ROS to your system is up to you.

There cannot be a step for step explanation for how to do this, because this depends on the HW. If you can control the robot to your liking from a self-written program on the microcontroller, you can write the rest yourself. But ROS is not just: "Plug in any roboter and they magically understand ROS".


The answer to all your questions below is actually the same:

Any sensor or actuator provides an interface specification how to retrieve the data from it. What you need to do is to write a ROS driver for this HW, that adheres to the interface specification of the sensor/actuator and then "translates" this in the respective ROS message type.

The same basically holds for a micro controller, however, there you might have the chance to decide on the interface specification yourself.

Originally posted by mgruhler with karma: 12390 on 2016-10-13

This answer was ACCEPTED on the original site

Post score: 6

Original comments

Comment by alienmon on 2016-10-13:
When we create nodes, subscribers,and publishers etc, we create it in our PC. SO when we publish, only our PC knows. SO we do not send the info to the robot when we publish. How does the robot knows the info?

Comment by alienmon on 2016-10-13:
2. Where does all these translating process happen? in the actual robot or in our PC?

Comment by alienmon on 2016-10-13:
4. How does this reading info from the robot's sensors happen? I know that in simulation , the robot will publish message containing the sensor readings to certain topics.

How is it in real robot? How does the real robot know how to publish things to topics, if it does not have ROS installed in it?

Comment by mgruhler on 2016-10-13:
see edit above.

Comment by alienmon on 2016-10-13:
Thanks for your reply. But I'm still confused. When writing code , we publish message to a topic, and we do not send it to the robot. How does the robot know the information/msg since the robot does not have subscriber to the topic.

Comment by alienmon on 2016-10-13:
I meant when we publish message , it's only to the ros master which is our own pc. And i don't remeber sending it e.g. cmd_vel to the robot. Where(in the code) does this(sending data from pc to robot , which is different from publishing message to a topic) happen?

Comment by mgruhler on 2016-10-13:
you have a ROS node which subscribes to this topic and this then is the HW driver which translates it to whatever the robot understands.

Comment by gokhan.acer on 2020-05-12:
Your explain is very well. Firstly, thank you. But, I'm wondering about turtlebot3 communication protocol. I try to understand the Turtlebot3 code for PC, and OpenCR code for MCU. On Turtbot3-PC side, the robot generates and Twist message and publish on cmd_vel. But other side (MCU), there is an ardunio code and there are some ROS libs which are included. Code here. I am confused. Do you know about this achitecture?


Rosanswers logo

As mig says, the answers depend on your hardware.

Example 1 (my robot):

  • Raspberry Pi, on the robot, runs ROS.
  • Arduino-style microcontroller talks to sensors and motors, does not run ROS.
  • ROS node (ros_arduino_python) listens for /cmd_vel messages, decides motor speeds, and sends over a serial protocol to Arduino.
  • Arduino sketch (ROSArduinoBridge.ino, source in ros_arduino_bridge package) listens for motor speed commands, controls motors, and sends sensor values over serial protocol to RPi.
  • ros_arduino_python receives sensor values and publishes as ROS messages.

Example 2 (hypothetical robot):

  • Robot runs some Linux microcontroller, perhaps Raspberry Pi or Odroid, running ROS.
  • Fancy motor controller connected to microcontroller using USB connection.
  • Some sensors connected via I2C to microcontroller.
  • ROS node on robot listens for /cmd_vel, decides motor speeds, and sends to motor controller.
  • ROS node on robot talks I2C to sensors and publishes ROS sensor messages.

In both cases the ROS nodes on the robot and ROS on your PC communicate over WiFi, presumably. You could run the ROS master on the robot (that's what I do) or your laptop.

What is your hardware?

Originally posted by Mark Rose with karma: 1563 on 2016-10-13

This answer was NOT ACCEPTED on the original site

Post score: 7

Original comments

Comment by alienmon on 2016-10-13:
Hi ,thanks for your helpful answer.

My hardware is a drone(crazyflie). I didn't remember installing ROS in the crazyflie itself, and afaik it's not preinstalled in the drone. So I assume that the robot does not have ROS installed in it.

Comment by alienmon on 2016-10-13:
Since the robot does not have ROS installed , so all the nodes are my PC's nodes. What I am confused is : I don't remember sending info to the robot. I only publish message to topic. And all topics are in my PC.

Comment by alienmon on 2016-10-13:
Can you please give one more example on: robot that does not have ROS installed in it?

So, all the nodes running in PC, and there's no node in the robot. How does the sending information to the robot happen? It does not happen during publishing message right?


Comment by Mark Rose on 2016-10-13:
Well, another possibility would be a smaller robot I have that uses an Arduino-type board that has built-in Bluetooth. A ROS node on the PC could handle the sending and receiving data to the robot. Probably a roll-your-own protocol to send motor commands and get sensor data back.

Comment by Mark Rose on 2016-10-13:
Once you get outside of ROS message/service communication, either you have to do the communication yourself (from a ROS node), or you have to use a ROS node that knows how to control the hardware (usually only for commercial robots).

Comment by alienmon on 2016-10-13:
I think I finally got what @mig said now. There's a ROS driver in our PC that subscribe to e.g. cmd_vel, translate this cmd_vel to data type that the robot understands, and send it to the robot.

Comment by alienmon on 2016-10-13:
Just want to reconfirm. pls correct me @mig @Mark Rose

  1. ROS running on robot and PC. All the info exchange happen through subscribe & publish

  2. ROS ONLY running on PC. There's a ROS driver in our PC which subscribes to needed message e.g. cmd_vel, TRANSLATE it, and SEND it to robot.

Comment by alienmon on 2016-10-13:
3. ROS ONLY running on robot. So all the package involved e.g. navgation ,etc are in the robot itself .

Those are all possible right?

Comment by alienmon on 2016-10-13:
on ANY cases, when we want to control the actuator e.g. motor, we need to translate it to the type that the actuator understand e.g. int.

This can be done in:

  1. robot's callback function. e.g. when the robot's subscriber receive cmd_vel , the callback funtion extract the message & write to motor

Comment by mgruhler on 2016-10-14:
@alienmon yes

@Mark Rose Thanks for helping out here :-) The examples clarified my points.

Comment by hasnain on 2018-03-29:
Hi, I am really new to ROS. Can you please refer any tutorials or steps that I can follow to understand and implement this. I need to do this on my robot car. Thank you


Your Answer

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