Question: ROScpp. How would i modify the below code so that it subscribes to the topic /scan and prints to the screen the contents of the
ROScpp.
How would i modify the below code so that it subscribes to the topic /scan and prints to the screen the contents of the field ranges
#include
void timeMessageReceived(const sensor_msgs::LaserScan::&array) { ROS_INFO_STREAM("Received time " << array.data); }
int main(int argc,char **argv) { ros::init(argc,argv,"getlaser"); ros::NodeHandle nh;
ros::Subscriber array = nh.subscribe("/scan",1000,&timeMessageReceived);
ros::spin();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
