how to get turtlebot pose
I would like to get turtlebot poses when it walking. The following codes are used, but there is no responds. I guess it was the problem of topic "/odom". could anybody give me some ideas to fix it? thanks.
virtual void onInit()
{
ros::NodeHandle& nh = getNodeHandle();
ros::NodeHandle& private_nh = getPrivateNodeHandle();
cmdpub_ = private_nh.advertise<geometry_msgs::Twist> ("cmd_vel", 1);
sub_= nh.subscribe<PointCloud>("depth/points", 1, &TurtlebotFollower::cloudcb, this);
ros::Subscriber sub = nh.subscribe("/odom",10, &TurtlebotFollower::poseCallback,this);
}
void poseCallback(const geometry_msgs::TwistPtr& msg){
std::cout << msg.linear.x << "\t" <<msg.linear.y<< "\t" << 0.0 << "\t" << std::endl;
}
I found that if I put above codes into the onInit() virtual function, it will be failed. But if I put it in an main() function, it will be succeed. What is the difference?
Did your poseCallback work even if the message type is geometry_msgs::Twist? You are trying to use nodelets. You have to run them differently. Please follow the link to learn about running nodelets.
sorry, the "succeed" means that I've changed them to nav_msgs. I will check nodelets, thank you Willson.