ROS2 Prerequisites

Skills Needed for ROS2

Although ROS2 is a neat framework that allows for a nice abstraction layer when programming a robot there are still (not mandatory just helpful) prerequisites that are needed before you can take a deep dive into ROS2. These skills include the following: C++, Python (just a bit), and Linux. You do not need to be an expert with these skills but having a little bit of knowledge of these three skills will help you greatly.  

C++

On the software team, we will be using c++ as our language of choice when developing ROS2 packages. I am well aware that ROS2 supports python. However, there is more support for ROS2 with c++. An example of this is the development of topic statistics for rclcpp (ROS2 c++), but not rclpy (ROS2 python). There are a few key things one should be familiar with before jumping into rclcpp. These include the following

  • Basics of Programming (control statements, functions, scopes, types, etc)
  • Classes, Structs, Polymorphism, Inheritance 
    • ROS2 uses Inheritance very heavily (e.g. creating a node is simply extending the rclcpp::Node class)
  • Smart Pointers
    • Shared Pointers
      • Making shared pointers 
    • Unique Pointers
      • Making unique pointers
  • Templates
    • Used heavily within ROS2
  • Callbacks & Function Pointers
  • Modern C++
    • Lambdas (Used a lot in place of callbacks, less code)
    • ‘auto’ keyword
    • For each loop 


A nice website to refresh or learn all the things above is https://www.learncpp.com/ 

Linux Tutorial

At this point, you should have a functioning Ubuntu 20.04 installation. If you are comfortable with the Linux command line already, you can move on to the next section. Before moving on, you should at minimum be comfortable using the command line to perform basic operations such as:

  • Navigate the file system
  • Create/delete files and folders
  • Edit files
  • Install new packages
  • Run commands as root user
  • Change file permissions

There are dozens of in-depth Linux tutorials online to get you started. Here are a couple of links you can look through:

Once you feel comfortable using the command line for at least the tasks listed above, you can move on to the next section.

Code Quality

We've decided this year to have an emphasis on good code that is easily readable and testable. This is so that code is reliable and can be quickly debugged if needed. This will allow us to reuse more code from year to year. While we have stopped short of requiring full unit test code coverage, we recommend you follow Test Driven Development

In general:

  1. Break down the problem into small functions that are 5 to 10 lines of code long. Be sure to consider the inputs and outputs of the function.
  2. Write a header file for the function (Now would be a good time to check in with a lead to see if you're on the right track)
  3. Write the CPP file implementing all the functions