Overview

The goals for this section:

  1. Learn to use RViz for visualizing information from your robot.
  2. Learn to write launch files to launch multiple nodes.
  3. Install nodes, launch files, and RViz config files in your ROS2 package.
  4. Test out code on hardware!

Setup Workspace

Task 1.1 — Directories. Create the base directory structure for your group’s ROS workspace, ~/autonomy_ws/src.

Task 1.2 — Clone and Branch. Clone your group’s GitHub repo to the src/ directory, and create a new branch called section3.

Task 1.3 — Create a Package. Create an empty ROS package inside of your group's git repository with the name s3_basic.

Task 1.4 — Examine and Customize. Just like you did in the previous section, use the cd and ls commands to explore your group’s newly created package. Use any editor to fill in the description, maintainer, and license fields of your newly created package.xml file. Use Apache License 2.0 for the license field.

Task 1.5 — Build. Navigate back to the “root” of your workspace, ~/autonomy_ws/, and build your ROS workspace using the command colcon build (do not run this command in any other directory). You should see something like the output below.

Starting >>> s2_basic          # package from last week's section 
Starting >>> s3_basic
Finished <<< s2_basic [0.87s]  # package from last week's section 
Finished <<< s3_basic [0.39s]

Summary: 2 packages finished [1.24s]

Cheat Sheet:

ls                      # List files and folders in the current directory
cd <directory>          # Change into directory
mkdir <directory>       # Make a directory with a given name
git clone <url>         # Clone a Git repository from a URL
git checkout -b <name>  # Create and switch to a new local branch
git checkout <name>     # Switch to a branch with a given name

# Create a new ROS package with the CMake build system.
ros2 pkg create --build-type ament_cmake <package_name>

# Run a ROS2 node
ros2 run <package_name> <script_name>

code <file> # edit a file for editing with VSCode
vim <file>  # edit a file with VIM

RViz

Task 2.1 — Launch Simulator and Constant Control Node. Recall from section 2.

<aside> 💡

you need 2 terminals for this.

</aside>

Task 2.2 — Launch RViz. (In another terminal), there are two ways to launch RVIZ, the easy (OS executable) way: