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

Try to use SetBool and getting error.

asked 2019-02-04 12:35:58 -0500

Lucas Amparo gravatar image

I'm trying to use a simple service to switch a server flag, with this code:

// Service bind
ros::ServiceServer switch_srv = n.advertiseService(
        "angle_flag_request", angle.serverRequest
);

// angle.serverRequest definition
void RosAngleFlag::serverRequest(
    std_srvs::SetBool& req,
    std_srvs::SetBool& res)
{
    bool req_type = req.request.data;
    if(req_type)
        ROS_INFO("flag true");
    else
        ROS_INFO("flag false");

    res.response.success = true;
    res.response.message = "teste";
}

And the return are that message:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [19], void(std_srvs::SetBool&, std_srvs::SetBool&))’

I've imported "std_srvs/SetBool.h" in my header file... Someone can help me?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-02-04 12:57:03 -0500

Lucas Amparo gravatar image

updated 2019-02-04 12:57:19 -0500

Change void to bool on serverRequest solve the problem. And add the Response and Request definition on the function parameters.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-02-04 12:35:58 -0500

Seen: 2,086 times

Last updated: Feb 04 '19