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?