ROS2_pubsub/README.md

66 lines
5.9 KiB
Markdown
Raw Normal View History

2021-01-13 15:28:01 +01:00
# pubsub - Publisher & Subscriber Package
2021-04-13 16:30:51 +02:00
Minimal Publisher & Subscriber Template for ROS2.
```
2021-01-13 15:28:01 +01:00
Created for ROS Workshop 2020
2021-04-13 16:30:51 +02:00
Course Roverentwicklung für Explorationsaufgaben
2021-01-13 15:28:01 +01:00
Institute for Space Systems
University of Stuttgart.
```
Class Code created by [Patrick Winterhalder](https://www.irs.uni-stuttgart.de/en/institute/team/Winterhalder/),
[IRS](https://www.irs.uni-stuttgart.de), University of Stuttgart.
2021-01-13 15:28:01 +01:00
## Workshop Prerequisites
2021-04-19 16:20:33 +02:00
In order to run ROS2 you must install **Ubuntu 20.04 LTS** on a capable machine (preferrably desktop/laptop).
2021-03-16 13:59:12 +01:00
* Install [Ubuntu 20.04](https://help.ubuntu.com/lts/installation-guide/index.html)
For a successful workshop you must conduct [this installation on your desktop machine](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/workshopinstall.sh) or [this installation on your Raspberry Pi](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/rpi_install.bash). Go through the commands of these *.bash file line by line and check if every commands finishes without errors! Following these .bash files should do the following:
2021-03-16 13:59:12 +01:00
* Install Visual Studio Code using the [Ubuntu Software Installer](https://wiki.ubuntuusers.de/Ubuntu_Software/)
2021-01-13 15:28:01 +01:00
* Install [Git](https://linuxconfig.org/how-to-install-git-on-ubuntu-20-04-lts-focal-fossa-linux) (no account required yet)
* Install [ROS2](https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/) (choose "desktop" on PC or "base" on Raspberry Pi, this eliminates all GUI tools from the installation, e.g. rviz and rqt).
2021-03-16 13:59:12 +01:00
* Also install _argcomplete_
* No need for _ROS 1 bridge_ or _RMW implementations_
* Install and update _rosdep_
After successfully installing ROS2 you should get to know it by working through the ["Beginner: CLI Tools"](https://index.ros.org/doc/ros2/Tutorials/) tutorial. This will teach you how to [configure your ROS 2 environment](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/) and you will learn about:
2021-03-16 13:59:12 +01:00
* Source setup files (understand **Underlay** & **Overlay**)
* How to configure the .bashrc file (shell startup script), a good example is [here](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/bashrc_overlay.bash))
* Add all _colcon_ workspaces to the shell startup script
2021-03-16 13:59:12 +01:00
* Check environment variables (check for correct installation)
2021-03-16 14:48:43 +01:00
* Configure *ROS_DOMAIN_ID* (DDS Network Number)
* Work through the tutorials covering _turtlesim, rqt, topics, services, actions_
2021-01-13 15:28:01 +01:00
## Install Instructions
The following steps describe how you can create a local copy of this repository containing ROS2 publisher and subscriber class templates.
2021-04-13 17:43:08 +02:00
* Move to your colcon workspace `cd <workspace_path>` (eg. `cd ~/colcon_ws`)
* Clone this repository: `git clone https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub.git .` (include `.` at the end of the command in oder to copy everything to this locations!)
2021-03-16 14:48:43 +01:00
* Build workspace: `colcon build` , __Note:__ Only the files inside _/src/_ are of importance.
* Remember to run `source ~/<workspace_path>/install/local_setup.sh` after every build.
2021-04-19 16:33:14 +02:00
In order to avoid this repetitive command, add line 23-27 from [_.bashrc_](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/bashrc_overlay.bash) to your shell startup script for every overlay you want to source. This script runs everytime you start a new console, thus loading your overlays automatically. This is very handy if you are working with multiple _colcon_ workspaces (overlays) simultaneously.
2021-01-13 15:28:01 +01:00
2021-04-13 17:43:08 +02:00
## Workshop Content
2021-03-16 14:48:43 +01:00
In this workshop you will:
* Create a new _colcon_ workspace
* Create a new package inside your newly created _colcon_ workspace
2021-01-13 15:28:01 +01:00
* `ros2 pkg create --build-type [ament_cmake, ament-python] <package_name>`
* Build your _colcon_ workspace, this means making it a functional ROS2 workspace from which you can start nodes:
2021-03-16 14:48:43 +01:00
* First move to your workspace root: `cd ~/<workspace_path>`
* Run `colcon build --symlink-install`
* Add your workspace overlay to the shell startup script for sourcing everytime you open a new console:
2021-04-19 16:41:26 +02:00
* Add [this](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/bashrc_overlay.bash) to the end of .bashrc (`sudo nano .bashrc`)
* In [this template](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/bashrc_overlay.bash) find all instances of "`~/ws_overlay_foxy`" and replace it with the path to your own _colcon_ workspace (replace `~/` with `$HOME` for representing the home directory variable in bash scripts)
2021-04-20 22:09:51 +02:00
* Create custom message (*.msg) or service (*.srv) files in order to create custom interfaces to exchange information between nodes. For this you can use the pre-made `/custom_interface` package and add your own *.msg and/or *.srv files using this [instruction document](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/srv_tests/src/custom_interfaces/Readme.md) (__easy__), or you can start from scratch by following [these instructions](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/instructions_custom_topics.md) (__hard__).
2021-04-13 17:43:08 +02:00
2021-04-20 12:23:18 +02:00
## Rules and Standard
In order for your code to work and to prevent major problems please read through [this document](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/Programming_Rules.md). This will give you a brief oversight over how to develop a ROS2 package using Python.
2021-04-13 17:43:08 +02:00
## Presentation
2021-04-20 22:04:04 +02:00
The workshop's content is covered in [this presentation](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/non-ros-files/ws-05-ros-workshop%20%281%29.pdf).
2021-04-21 11:14:15 +02:00
## Further Documentation:
* `pubsub/pubsub/` [Readme.md](None): Information on the example files and libraries to create communication interfaces between ROS nodes.
* `custom_interface/` [Readme.md](None): Instructions on how to create additional custom interfaces using this pre-made ROS package.