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

pass arguments with called service

asked 2014-11-20 09:56:37 -0500

irgendeinGastname gravatar image

Hey, in my code I call a service that calls another service

bool srvCallback_my_switcher(cob_srvs::Trigger::Request &req, cob_srvs::Trigger::Response &res)

    if (
        stuff.. = true;
    return true;

is there a possibility to call the service srv with an argument for example a bool variable? I would like the called service to differ whether variable is true or false.

Kindly guide :))

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-11-20 10:15:30 -0500

Torsten gravatar image

updated 2014-11-20 10:21:43 -0500

You should pass the variable you need by assign srv.request.[VariableName] = [true, false];, like you did in the response. Please also look at this tutorial:

beginner_tutorials::AddTwoInts srv;
srv.request.a = atoll(argv[1]);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-11-20 09:56:37 -0500

Seen: 1,636 times

Last updated: Nov 20 '14