From 7d0e7f178655ed1448e92c40ffc4b6aae362ca1c Mon Sep 17 00:00:00 2001 From: winterhalderp Date: Wed, 21 Apr 2021 11:14:15 +0200 Subject: [PATCH] new readme created --- README.md | 4 +++ src/pubsub/pubsub/Readme.md | 33 +++++++++++++++++++ .../pubsub/statemachine_host_example.py | 6 ++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/pubsub/pubsub/Readme.md diff --git a/README.md b/README.md index fed618c..c755df4 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,7 @@ In order for your code to work and to prevent major problems please read through ## Presentation 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). + +## 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. diff --git a/src/pubsub/pubsub/Readme.md b/src/pubsub/pubsub/Readme.md new file mode 100644 index 0000000..480073c --- /dev/null +++ b/src/pubsub/pubsub/Readme.md @@ -0,0 +1,33 @@ +# Readme /pubsub +This directory represents a ROS package due to its internal structure and files. The files inside `pubsub/pubsub/` are the Python scripts written by the package developer and can be called using the command line `ros2 run pubsub `. The `` has to be defined in _setup.py_. + +## Files +This section describes the content and purpose of the files inside this directory. +`ros2 run` callable files: +* *topic\_talker.py* : Example for creating a `MinimumPublisher` and sending topics +* *topic\_listener.py* : Example for creating a `MinimumSubscriber` and receiving topics +* *service\_host.py* : Example for creataing a `MinimumServiceProvider` and hosting a service +* *service\_client.py* : Example for creating a `MinimumServiceClient` and calling a service +* *statemachine\_host\_example.py* : Example application of State Machine (SM) hosting a service to call for a change of state +* *statemachine\_client\_example.py* : Example application of a service client calling for the change of SM state + +Library files: +* \[*pubsub\_library* ; *pubsub\_library\_v2*\] : old versions +* *pubsub\_library\_v3* : Library containing + * `MinimalPublisher` class + * `MinimalSubscriber` class + * `MinimalServiceProvider` class + * `MinimalServiceClient` class + +## How to use +You can use the `Minimal` classes in three ways: +* Create `Minimal` in your script (eg. [topic_listener.py](None) where data is echanged between the script environment and the class environment) +* Implement `Minimal` inside your device class the same way as implementing in your main script (__<-- ToDo !!!__) +* Build device class upon `Minimal` class (eg. [statemachine_host_example.py](None) where a device class is built upon the `MinimalServiceProvider` class) by implementing this structure +```python +class Child_Class(Parent_Class): +``` +For example: +```python +class StateMachineCMDServiceProvider(MinimalServiceProvider): +``` diff --git a/src/pubsub/pubsub/statemachine_host_example.py b/src/pubsub/pubsub/statemachine_host_example.py index 6808e29..9e6779f 100644 --- a/src/pubsub/pubsub/statemachine_host_example.py +++ b/src/pubsub/pubsub/statemachine_host_example.py @@ -1,14 +1,14 @@ import rclpy from rclpy.node import Node -import pubsub.pubsub_library_v3 as lib +from pubsub.pubsub_library_v3 import MinimalServiceProvider # Service Type Files from custom_interfaces.srv import StateMachineSrv - -class StateMachineCMDServiceProvider(lib.MinimalServiceProvider): +# Device Class +class StateMachineCMDServiceProvider(MinimalServiceProvider): def __init__(self, NODE_NAME, SRV_NAME, SRV_TYPE): self.NODE_NAME = NODE_NAME self.SRV_NAME = SRV_NAME