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
Publisher & Subscriber package as template package and source code.
Publisher & Subscriber template package and source code.
Created for ROS Workshop 2020
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)
* 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. 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
@ -45,6 +45,5 @@ __Note:__ Only the files inside _src/_ are of importance.
* `ros2 pkg create --build-type [ament_cmake, ament-python] <package_name>`
* Go back up one layer: `cd ..`
* 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
* [Instruction](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md) on how to create a custom message to interface between nodes
* 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
* 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.
__Table of Content__
* [CMake Package (eg. /pubsub_msg)](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#cmake-package-eg-pubsub_msg)
* [Create CMake Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#1-create-cmake-package)
* [Create Message Files](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#2-create-message-files)
* [Configure CMakeLists.txt](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#3-configure-cmakeliststxt)
* [Configure package.xml](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#4-configure-packagexml)
* [Build Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#5-build-package)
* [Source newly built workspace](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#6-source-newly-built-workspace)
* [Check functionality](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#7-check-functionality)
* [Python Package (eg. /pubsub)](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#python-package-eg-pubsub)
* [Create Python Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#1-create-python-package)
* [Write Python Scripts](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#2-write-python-scripts)
* [Configure package.xml](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#3-configure-packagexml)
* [Build Package](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#4-build-package)
* [Source newly built workspace](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#5-source-newly-built-workspace)
* [Run scripts](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#6-run-scripts)
* [Sources](https://github.com/patrickw135/pubsub/blob/master/instructions_custom_topics.md#sources)
* [CMake Package (eg. /pubsub_msg)]()
* [Create CMake Package]()
* [Create Message Files]()
* [Configure CMakeLists.txt]()
* [Configure package.xml]()
* [Build Package]()
* [Source newly built workspace]()
* [Check functionality]()
* [Python Package (eg. /pubsub)]()
* [Create Python Package]()
* [Write Python Scripts]()
* [Configure package.xml]()
* [Build Package]()
* [Source newly built workspace]()
* [Run scripts]()
* [Sources]()
@ -50,7 +50,7 @@ This will result in an empty package structure:
### 1. Create CMake Package
* Move to your colcon workspace's src directory: `cd <workspace_path>/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`)
@ -125,19 +125,19 @@ publishing #1: pubsub_msg.msg.CustomMsg2(pitch_ctrl=33.33, yaw_ctrl=0.5)..._
## 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 can be created as a CMake (C++) package or as a python package depending on your coding preference.
* C++: `ros2 pkg create --build-type ament-cmake <package_name>`
* Python: `ros2 pkg create --build-type ament-python <package_name>`
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>`
* Python: `ros2 pkg create --build-type ament_python <package_name>`
<package_name> directory:
* 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
* 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
When using custom interfaces in python scripts these must be imported into the python script first