Category: Courses

  • ROS Basics (C++) – Basic ROS

    ROS Basics (C++) – A 4-Month Self-Study Course

    Welcome to “ROS Basics (C++)”! This comprehensive 4-month self-study course is designed to take you from a motivated beginner to an intermediate learner in the world of Robotics Operating System (ROS) using C++. Whether you’re an aspiring roboticist, a student, or a professional looking to expand your skill set, this course will provide you with a solid foundation in ROS, enabling you to develop and control robotic systems effectively. We’ll cover everything from setting up your ROS environment and understanding its core concepts to implementing complex robot behaviors and debugging your applications. Through engaging lessons, practical examples, and a culminating final project, you’ll gain the knowledge and hands-on experience necessary to confidently navigate the ROS ecosystem and contribute to exciting robotics projects.

    Primary Learning Objectives:

    Upon successful completion of this course, you will be able to:

    • Understand the fundamental architecture and core concepts of ROS.
    • Proficiently write, compile, and execute ROS nodes in C++.
    • Utilize ROS communication mechanisms (topics, services, actions) for inter-node communication.
    • Create and manage ROS workspaces and packages.
    • Debug ROS applications effectively using various tools.
    • Work with ROS parameters, launch files, and rosbag.
    • Develop basic robotic applications, including simple navigation and manipulation.
    • Apply learned concepts to design and implement a complete ROS-based robotic project.

    Necessary Materials:

    • A computer with Ubuntu Linux (20.04 LTS or newer recommended) installed.
    • Internet connection for downloading ROS and other necessary packages.
    • Text editor or IDE (e.g., VS Code, Sublime Text, Vim).
    • Familiarity with basic C++ programming concepts (variables, data types, control flow, functions, classes). While not strictly required, a basic understanding will significantly enhance your learning experience.

    Course Content: 14 Weekly Lessons (Structured within a 16-Week Timeframe)

    Module 1: Getting Started with ROS (Weeks 1-3)

    Week 1: Introduction to ROS & Environment Setup

    • Title: Diving into the Robot Operating System (ROS)
    • Learning Objectives:
      • Understand what ROS is and why it’s used in robotics.
      • Familiarize yourself with the ROS philosophy and architecture.
      • Successfully set up a ROS environment on your machine.
    • Key Vocabulary:
      • ROS (Robot Operating System): A flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.
      • ROS Master: The central coordinator for name registration and lookup in the ROS graph. It allows ROS nodes to find each other.
      • Node: An executable process in ROS that performs computation.
      • Package: The fundamental unit of organization in ROS, containing nodes, libraries, datasets, configuration files, and more.
      • Workspace: A collection of ROS packages where you develop your ROS applications.
      • Catkin: The build system used by ROS.
    • Content: ROS, or the Robot Operating System, isn’t an operating system in the traditional sense, but rather a powerful middleware that provides a standardized way for different software components to communicate and work together on a robot. Think of it as a common language and set of tools that allows various parts of a robot’s brain (like perception, planning, and control) to speak to each other seamlessly. This modularity is key, as it enables developers to reuse code, collaborate efficiently, and build complex robotic systems more easily. The core of ROS revolves around the concept of a “ROS graph,” which is a network of independent executable processes called “nodes.” Each node performs a specific task, such as reading sensor data, calculating robot movements, or controlling motors. These nodes communicate with each other using various mechanisms, which we’ll explore in detail. Setting up your ROS environment is the first crucial step. For this course, we recommend using Ubuntu Linux, as ROS is primarily developed and supported on this platform. The installation process typically involves adding the ROS repositories, updating your system, and then installing the appropriate ROS distribution (e.g., Noetic for ROS 1, Humble for ROS 2). Once ROS is installed, you’ll learn about ROS workspaces and packages. A workspace is essentially a directory where you’ll organize your ROS projects. Within a workspace, you create “packages,” which are the fundamental building blocks of ROS applications. Each package can contain source code (like your C++ files), configuration files, launch files, and more. The catkin build system is what ROS uses to compile your C++ code and manage your packages.

      Example: Imagine a robot that needs to detect obstacles and then move around them. In ROS, you might have one node responsible for processing sensor data to identify obstacles (a “perception node”), and another node responsible for generating movement commands to avoid them (a “navigation node”). These two nodes would communicate, with the perception node sending obstacle information to the navigation node, which then calculates a safe path.

    • Practical Hands-on Example:
      1. Install ROS (e.g., Noetic for ROS 1 or Humble for ROS 2) on your Ubuntu machine by following the official ROS installation guide.
      2. Create your first ROS workspace using mkdir -p ~/catkin_ws/src (for ROS 1) or mkdir -p ~/ros2_ws/src (for ROS 2).
      3. Source your ROS environment: source /opt/ros/<your_ros_distro>/setup.bash (for ROS 1) or source /opt/ros/<your_ros_distro>/setup.bash (for ROS 2).
      4. Verify your ROS installation by running roscore (for ROS 1) or ros2 daemon start (for ROS 2) in a new terminal, and then running rosnode list (for ROS 1) or ros2 node list (for ROS 2) in another terminal. You should see the rosout node listed.

    Week 2: ROS Nodes and Basic C++ Publishing

    • Title: Building Your First ROS Node: The Publisher
    • Learning Objectives:
      • Understand the concept of ROS nodes and their role in the ROS graph.
      • Learn how to create a basic C++ ROS publisher node.
      • Publish simple messages to a ROS topic.
    • Key Vocabulary:
      • Publisher: A ROS node that sends messages on a topic.
      • Topic: A named bus over which nodes exchange messages.
      • Message: A data structure used for communication between nodes.
      • ros::init: Initializes the ROS system.
      • ros::NodeHandle: A way to interact with the ROS system.
      • advertise: Method used by NodeHandle to create a publisher.
      • publish: Method used by a publisher to send a message.
      • ros::spinOnce(): Processes a single batch of pending callbacks.
      • ros::Rate: Used to control the loop frequency of a ROS node.
    • Content: At the heart of any ROS application are “nodes.” A ROS node is essentially an executable program that performs a specific, well-defined task within your robotic system. Nodes are designed to be modular and independent, communicating with each other through various mechanisms to achieve a larger goal. In this week, we’ll focus on the most fundamental communication mechanism: topics. Topics are like named channels through which nodes can send and receive data. A node that sends data on a topic is called a “publisher,” and a node that receives data from a topic is called a “subscriber” (we’ll cover subscribers next week). To create a C++ publisher node, you’ll use the roscpp client library. The basic structure involves including necessary headers, initializing ROS with ros::init(), creating a ros::NodeHandle to interact with the ROS master, and then using the advertise() method to set up a publisher for a specific message type and topic. Inside a loop, you’ll create messages and use the publish() method to send them. The ros::Rate object is very useful for controlling the publishing frequency, ensuring your node doesn’t consume all available CPU resources. ros::spinOnce() is called periodically to allow ROS to process incoming messages and callbacks.

      Example: A simple publisher node could be one that continuously publishes a “Hello, ROS!” string message on a topic named “/