avoid_wall.cpp
. Specs:ROS node:
- Create a Publisher that writes into the /cmd_vel topic in order to move the robot.
- Create a Subscriber that reads from the /kobuki/laser/scan topic. This is the topic where the laser publishes its data.
- Depending on the readings you receive from the laser's topic, you'll have to change the data you're sending to the /cmd_vel topic in order to avoid the wall. This means, use the values of the laser to decide.
Program logic:
- If the laser reading in front of the robot is higher than 1 meter (there is no obstacle closer than 1 meter in front of the robot), the robot will move forward.
- If the laser reading in front of the robot is lower than 1 meter (there is an obstacle closer than 1 meter in front of the robot), the robot will turn left.
- If the laser reading at the right side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the right side of the robot), the robot will turn left.
- If the laser reading at the left side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the left side of the robot), the robot will turn right.
CMakeLists.txt
. To do:add_executable
.add_dependencies
.target_link_libraries
.- Anything specific for messages?
package.xml
. To do:<build_depend>
.<build_export_depend>
.<exec_depend>
.- Anything else?