create subscriber for /turtle1/pose data
i tried to subscribe /turtle1/pose values to the node i created using this :
#include "ros/ros.h"
#include "turtlesim/Pose.h"
#include "std_msgs/Float32.h"
#include <sstream>
void callback(const turtlesim::Pose::ConstPtr& lis)
{
std_msgs::Float32 m;
m.data=lis.x;
ROS_INFO("i heard %f \n",m.data);
}
int main(int argc, char * argv[])
{
turtlesim::Pose lis;
ros::init(argc,argv,"listen");
ros::NodeHandle n;
ros::Subscriber sub1=n.subscribe("/turtle1/pose",1000,callback);
ros::spin();
return 0;
}
but it doesn't seem to work , i guess the problem is with the pointer lis since turtlesim::Pose is multi-dimensional array .
What do you mean? What does happen?
Thanks i solved it out , I had first to copy data from pointer to another variable with data type turtlesim::Pose For example , turtlesim::Pose V=* lis;. Then I can access V.x
Perhaps you can write up your solution as an answer instead of a comment?