This commit is contained in:
winterhalderp 2021-03-09 22:12:40 +01:00
commit da35fd10bd
2 changed files with 26 additions and 27 deletions

View File

@ -1,5 +1,5 @@
# pubsub - Publisher & Subscriber Package # pubsub - Publisher & Subscriber Package
Publisher & Subscriber package as template package and source code. Publisher & Subscriber template package and source code.
Created for ROS Workshop 2020 Created for ROS Workshop 2020
Roverentwicklung für Explorationsaufgaben Roverentwicklung für Explorationsaufgaben
@ -35,7 +35,7 @@ Created by Patrick Winterhalder,
* Clone repository: `git clone git://github.com/patrickw135/pubsub.git .` (include the . at the end) * Clone repository: `git clone git://github.com/patrickw135/pubsub.git .` (include the . at the end)
* Build workspace: `colcon build` * Build workspace: `colcon build`
__Note:__ Only the files inside _src/_ are of importance. __Note:__ Only the files inside _src/_ are of importance.
* Remember to run `source ~/<workspace_path>/install/local_setup.sh` after every build. Best would be to [add this command to _.bashrc_](https://github.com/patrickw135/pubsub/blob/master/bashrc_addons.txt) which is run everytime you start a new console. * Remember to run `source ~/<workspace_path>/install/local_setup.sh` after every build. Best would be to [add this command to _.bashrc_](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/bashrc_addons.bash) which is run everytime you start a new console.
## During Workshop ## During Workshop
@ -45,6 +45,5 @@ __Note:__ Only the files inside _src/_ are of importance.
* `ros2 pkg create --build-type [ament_cmake, ament-python] <package_name>` * `ros2 pkg create --build-type [ament_cmake, ament-python] <package_name>`
* Go back up one layer: `cd ..` * Go back up one layer: `cd ..`
* Build workspace: `colcon build --symlink-install` * Build workspace: `colcon build --symlink-install`
* Add [this](https://github.com/patrickw135/pubsub/blob/main/bashrc_addons.txt) to end of .bashrc (`sudo nano .bashrc`), find all instances of "`~/ws_overlay_foxy`" and replace it with your local path to your colcon workspace * Add [this](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/bashrc_addons.bash) to end of .bashrc (`sudo nano .bashrc`), find all instances of "`~/ws_overlay_foxy`" and replace it with your local path to your colcon workspace
* [Instruction](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md) on how to create a custom message to interface between nodes * Follow [these instructions](https://egit.irs.uni-stuttgart.de/RoverLehre/ROS2_pubsub/src/branch/master/instructions_custom_topics.md) to create a custom message to define the interface between nodes

View File

@ -8,22 +8,22 @@ For this at least two packages will be required:
The CMake package is required because the custom msg/srv/act files cannot be created inside the python package as this is not supported yet. The CMake package is required because the custom msg/srv/act files cannot be created inside the python package as this is not supported yet.
__Table of Content__ __Table of Content__
* [CMake Package (eg. /pubsub_msg)](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#cmake-package-eg-pubsub_msg) * [CMake Package (eg. /pubsub_msg)]()
* [Create CMake Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#1-create-cmake-package) * [Create CMake Package]()
* [Create Message Files](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#2-create-message-files) * [Create Message Files]()
* [Configure CMakeLists.txt](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#3-configure-cmakeliststxt) * [Configure CMakeLists.txt]()
* [Configure package.xml](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#4-configure-packagexml) * [Configure package.xml]()
* [Build Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#5-build-package) * [Build Package]()
* [Source newly built workspace](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#6-source-newly-built-workspace) * [Source newly built workspace]()
* [Check functionality](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#7-check-functionality) * [Check functionality]()
* [Python Package (eg. /pubsub)](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#python-package-eg-pubsub) * [Python Package (eg. /pubsub)]()
* [Create Python Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#1-create-python-package) * [Create Python Package]()
* [Write Python Scripts](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#2-write-python-scripts) * [Write Python Scripts]()
* [Configure package.xml](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#3-configure-packagexml) * [Configure package.xml]()
* [Build Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#4-build-package) * [Build Package]()
* [Source newly built workspace](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#5-source-newly-built-workspace) * [Source newly built workspace]()
* [Run scripts](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#6-run-scripts) * [Run scripts]()
* [Sources](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#sources) * [Sources]()
@ -50,7 +50,7 @@ This will result in an empty package structure:
### 1. Create CMake Package ### 1. Create CMake Package
* Move to your colcon workspace's src directory: `cd <workspace_path>/src` * Move to your colcon workspace's src directory: `cd <workspace_path>/src`
* (For example: `cd ~/colcon_ws/src`) * (For example: `cd ~/colcon_ws/src`)
* Create CMake package: `ros2 pkg create --build-type ament_cmake <package_name> * Create CMake package: `ros2 pkg create --build-type ament_cmake <package_name>`
* (Here: `ros2 pkg create --build-type ament_cmake pubsub_msg`) * (Here: `ros2 pkg create --build-type ament_cmake pubsub_msg`)
@ -125,19 +125,19 @@ publishing #1: pubsub_msg.msg.CustomMsg2(pitch_ctrl=33.33, yaw_ctrl=0.5)..._
## Python Package (eg. /pubsub) ## Python Package (eg. /pubsub)
This package contains your scripts, programs and libraries. After building the workspace (`colcon build`) the custom messages are available to all other packages. This package contains your scripts, programs and libraries. After building the workspace (`colcon build`) the custom messages are available to all other packages.
This package can be created as a CMake (C++) package or as a python package depending on your coding preference. This package can be created as a CMake (C++) package or as a python package depending on your coding preference, e.g.
* C++: `ros2 pkg create --build-type ament-cmake <package_name>` * C++: `ros2 pkg create --build-type ament_cmake <package_name>`
* Python: `ros2 pkg create --build-type ament-python <package_name>` * Python: `ros2 pkg create --build-type ament_python <package_name>`
<package_name> directory: <package_name> directory:
* This directory contains your python scripts (eg. listener.py) * This directory contains your python scripts (eg. listener.py)
* Also place the non-standard libraries in this directory and import the library in your python scripts * Also place non-standard libraries in this directory and import them in your python scripts
### 1. Create Python Package ### 1. Create Python Package
* Move to your workspace's source directory: `cd <workspace_path>/src` * Move to your workspace's source directory: `cd <workspace_path>/src`
* Create python package: `rps2 pkg create --build-type ament_python <pkg_name>` * Create python package: `ros2 pkg create --build-type ament_python <pkg_name>`
### 2. Write Python Scripts ### 2. Write Python Scripts
When using custom interfaces in python scripts these must be imported into the python script first When using custom interfaces in python scripts these must be imported into the python script first