ROS2 Introduction - rhaschke/lecture GitHub Wiki

ROS: Robot Operating System

  • middleware, i.e. inter-process communication
  • hardware abstraction for robots
  • message definitions (for RPC)
  • package management system, tailored towards development
  • collection of open-source software packages
  • multi language: C++, Python, Java
  • multi platform: (Ubuntu Linux), Windows 10, OSX

middleware concepts

  • topics (publish - subscribe)
  • services (remote procedure calls)
  • actions (preemptable, long-running tasks)
  • nodes: logical computing components, several per process possible
  • remapping: renaming of nodes, topics, etc.
  • node parameters

building from source

  • ROS2 packages use ament, a series of build helpers that hook into or extend existing build tools (like cmake or python's setuptools) to facilitate building and package management
  • colcon is a meta build tool that crawls your workspace for packages and builds them
  • hierarchical stacking of workspaces:
    /opt/ros/<distro>
      ⮤ /homes/juser/ros
    
    activate environment with: source <workspace dir>/setup.bash
  • workspace structure
    • src/
    • build/
    • install/
      • setup.bash

setup your ROS workspace

# create your ROS workspace
mkdir -p ~/ros/src
cd ~/ros/src

# clone lecture repository from github
git clone https://github.com/rhaschke/lecture

# install colcon-top-level-workspace to allow building from any folder in your workspace
pip install git+https://github.com/rhaschke/colcon-top-level-workspace

# source your parent ROS environment
source /opt/ros/<distro>/setup.bash

# once build in your workspace's root folder
cd ~/ros
colcon build

package structure

  • package.xml
    • defines folder as a ROS package
    • defines dependencies: build, test, run
    • author, license, package information
  • CMakeLists.txt

example ROS session

source /opt/ros/<distro>/setup.bash
ros2 topic pub chatter std_msgs/msg/String 'data: "Hello World"' &
ros2 topic echo chatter

Inspect ROS universe:

ros2 node list
ros2 topic list
ros2 service list
ros2 interface list

rqt_graph
⚠️ **GitHub.com Fallback** ⚠️