How to control my own robot through transfer function


Hey guys,

I’m trying to control my own robot through a transfer function, just like in the baseball tutorial. The robot is already imported in the NRP and all that worked well.

Because writing a transfer function from scratch and trying to access the robot through it didn’t work, I’m trying to understand the mechanism better by modifying some names in an existing model and seeing if it still works.

But this is where I got stuck: I renamed every single occurrence of r_elbow (except occurrences such as r_elbow_1 etc.) in the whole NRP folder, aka in the subfolders Experiments/tutorial_baseball_exercise, Models/icub_model and GazeboRosPackages/src/icub_initialization to a different string. I also did catkin_make inside of GazeboRosPackages and it told me the changed file was successfully built and linked. Finally, I added a line in the transfer function where a value is sent to that topic.

Still, when I execute the experiment, nothing happens with the elbow (experiment is started) and neither does anything happen when I edit the transfer function in the browser window and click on Apply.

Any ideas?


OK since I can’t delete my post, I’ll just say how I resolved it: I was passing a number to the joint that apparently was outside of the possible interval. After I chose a valid number, the robot moved.


So it’s not working with my own robot anyways… How can I make my joint subscribe to the ROS topic that is published to by the transfer function? I suppose that is where I’m missing something.


Hi Tobi

Looks like you could save yourself a lot of pain by using ROS commands to help you understand what is going on under the hood.

# Check whether the topics you are expecting exist:
rostopic list 
# Check whether the control topic is published to by the TF & listened to by your robot (gazebo if simulated):
rostopic info /robot/r_elbow/cmd_pos
# Check whether there's data being sent to the topic
rostopic echo /robot/r_elbow/cmd_pos

You can run these commands in your terminal or directly in the ROS terminal of the NRP.

You can also use rqt_graph to plot a graph of all the ros nodes and how they connect to each other with the ros topics.



Hi Jacques,

Thank you for your reply! So even though controlling the right elbow (with the original name, the pure Baseball Experiment Exercise with nothing changed except for is working and I’m controlling the right elbow in, I’m getting this output

and therefore also these errors:

On the other hand, if I execute these commands with pos instead of cmd_pos, it tells me in the original experiment that gazebo is subscribing to that topic. However, when I insert my model instead of the icub model, I get this output:

So my question is: How can I make gazebo subscribe to that topic? I believe my robot isn’t moving for precisely that reason.




Hi Tobi,

rostopics are different from a robot to another, sometimes the convention is /robot/r_elbow/cmd_pos sometimes just /robot/r_elbow/pos: this is why you use the ros commands, for figuring out name of topics quickly.

Indeed gazebo does not subscribe to the topic /robot/r_elbow/pos, because your robot does not tell gazebo that it’s controlled that way. The icub happens to have its own gazebo plugin:

  • GazeboRosPackages/src/controller_ros_gazebo_icub/src/controller_ros_gazebo_icub.cpp
  • referenced with <plugin name="ROSController_iCub" filename=""> in Models/icub_model/model.sdf

Most of the other robot use instead a generic plugin, the See Models/arm_robot/arm_robot.sdf for an example.

Does your robot already has a controller (a plugin) attached to it? If yes, you should see the control topic in rostopic list, if not, you need to add a controller in the sdf, like in the arm_robot.sdf.


Joint angles in Myorobotics Arm

Hello Jacques,

Thank you for the tip with the generic plugin. That made it work! Thanks so much!

Is this mentioned in the tutorials anywhere? Because I think it’s quite a valuable piece of information :smile:



No worries,

It’s not mentioned because it is ROS / Gazebo specific and not NRP specific, although new tutorials are in preparation so we’ll see =)

(Plus, now it’s on the forum!)