ROS2_pubsub/src/pubsub/pubsub
Christopher Herr 3d0fb1ef73 revert ed2f2c95c7
revert ROS actionlib start
2023-01-18 16:12:06 +01:00
..
__pycache__ modified: src/custom_interfaces/CMakeLists.txt 2023-01-18 15:42:46 +01:00
Readme.md Update 'src/pubsub/pubsub/Readme.md' 2021-04-23 15:41:30 +02:00
__init__.py first test push 2021-01-13 15:28:01 +01:00
pubsub_library.py first test push 2021-01-13 15:28:01 +01:00
pubsub_library_v2.py pubsub_v2 2021-03-09 22:12:06 +01:00
pubsub_library_v3.py revert ed2f2c95c7 2023-01-18 16:12:06 +01:00
service_client.py Correction topic & services 2021-04-29 16:04:31 +02:00
service_host.py service call example created 2021-04-21 01:46:37 +02:00
statemachine_client_example.py service call example created 2021-04-21 01:46:37 +02:00
statemachine_host_example.py new readme created 2021-04-21 11:14:15 +02:00
topic_listener.py Correction topic & services 2021-04-29 16:04:31 +02:00
topic_talker.py Correction topic & services 2021-04-29 16:04:31 +02:00

Readme.md

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 <entry_point_name>. The <entry_point_name> 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*
  • pubsub_library_v3 : Library containing
    • MinimalPublisher class
    • MinimalSubscriber class
    • MinimalServiceProvider class
    • MinimalServiceClient class

How to use

In the following the various classes named above are referred to as Minimal<X> with <X> standing for topic publisher/subscriber or service host/client.

You can use the Minimal<X> classes in three ways:

  • Create Minimal<X> in your script (eg. topic_listener.py): Here data is echanged between the script environment and the class environment.
    Upsides: You can implement as many instances of Minimal<X> as you like
    Downsides: Code get's complicated and confusing
  • Implement Minimal<X> inside your device class the same way as implementing in your main script (<-- ToDo !!!)
    Upsides: You can implement as many instances of Minimal<X> as you like; You can wrap these instances inside you device class
    Downsides: ToDo
  • Build device class upon Minimal<X> by using this structure
class Child_Class(Parent_Class):

For example:

class StateMachineCMDServiceProvider(MinimalServiceProvider):

(Example: statemachine_host_example.py: device class is built upon MinimalServiceProvider class.)
Upsides: Minimal<X> is automatically instantiated when creating an instance of your device class due to __init()__
Downsides: You can only implement one instance of Minimal<X>, eg. one device class can only implement one publisher. If you need more than one instance you want to implement Minimal<X> inside your device class (see above)