gtest testing function with subscriber reference [closed]
Im using gtest for writing test suites for my robot. Im trying to test a function that i use to convert my twist message being sent from the Nav Stack or joystick (cmd_vel topic) that is then converted into my individual wheel velocities for my roboteq motor controller. This function that i am testing is used in the cmd_vel subscriber callback in my roboteq driver node. So normally, when the callback is fired, i pass the reference of the twist, into my function like so (i type def'd geometry_msgs::Twist to TTwist, and TWheelMsg is my custom msg, also type def'd)
void RosRoboteqDrv::CmdVelCallback(const TTwist::ConstPtr& twist_velocity)
{
_wheelVelocity = RosRoboteqDrv::ConvertTwistToWheelVelocity(twist_velocity);
Where my my conversion function is defined like so:
TWheelMsg ConvertTwistToWheelVelocity(const TTwist::ConstPtr& twist_velocity);
In my gtest class, im not sure how i can use this ConvertTwtistToWheelVelocity function since it is passing a reference. I tried looking up in the API docs where the reference originated from, and found that in the node handle subscriber template here it passes a boost shared pointer, which in my case i passed type geometry_msgs::Twist. So then i looked inside of the geometry_msgs source file, and found this:
typedef ::geometry_msgs::Twist_< std::allocator< void > >
Can someone please tell me what should i do to be able to pass some value (clearly has to be reference) into the ConvertTwistToWheelVelocity function? I dont know what to do since std::allocator is the template type.
Since in the API docs it says that the node handle subscribe function is a template
EDIT: here is what my subscriber call looks like:
_sub = _nh.subscribe("cmd_vel", 1, &RosRoboteqDrv::CmdVelCallback, this);