ROS1 Subscriber callback
I have a simple class as follows:
class SimpleSub {
public:
SimpleSub(ros::NodeHandle *nh) {
nh->subscribe("/imu", 1000, &SimpleSub::imuSubsCallback, this);
}
void imuSubsCallback(const sensor_msgs::ImuConstPtr& msg)
{
ROS_INFO("Orientation: X=%f, Y=%f, Z=%f\n", msg->orientation.x, msg->orientation.y, msg->orientation.z);
}
private:
ros::Subscriber imuSub_;
};
When I run IMU publisher, my callback does not get called. However, it works when I use just stand-alone (not class member function) like this:
void imuSubsCallback(const sensor_msgs::ImuConstPtr& msg);
There is no compile error. Am I doing something wrong when registering callback (nh->subscriber)? Thanks!