This activity focuses on creating a simple navigation system using rviz. You will input a waypoint destination for the robot by clicking on the desired location. The robot will then navigate to that destination from its current position.
Additionally, you will learn about messages and how to navigate the documentation in order to effectively send and receive the data you need.
Download the activity_4.zipfrom the link below
Extract the contents of zip to ~/catkin_ws/src .
Open a terminal and navigate to your catkin workspace. Then, use catkin build to build the package.
Source your workspace using source ~/catkin_ws/devel/setup.bash.
Launch the activity package using the command roslaunch activity_4 activity.launch.
Make sure gazebo and rviz launch successfully. When they do, you’re ready and you can close them both and shut off the program.
Collecting input in rviz requires a map, this is because we need something to click on.
Thankfully, we can make a map pretty easily for an empty, flat plane world like what we’ll be working with. We will be using the OccupancyGrid message type, which comes from the nav_msgs library
Documentation for the OccupancyGrid and other messages can be found here:
<aside> 📔 http://docs.ros.org/en/noetic/api/nav_msgs/html/index-msg.html Note: click the message types in the Compact Message Definition of each message type for more information
</aside>
To begn, navigate to /class_activity_4/src/map_node.py, where the base code is provided.
Because our world is simple, our map can be simple, too. We need only one pixel!
We will need to construct and fill out an OccupancyGrid . The resulting code is shown below
map = OccupancyGrid()
map.info.height = 1
map.info.width = 1
map.info.resolution = 100
map.info.origin.position.x = -50
map.info.origin.position.y = -50
map.data = map_data