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

Callbacks in pr2 controllers

asked 2011-03-11 01:48:19 -0500

Guido gravatar image

updated 2014-11-22 17:05:36 -0500

ngrennan gravatar image

Hi ros answers users,

I'm currently trying to make a custom controller work on pr2. I have two subscribers inside the controller.My problem is that their respective callbacks are not called. Moreover I noticed that the existing controllers on pr2 (namely joint_spline_controller and joint_velocity_controller ) don't call spinOnce. Still, they use subscribers and callbacks. So my question is how and when are callbacks called for a controller ?

Guido

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2011-03-22 14:01:31 -0500

sglaser gravatar image

updated 2011-03-22 14:07:35 -0500

Hi Guido,

ROS's spin() function is called external to the controller manager. On the PR2, it's called from pr2_etherCAT, and in Gazebo it's called from pr2_gazebo_plugins. The controller manager itself uses ROS to load and unload controllers, and many other topics are published (such as joint_state), so if spin() weren't being called, there would be many other issues.

I'm not sure why your subscription callback isn't being called, but I suspect it's just related to standard ROS issues and unrelated to the controllers. Try using rostopic info, rostopic echo, rosnode ping, and rosnode info. Check that both ends are connected to the same topic, and that messages are being published.

One last thing to check: be sure that your controller's init() method finishes.

If you still can't find the issue, try posting some code.

Best of luck

edit flag offensive delete link more

Comments

It was indeed a connection problem between both ends of the topic. I forgot to take into account namespaces, so the topic advertised was /command but the topic to which I should publish is /my_controller/command. I was missing the "/my_controller" part. Thank you for the explanation.
Guido gravatar image Guido  ( 2011-03-23 20:45:29 -0500 )edit
0

answered 2011-03-15 00:59:08 -0500

bit-pirate gravatar image

Hi Guido,

did you already solve your problem? In which part of your code are you using these subscribers or their callbacks? Maybe if you provide more information, I could help you. Here are some words about how I use subscribers and callbacks in my custom controller.

In the init() part of the controller I subscribe to a couple of topics, which contain information about tracked positions. The callback functions of these subscribers update the target positions and also the corresponding flags. All of these things are class members of the controller. In the update() loop the flags indicate whether or not the controller has to use the updated target positions or not. All that works fine for me.

But I am also wondering, if this usage is real-time safe. Can anyone provide some information about that?

I opened up a new question to ask about real-time facts in a more general scope -> real-time safe communication with a controller. Maybe answers there are helpful for your problem.

:-) Marcus

edit flag offensive delete link more

Comments

Thank you for your answer. Unluckily my problem is not solved yet. I use two subscribers, members of the controller class, which subscribe to two topics in the init(). Callbacks are private methods which write into private members. I continue searching...
Guido gravatar image Guido  ( 2011-03-15 04:40:46 -0500 )edit
Dear Marcus, i notice that the default controllers don't subscribe to topics in the same way. Would you be so kind to show me which function you use. I use "sub_command_ = node_.subscribe("command", 1, &Pr2Controller::commandCB, this)".
Guido gravatar image Guido  ( 2011-03-18 01:09:36 -0500 )edit

Question Tools

Stats

Asked: 2011-03-11 01:48:19 -0500

Seen: 435 times

Last updated: Mar 22 '11