ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Try to use SetBool and getting error.

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

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 =;
        ROS_INFO("flag true");
        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

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

Lucas Amparo gravatar image

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

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

Your Answer

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

Add Answer

Question Tools


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

Seen: 1,734 times

Last updated: Feb 04 '19