Ask Your Question

Ongun Kanat's profile - activity

2015-09-09 19:44:50 -0500 received badge  Famous Question (source)
2015-09-08 20:00:08 -0500 received badge  Notable Question (source)
2015-09-08 19:23:04 -0500 received badge  Student (source)
2015-07-25 09:19:40 -0500 received badge  Popular Question (source)
2015-07-24 11:28:18 -0500 asked a question boost::bind with Ros Service

I have a ROS Service GripperState

int32 gripperState
int32 paddleState

And In my main.cpp file I have this line since I need gripper data from robot needs to be passed to service

ros::ServiceServer gripperService = 
    n.advertiseService<my_robot::GripperState::Request, my_robot::GripperState::Response>
    ("GripperState",boost::bind(&gripperControl, node->getGripper(), 
    (my_robot::GripperState::Request &) _2,  (my_robot::GripperState::Response &) _3));

In GripperServer.cpp I have the definition of method gripperControl

bool gripperControl(ArGripper *gripper, my_robot::GripperState::Request &req, my_robot::GripperState::Response &res)
    int32_t gSt = gripper->getGripState();
    int32_t pSt = gripper->getPaddleState();
    ROS_INFO("GripperSt : %d, PaddleSt: %d", gSt, pSt);
    res.gripperState = 5;
    res.paddleState = 10;
    return true;

However it compiles. It doesn't work since boost doesn't pass the placeholders _2 and _3 as references.(I think it creates a copy of each parameter).

Is there any way to make this work?