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

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 (client.call(srv))
    {
        srv.request;
        stuff..

    res.success.data = 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
1

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:

http://wiki.ros.org/ROS/Tutorials/Wri...

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

Question Tools

1 follower

Stats

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

Seen: 1,628 times

Last updated: Nov 20 '14