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

has_parameter() in callback throws exception

asked 2019-09-25 02:42:09 -0500

madmax gravatar image

I am not sure how this is supposed to be done:

I have a parameter client and the node which is passed to the client spins ...

rclcpp::spin( paramServer.get_node_base_interface() );

Now when I get a service callback, and I call the function has_parameter():

paramClient.has_parameter( paramName )

I get the exception Node has already been added to an executor because inside has_parameter() it does spin_node_until_future_complete.

Only solution I can think of is to do it like that:

rclcpp::WallRate rate(5);
  while( rclcpp::ok() )
  {
     rclcpp::spin_some( paramServer.get_node_base_interface() );
     rate.sleep();
  }

So is it correct that I am not allowed to just spin the node if I want to do such things inside a subclassed node ( class ParamServer : public rclcpp::Node )?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-25 02:47:53 -0500

madmax gravatar image

Ok, stupid me...

I must not use the paramClient inside the node but the node itself to call has_parameter().

this->has_parameter( name ) instead of paramClient.has_parameter( name )

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-09-25 02:42:09 -0500

Seen: 608 times

Last updated: Sep 25 '19