0
$\begingroup$

Rosanswers logo

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


Originally posted by Guido on ROS Answers with karma: 514 on 2011-03-11

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by sglaser with karma: 649 on 2011-03-22

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Guido on 2011-03-23:
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.

$\endgroup$

Your Answer

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