Subscriber to /scan
This the error i'm getting for the code m writting below. I'm trying to write a subscriber to /scan and a callback function which prints the angle_min on the terminal (ranges[] later). However i guess im making a mistake in the ROS_INFO(....) part. Please have a look and Please help. Thank You.
In function ‘void poseMessageReceived(const ConstPtr&)’: error: ‘const ConstPtr’ has no member named ‘angle_min’ make[2]: * [beginner_tutorials/CMakeFiles/lms.dir/src/lms.cpp.o] Error 1 make[1]: * [beginner_tutorials/CMakeFiles/lms.dir/all] Error 2
#include "ros/ros.h"
#include "sensor_msgs/LaserScan.h"
#include "std_msgs/String.h"
#include "iomanip"
void poseMessageReceived(const sensor_msgs::LaserScan::ConstPtr& scan)
{
ROS_INFO("position=: [%f]",scan.angle_min);
}
int main(int argc,char **argv)
{
ros::init(argc,argv,"subscribe_to_scan");
ros::NodeHandle n;
//Create a subscriber object
ros::Subscriber sub = n.subscribe("/Scan",1000, poseMessageReceived);
//Let ROS take over
ros::spin();
return 0;
}