I’m trying to work on the real robot project on ros2 basics C++ where I have to build a wall follower package. I have subscribed to the /scan topic but it doesn’t seem to read it properly. I have attached screenshots. Please help.
Has the robot started moving? You should move the robot and then check the reading at different positions of the ranges array.
You can also use
ros2 echo to check if the readings change with movement. If they do, then you need to fine-tune your code to detect the readings properly.
Hi, thanks for your reply. I had tried that. When I do
ros2 echo, it shows the ranges properly. They change when I move the robot. But the problem persists.
Well, then, the problem is somewhere in your code. What you can do:
- Carefully compare your code to the samples given in the course.
- You might not be calling
ros::spin()properly in your code. Please see this post for more information.