From 69ff2bd1bcfc31506cc3f767f6969cf8a8319561 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 24 Jan 2023 10:47:16 +0800 Subject: [PATCH 01/10] :heavy_plus_sign: :blue_book: Added slightly elaborated README.md under composition ROS2 package. Signed-off-by: Bey Hao Yun --- composition/README.md | 91 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 composition/README.md diff --git a/composition/README.md b/composition/README.md new file mode 100644 index 000000000..5d88710c1 --- /dev/null +++ b/composition/README.md @@ -0,0 +1,91 @@ +## **What Is This?** + +This demo ... + +This ROS 2 package consists of the following nodes: + +1. `dlopen_composition` +2. `linktime_composition` +3. `manual_composition` + +## **Build** + +Run the commands below to build the ROS 2 package: + +```bash +colcon build --packages-up-to composition +``` + +## **Run** + +### Manual Composition + +```bash +ros2 run +``` + +### DlOpen Composition + + +```bash + +``` + +### Linktime Composition + + +```bash + +``` + + +## **Verify** + +### Manual Composition + +When executed correctly, strings should be printed to terminal similar to what is shown below: + +```bash +[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1' +[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1] +[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2' +[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2] +[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3] +[INFO] [1674528189.032815843] [Client]: Got result: [5] +[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3' +[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3] +[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4' +[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4] +[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3] +[INFO] [1674528191.032604427] [Client]: Got result: [5] +[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5' +[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5] +[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6' +[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6] +[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3] +[INFO] [1674528193.032603036] [Client]: Got result: [5] +``` + +### DlOpen Composition + +When executed correctly, strings should be printed to terminal similar to what is shown below: + +```bash + +``` + +### Linktime Composition + +```bash + +``` + +## **FAQ** + +WIP + +## **References** + +1. [Composing multiple nodes in a single process](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) +2. [About Composition](https://docs.ros.org/en/rolling/Concepts/About-Composition.html#about-composition) +3. []() From 4b26bcf785948252636a647919848201d5ad2af1 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 24 Jan 2023 11:00:15 +0800 Subject: [PATCH 02/10] :hammer: Elaborated further Run and Verify instructions. Yet to include proper explainations for Run sub-sections. Signed-off-by: Bey Hao Yun --- composition/README.md | 47 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/composition/README.md b/composition/README.md index 5d88710c1..fd4947e2c 100644 --- a/composition/README.md +++ b/composition/README.md @@ -21,21 +21,22 @@ colcon build --packages-up-to composition ### Manual Composition ```bash -ros2 run +ros2 run composition manual_composition ``` ### DlOpen Composition ```bash - +ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so ``` ### Linktime Composition +This runs `linktime_composition` ROS 2 node which ... ```bash - +ros2 run composition linktime_composition ``` @@ -64,6 +65,7 @@ When executed correctly, strings should be printed to terminal similar to what i [INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6] [INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3] [INFO] [1674528193.032603036] [Client]: Got result: [5] +#... ``` ### DlOpen Composition @@ -71,13 +73,48 @@ When executed correctly, strings should be printed to terminal similar to what i When executed correctly, strings should be printed to terminal similar to what is shown below: ```bash - +INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling/lib/libtalker_component.so +[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/rolling/lib/liblistener_component.so +[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1' +[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1] +[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2' +[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2] +[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3' +[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3] +[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4' +[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4] +[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5' +[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5] +#... ``` ### Linktime Composition -```bash +When executed correctly, strings should be printed to terminal similar to what is shown below: +```bash +[INFO] [1674528568.091949637] [linktime_composition]: Load library +[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate +[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1' +[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1] +[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3] +[INFO] [1674528570.099376432] [Client]: Got result: [5] +[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2' +[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2] +[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3' +[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3] +[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3] +[INFO] [1674528572.099628903] [Client]: Got result: [5] +[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4' +[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4] +[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5' +[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5] +#... ``` ## **FAQ** From 4ecfc0f3f970c3f17fb45ac297d7ab2f5013161e Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 24 Jan 2023 11:12:34 +0800 Subject: [PATCH 03/10] :hammer: Elaborated further Manual Composition section. Signed-off-by: Bey Hao Yun --- composition/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/composition/README.md b/composition/README.md index fd4947e2c..d31ce71bf 100644 --- a/composition/README.md +++ b/composition/README.md @@ -20,6 +20,13 @@ colcon build --packages-up-to composition ### Manual Composition +Running `manual_composition` compiles an executable that runs the following 4 components: + +- **Talker** (A ROS 2 component which publishes a string) +- **Listener** (A ROS 2 component that prints the received string from **Talker**) +- **Server** (A ROS 2 component that adds two integers and outputs its result to **Client**) +- **Client** (A ROS 2 component that sends two integers to **Server** and prints the received result from **Server**). + ```bash ros2 run composition manual_composition ``` @@ -68,6 +75,9 @@ When executed correctly, strings should be printed to terminal similar to what i #... ``` +:warning: +> Note that manually-composed components **will not be reflected in the `ros2 component list`** command line tool output. + ### DlOpen Composition When executed correctly, strings should be printed to terminal similar to what is shown below: From 5935cff220fd348cb37259e0cf2c8af607ce3d20 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 24 Jan 2023 11:26:19 +0800 Subject: [PATCH 04/10] :hammer: Elaborated fully README.md in composition ROS2 package. Signed-off-by: Bey Hao Yun --- composition/README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/composition/README.md b/composition/README.md index d31ce71bf..d2c17c13a 100644 --- a/composition/README.md +++ b/composition/README.md @@ -33,6 +33,9 @@ ros2 run composition manual_composition ### DlOpen Composition +This runs `dlopen_composition` which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces. + +The process will open each library and create one instance of each “rclcpp::Node” class in the library. ```bash ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so @@ -40,12 +43,19 @@ ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtal ### Linktime Composition -This runs `linktime_composition` ROS 2 node which ... +Similar to previous, this runs `linktime_composition` which **links all classes from libraries** that are registered under the **library_path** with the **linker**. ```bash ros2 run composition linktime_composition ``` +### Composition Using Launch Actions + +Rather than using the command line tool to run each composition, we can **automate this action** with `ros2 launch` functionality: + +```bash +ros2 launch composition composition_demo.launch.py +``` ## **Verify** @@ -100,6 +110,10 @@ INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling #... ``` +:warning: +> Note that dlopen-composed components **will not be reflected in the `ros2 component list`** command line tool output. + + ### Linktime Composition When executed correctly, strings should be printed to terminal similar to what is shown below: @@ -127,6 +141,10 @@ When executed correctly, strings should be printed to terminal similar to what i #... ``` +:warning: +> Note that linktime-composed components **will not be reflected in the `ros2 component list`** command line tool output. + + ## **FAQ** WIP @@ -135,4 +153,3 @@ WIP 1. [Composing multiple nodes in a single process](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) 2. [About Composition](https://docs.ros.org/en/rolling/Concepts/About-Composition.html#about-composition) -3. []() From 1be30cdc3cc1c162cdd3bcf0d7c85a8f19696a54 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 24 Jan 2023 16:17:19 +0800 Subject: [PATCH 05/10] :hammer: Updated README.md further. Signed-off-by: Bey Hao Yun --- composition/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composition/README.md b/composition/README.md index d2c17c13a..0a853e43e 100644 --- a/composition/README.md +++ b/composition/README.md @@ -1,6 +1,6 @@ ## **What Is This?** -This demo ... +This demo provides examples on 3 different ways which users could use the **rclcpp_components** API to compose multiple nodes in a single process. This ROS 2 package consists of the following nodes: @@ -147,9 +147,12 @@ When executed correctly, strings should be printed to terminal similar to what i ## **FAQ** -WIP +`Q`: Why use Composition? + +`A`: Composition provides utilties to manage life cycle for nodes. This provides greater control over the state of a given ROS-based system. The idea of a managed node is to provide a interactable interface which executes to a known life cycle state machine, allowing for higher system transparency and code-agnosticism. ## **References** 1. [Composing multiple nodes in a single process](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) 2. [About Composition](https://docs.ros.org/en/rolling/Concepts/About-Composition.html#about-composition) +3. [Node Life Cycle](https://design.ros2.org/articles/node_lifecycle.html) From 5d402bfe5087bde9e55ca3a0804ca02863847405 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Fri, 27 Jan 2023 13:32:39 +0800 Subject: [PATCH 06/10] :hammer: :fire: Updated based on feedback. Removed link to Reference Life Cycle Node. Signed-off-by: Bey Hao Yun --- composition/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composition/README.md b/composition/README.md index 0a853e43e..3216fccf6 100644 --- a/composition/README.md +++ b/composition/README.md @@ -147,12 +147,11 @@ When executed correctly, strings should be printed to terminal similar to what i ## **FAQ** -`Q`: Why use Composition? +`Q`: Why use node composition? -`A`: Composition provides utilties to manage life cycle for nodes. This provides greater control over the state of a given ROS-based system. The idea of a managed node is to provide a interactable interface which executes to a known life cycle state machine, allowing for higher system transparency and code-agnosticism. +`A`: Node composition avoids the overhead of marshaling and unmarshaling messages by allowing nodes to be instantiated within the same process. ## **References** 1. [Composing multiple nodes in a single process](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) 2. [About Composition](https://docs.ros.org/en/rolling/Concepts/About-Composition.html#about-composition) -3. [Node Life Cycle](https://design.ros2.org/articles/node_lifecycle.html) From 625e07aa5f56dc125944bc230d948ba57a3593c1 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Fri, 27 Jan 2023 13:34:20 +0800 Subject: [PATCH 07/10] :hammer: Updated to fix minor typo. Signed-off-by: Bey Hao Yun --- composition/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composition/README.md b/composition/README.md index 3216fccf6..bba5edbb2 100644 --- a/composition/README.md +++ b/composition/README.md @@ -149,7 +149,7 @@ When executed correctly, strings should be printed to terminal similar to what i `Q`: Why use node composition? -`A`: Node composition avoids the overhead of marshaling and unmarshaling messages by allowing nodes to be instantiated within the same process. +`A`: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process. ## **References** From a7bd105b7eca9c7ce503b4bc9a1bfc7a32038d33 Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Wed, 1 Feb 2023 09:20:08 +0800 Subject: [PATCH 08/10] :hammer: Updated based on feedback to improve phrasing and formating. Signed-off-by: Bey Hao Yun --- composition/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composition/README.md b/composition/README.md index bba5edbb2..dfabbe502 100644 --- a/composition/README.md +++ b/composition/README.md @@ -1,6 +1,6 @@ ## **What Is This?** -This demo provides examples on 3 different ways which users could use the **rclcpp_components** API to compose multiple nodes in a single process. +This demo provides examples of three different ways to use the **rclcpp_components** API to compose multiple nodes in a single process. This ROS 2 package consists of the following nodes: @@ -22,10 +22,10 @@ colcon build --packages-up-to composition Running `manual_composition` compiles an executable that runs the following 4 components: -- **Talker** (A ROS 2 component which publishes a string) -- **Listener** (A ROS 2 component that prints the received string from **Talker**) -- **Server** (A ROS 2 component that adds two integers and outputs its result to **Client**) -- **Client** (A ROS 2 component that sends two integers to **Server** and prints the received result from **Server**). +- **Talker**: A ROS 2 component that publishes a string +- **Listener**: A ROS 2 component that prints the received string from **Talker** +- **Server**: A ROS 2 component that adds two integers and outputs its result to **Client** +- **Client**: A ROS 2 component that sends two integers to **Server** and prints the received result from **Server** ```bash ros2 run composition manual_composition From 157486d408d6a1efaa5ce0abe156b053addbd29e Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Wed, 1 Feb 2023 09:21:58 +0800 Subject: [PATCH 09/10] :hammer: Removed bold from all headers. Signed-off-by: Bey Hao Yun --- composition/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composition/README.md b/composition/README.md index dfabbe502..67f0f6638 100644 --- a/composition/README.md +++ b/composition/README.md @@ -1,4 +1,4 @@ -## **What Is This?** +## What Is This? This demo provides examples of three different ways to use the **rclcpp_components** API to compose multiple nodes in a single process. @@ -8,7 +8,7 @@ This ROS 2 package consists of the following nodes: 2. `linktime_composition` 3. `manual_composition` -## **Build** +## Build Run the commands below to build the ROS 2 package: @@ -16,7 +16,7 @@ Run the commands below to build the ROS 2 package: colcon build --packages-up-to composition ``` -## **Run** +## Run ### Manual Composition @@ -57,7 +57,7 @@ Rather than using the command line tool to run each composition, we can **automa ros2 launch composition composition_demo.launch.py ``` -## **Verify** +## Verify ### Manual Composition @@ -145,13 +145,13 @@ When executed correctly, strings should be printed to terminal similar to what i > Note that linktime-composed components **will not be reflected in the `ros2 component list`** command line tool output. -## **FAQ** +## FAQ `Q`: Why use node composition? `A`: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process. -## **References** +## References 1. [Composing multiple nodes in a single process](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) 2. [About Composition](https://docs.ros.org/en/rolling/Concepts/About-Composition.html#about-composition) From 4e0c9802b4d2bb4d55ab327c25faa38d6b79c56c Mon Sep 17 00:00:00 2001 From: Bey Hao Yun Date: Tue, 7 Feb 2023 08:33:42 +0800 Subject: [PATCH 10/10] :hammer: Updated based on feedback to correct phrasing. Signed-off-by: Bey Hao Yun --- composition/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composition/README.md b/composition/README.md index 67f0f6638..07a28fe0d 100644 --- a/composition/README.md +++ b/composition/README.md @@ -2,7 +2,7 @@ This demo provides examples of three different ways to use the **rclcpp_components** API to compose multiple nodes in a single process. -This ROS 2 package consists of the following nodes: +This ROS 2 package consists of the following demo applications: 1. `dlopen_composition` 2. `linktime_composition`