This repository is designed for teaching purposes and currently relies on knowledge gained from tutorials on TheConstruct, particularly the Advanced ROS2 Navigation course, and is intended for use along a physical Turtlebot3 robot.
This package has been tested with ROS2 Humble.
The turtlebot3_navigation
package provides some package structure and code templates for a series of code that will be used to autonomously navigate around a known map which has been generated by a physical turtlebot3 robot.
First install colcon common files
sudo apt install python3-colcon-common-extensions
Install ROS2 at the following link: ROS2 Humble Installation
Complete the steps in the link above, making sure to install the desktop versionof ROS2, and not the base version so that we install GUI utilities on our primary machines. Read all of the prompts carefully to avoid attempting to build multiple or incorrect versions, don't blindly copy and paste every line.
Create a new workspace after ROS2 installation is complete;
mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws
colcon build --symlink-install
source install/setup.bash
Clone this package (turtlebot3_navigation
) into your new workspace using git:
cd ~/turtlebot_ws/src
git clone -b main https://github.com/uml-robotics/turtlebot3_navigation.git
cd .. # this moves into the parent directory; alternatively run cd ~/turtlebot_ws
colcon build
source install/setup.bash
Install turtlebot3 required packages:
sudo apt install ros-humble-gazebo-*
sudo apt install ros-humble-cartographer
sudo apt install ros-humble-cartographer-ros
sudo apt install ros-humble-navigation2
sudo apt install ros-humble-nav2-bringup
Install turtlebot3 packages:
source ~/.bashrc
sudo apt install ros-humble-dynamixel-sdk
sudo apt install ros-humble-turtlebot3-msgs
sudo apt install ros-humble-turtlebot3
Install ssh
sudo apt install ssh
Each turtlebot needs a unique ROS_DOMAIN_ID
specified so that it can properly communicate with the intended machine, you do not need to look into this further for now but we will use two tested values for the turtlebots. In order to communicate with the robot via a host PC, the PC and robot need to have the same ROS_DOMAIN_ID
environment variable. Instructions on how to perform this action are detailed below.
- for turtlebot3-1;
<ID_NUM>
will be 30 - for turtlebot3-2;
<ID_NUM>
will be 0
In the code snippets below, make sure to replace <ID_NUM>
with the correct numerical value as defined above before you hit enter, this is not an environment variable and the < >
instead denote a value that must be edited. This is common syntax so be on the lookout for these symbols in other sets of instructions. Specifically, make sure that if you copy and paste the following lines that you edit that segment before hitting enter.
Starting Turtlebot3:
- On a terminal ssh'd into Turtlebot:
in a new terminal: ssh turtlebot@<\ip-address-of-robot>
export TURTLEBOT3_MODEL=burger
export ROS_DOMAIN_ID=<ID_NUM>
ros2 launch turtlebot3_bringup robot.launch.py
- On your primary PC (not ssh'd into the turtlebot) in a new terminal:
export TURTLEBOT3_MODEL=burger
export ROS_DOMAIN_ID=<ID_NUM>
Creating a map:
- On your primary PC (not ssh'd into the turtlebot) in a another new terminal:
ros2 launch turtlebot3_cartographer cartographer.launch.py
- On your primary PC (not ssh'd into the turtlebot) in a another new terminal:
export TURTLEBOT3_MODEL=burger
export ROS_DOMAIN_ID=<ID_NUM>
ros2 run turtlebot3_teleop teleop_keyboard
- On your primary PC (not ssh'd into the turtlebot) in a another new terminal:
ros2 run nav2_map_server map_saver_cli -f ~/map
Note that the final argument is a directory, you can choose to save the file in a specific location to make it easier to access. Experiment with examining the map and cleaning up edges if necessary in an image editor software.
Nav2 Documentation Navigation2 Github repository
- Contains all of the Nav2 packages and instructions for setup and usage if you need to look deeper into any component.
Project Steps:
- Follow the instructions in this repository to install ROS2 and set up your machine to work with the turtlebot3 robot
- Set up a Github account if you do not already have one
- Create a new repository on your github account, uncheck the box to create a README file so that it is completely empty. We will push your code up here for practice with version control.
- Create a small map with turtlebot3
- Create a launch file that launches all of the nav2 nodes you need
- Create a composable node that goes to a set of waypoints, at least 5 (4 corners and center as much as possible) around map and records the completion time of full navigation
- Modify the map and add a keepout filter and run again for time
- Modify the map and add a new keepout filter using preferred lanes and run again for time
- Add physical obstacles into the robots expected path before running, and see how your robot reacts. Update your filters to try and improve performance (slowdown areas, keepout additions/removals, etc.)
- Add a speed limit filter to control robot speed at certain junctions