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

ros controller topics not being published

asked 2020-05-09 04:27:21 -0500

dinesh gravatar image

updated 2020-05-09 04:29:12 -0500

I am trying to write a custum ros hardware interface following this tutorial. I am trying to make a hardware interface for rrbot for testing purpose as it provides already present rrbot descrition and some launch files. Here is the git repository of this catkin package, which sucessfully builds but when i try to view the position controller topics i'm only seeing following ros topics:

$ rostopic list
/rosout
/rosout_agg
/rrbot/joint_states
/tf
/tf_static

when i launch the hardware interface node with the controller with command:

roslaunch rrbot_control rrbot_hardware_interface.launch

the output of the terminal display is:

started core service [/rosout]
process[rrbot/rrbot_hw_interface-2]: started with pid [14994]
process[rrbot/controller_spawner-3]: started with pid [14998]
process[rrbot/robot_state_publisher-4]: started with pid [14999]
read
write
[INFO] [1589016205.926310]: Controller Spawner: Waiting for service controller_manager/load_controller
[INFO] [1589016205.932689]: Controller Spawner: Waiting for service controller_manager/switch_controller
[INFO] [1589016205.938694]: Controller Spawner: Waiting for service controller_manager/unload_controller
[INFO] [1589016205.944457]: Loading controller: joint_state_controller
    read
    write
    read
    write
    ^C[rrbot/robot_state_publishe

r-4] killing on exit
[rrbot/controller_spawner-3] killing on exit
[rrbot/rrbot_hw_interface-2] killing on exit
[INFO] [1589016208.067200]: Shutting down spawner. Stopping and unloading controllers...
read
write

I am using ubuntu 18.04, ros melodic.

edit retag flag offensive close merge delete

Comments

You're most likely not spin()ing. Specifically: here.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-09 05:35:30 -0500 )edit

i tried that also. but still not working.

dinesh gravatar image dinesh  ( 2020-05-09 05:48:37 -0500 )edit

Have you tried using a ros::AsyncSpinner? If I remember correctly, it is needed to let the controller manager do its job while the hw is running...

ffusco gravatar image ffusco  ( 2020-05-09 15:09:43 -0500 )edit

i tried that also. but still not working.

And for future questions: "it does not work" is not a sufficient description of your problem.

No one can help you like this.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-10 04:26:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-05-10 04:05:32 -0500

gvdhoorn gravatar image

updated 2020-05-10 04:25:24 -0500

From the repository you linked, this is the main():

int main(int argc, char **argv)
{
  ros::init(argc, argv, "rrbot_hw_interface");

  MyRobot robot;
  controller_manager::ControllerManager cm(&robot);

  while (ros::ok())
  {
     robot.read();
     cm.update(robot.get_time(), robot.get_period());
     robot.write();
     sleep(1);
  }
  return 0;
}

This seems to not be spinning at all. Without that, incoming events cannot be properly processed, which prevents controllers from being started.

i tried that also. but still not working.

You must spin somewhere.

I'm not saying you should literally add spin(), the AsyncSpinner @ffusco mentions would be my first choice, and is in fact also used by the ros_control_boilerplate package you have in your workspace (from here):

int main(int argc, char** argv)
{
  ros::init(argc, argv, "sim_hw_interface");
  ros::NodeHandle nh;

  // NOTE: We run the ROS loop in a separate thread as external calls such
  // as service callbacks to load controllers can block the (main) control loop
  ros::AsyncSpinner spinner(2);
  spinner.start();

  [..]

}

Edit:

is this tested? cas i did this before, but was not working i think.

This pattern is used in countless hardware_interface implementations.

I'm not guaranteeing it will solve your problem, but your code currently does not seem to spin at all, which is certainly something to address first, before looking at other causes.


Edit2: your repository has been updated, now the main() is this:

int main(int argc, char **argv)
{
  ros::init(argc, argv, "rrbot_hw_interface");

  MyRobot robot;
  controller_manager::ControllerManager cm(&robot);

     robot.read();
     cm.update(robot.get_time(), robot.get_period());
     robot.write();
     ros::AsyncSpinner spinner(0); // Use 4 threads
     spinner.start();
  return 0;
}

This will not work. Please compare the structure in the ros_control_boilerplate package with your own code: you'll want to create and start the ros::AsyncSpinner before everything else. Then create your ControllerManager and MyRobot and finally start your while-loop (which seems to have disappeared).

edit flag offensive delete link more

Comments

is this tested? cas i did this before, but was not working i think.

dinesh gravatar image dinesh  ( 2020-05-10 04:11:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-05-09 04:27:21 -0500

Seen: 631 times

Last updated: May 10 '20