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

Revision history [back]

click to hide/show revision 1
initial version

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();

  [..]

}

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.

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).

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.

Your


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).