Rosanswers logo

Hi folks,

I have a 4WD/4WS mobile robot, which I can control it through rosserial/arduino (open loop control). I have setup the robot in Gazebo and I'm able to use ros controllers to control each joint with position_joint_controller and velocity_joint_controller. As we know setting up and applying ros control is easy for simulation in Gazebo using URDF files which make it easy for us to use ros control just by adding plugins and transmission tags, but when it's coming to real hardware it makes a lot of confusions.

I followed Adolfo Rodriguez's RosCon 2014 lecture and it explains everything very well and of course very brief.

Q1) How can I read from and write to my hardware? (Adolfo's lecture page 43) Do you have a good example for rosserial? What do I need to have to define each of my actuators as a joint? (it can be easily done by URDF files for Gazebo usuing transmission tags).

I tried to write an interface node to get cmd_vel and publish it to my servos but what I want is to use ros_control. Sorry if my question is not that clear but if you please help me with some examples if you have.


Originally posted by Mos on ROS Answers with karma: 28 on 2015-07-28

Post score: 0

Original comments

Comment by Adolfo Rodriguez T on 2015-08-06:
Can you already read/write raw data from your arduino device?.

Comment by Mos on 2015-08-06:
I actually have a node, subscribing to cmd_vel from ROS and encoder ticks from ardunio usuing rosserial. It also publishes RPM/Speed to ROS and PWM to arduino to drive the dc motors.


1 Answer 1


Rosanswers logo

If you can already read/write raw data from hardware, you need to map this raw data into ros_control interfaces. Regardless of how you talk to hardware, these are some examples of how to do this mapping:

Originally posted by Adolfo Rodriguez T with karma: 3907 on 2015-08-06

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Mos on 2015-08-14:
Thanks! So far what I did to finally figuring everything out is to subscribe to data I need in read function and publish the required data through write function and now everything works perfectly fine.

Comment by al0ne on 2017-04-04:
hey Mos, can you add your solution like example? I don't know how i can map the raw data

Comment by Irin Thirdwater on 2019-03-24:
For anyone stumbling upon this and found that the linked lines no longer match up, here are the commit-independent links to the snippets: gz_ros_ctrl, KUKA.

Comment by Irin Thirdwater on 2019-03-24:
For al0ne, you've probably already solved your problem so I doubt you will need this, but it generally involves:

  1. Having a set of variables representing your data (in KUKA's example, they have arrays for position, velocity, and effort for each joints) (these, you should update constantly through your robot hw's read/write methods)
  2. Assigning these variables to a corresponding resource handle (note in KUKA's, this is done in a loop for each joint j)
  3. Registering the handle(s) to the interface in your robot hw (for joint states in KUKA, step 2 and 3 have been inlined)

Your Answer

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