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 #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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!