Does function type of callback work in class?
Hi everyone,
I am wondering if I can use function type of callback in a class?
This is my function type callback signature:
double current_joint_position[7];
double current_joint_velocity[7];
void controllerStateCB(const pr2_controllers_msgs::JointTrajectoryControllerState::ConstPtr& msg)
{
for (int joint_index = 0; joint_index < 7; joint_index++)
{
current_joint_position[joint_index]=msg->actual.positions[joint_index];
current_joint_velocity[joint_index]=msg->actual.velocities[joint_index];
}
}
This is where I define the subscriber:
void move_group::MoveGroupMoveAction::executeMoveCallback_PlanOnly(const moveit_msgs::MoveGroupGoalConstPtr& goal, moveit_msgs::MoveGroupResult &action_res)
{
...
...
...
ros::NodeHandle handle;
ros::Subscriber sub = handle.subscribe("r_arm_controller/state", 1000, &controllerStateCB);
...
...
...
}
The function signature is in the same cpp file of the class.
However, it seems that the callback function is never called even though there is message in "r_arm_controller/state" topic.
Thanks for any help in advance!
Quan
Thank you tbh, I just miss spin in my code.