Ask Your Question
0

Error on calling a rosservice

asked 2018-03-03 12:09:21 -0500

bxl gravatar image

updated 2018-03-03 12:22:21 -0500

Im trying to enable hector_quadrotor motors' on throught code:

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

   ros::NodeHandle nh;

  ros::ServiceClient enable_motors = nh.serviceClient<hector_uav_msgs::EnableMotors>("enable_motors");

  hector_uav_msgs::EnableMotors motors;
  motors.request.enable = true;

  if (enable_motors.call(motors)){
    ROS_INFO("Motors on");
  }
  else{
   ROS_INFO("Motors off");   
 }

However, calling the service always fails (returns 0) and results on the else statement.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-03 15:32:27 -0500

bxl gravatar image

Have to wait for service to become available:

enable_motors.waitForExistence()

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-03 12:09:21 -0500

Seen: 125 times

Last updated: Mar 03 '18