Skip to content

Tutorial 5: Using the Component Manager

RValner edited this page Apr 13, 2023 · 5 revisions

Note: All examples shown in this tutorial can be found and replicated via Temoto Tutorials repository.


Component Manager is designed to maintain information about components and pipes. Components are resources that encompass ROS based programs (nodes/launch files) which provide sensing or data processing functionalities. The description of each component (including published/subscribed topics, package names) is outlined in the components.yaml file.

Example of usb camera

Components:
- component_name: "Any camera on video_device"
  component_type: "2d_camera"
  package_name: "tutorials_temoto_config"
  executable:  "usb_cam_remappable.launch"
  output_topics:
    camera_data: "usb_cam/image_raw"
    camera_data_compressed: "usb_cam/image_raw/compressed"
    camera_info: "usb_cam/camera_info"
  required_parameters:
    frame_id: "camera_link"
    video_device: "/dev/video0"

Demo 1

Access a component resource using a regular ROS node and the Component Manager Interface. For this demo you need a usb camera and the usb_cam node installed. if you dont have it, run the following command to install it

sudo apt install ros-noetic-usb-cam
roslaunch tutorials_temoto_config temoto.launch temoto_namespace:=my_temoto
rosrun tutorials_temoto_config component_manager_client __ns:=my_temoto

The component_manager_client is a node with a CMI object that can communicate with the Component Manager subsystem, thus it is able to access resources. In this example we load a usb camera for 30 seconds and then unload the resource.

Once the node is running, you should be able to see the topics related to the usb cam among there are:

  • /my_temoto/usb_cam/camera_info
  • /my_temoto/usb_cam/image_raw
  • /my_temoto/usb_cam/image_raw/compressed

Or you can visualize it using rqt:

rqt

Open the Plugins/Visualization/image view tab and select the /my_temoto/usb_cam/image_raw topic.

Task: Replicate the same demo using a TeMoto Action. You should be able to load a resource (usb_cam) using the component manager interface. Launch TeMoto and trigger the TeMoto action you just created.

Component Pipes - tutorial

About Component Pipes

Pipe management is the second main feature of the Component Manager. Pipes are composed of segments, i.e., components, that sequentially pass data from one segment to another. For example Figure 2. depicts a pipe which tracks objects based on filtered video data.

The pipes are described via pipes.yaml which has the following structure:

  • pipe_category_A
    • pipe_method_0
      • segment_0_1
      • segment_0_2
      • segment_0_3
    • pipe_method_1
      • segment_1_1
      • segment_1_2
    • ...
  • pipe_category_B
    • ...

where

  • pipe category indicates the generic purpose of the pipes outlined under it
  • method allows to define different alternatives for achieving the same pipe functionality
  • segment describes what kind of component should be used for a particular pipe method

Each segment outlines the structure of a component but without mentioning any specific topic names, just the component type and topic types:

  • segment_type: "component_type"
    • input_topic_types:
      • topic_type_0
      • topic_type_1
    • output_topic_types:
      • topic_type_2
      • topic_type_3

Here is an example of an AR tag tracking pipe

ar_tag_tracking:
- method:

  - segment_type: "2d_camera"
    required_parameters:
      - frame_id
    output_topic_types:
      - camera_info
      - camera_data

  - segment_type: "ar_tag_tracker"
    required_parameters:
      - frame_id
    input_topic_types:
      - camera_info
      - camera_data
    output_topic_types:
      - visualization_data
      - tag_data

Run an example

This repo contains an example setup for demonstrating components. In this demonstration, three components will be combined into a pipe where each component is subscribing and publishing std_msgs::string messages. The output of the final component within the pipe is a sentence, which reads "The pipe is working like it is supposed to" and "The data is flowing properly". The point is that each component has added only a part of the sentence, thus demonstrating that the pipe is truly working like a pipeline.

The components.yaml contains three component descriptions named "String spammer 0", "String spammer 1" and "String spammer 2". The source code can be found here. Now the pipes.yaml outlines how these components should be combined. Note that only component and topic types are used and no specific names are mentioned. This allows to dynamically resolve to any alternative if necessary.

Try the thing out by first:

roslaunch tutorials_temoto_config temoto.launch temoto_namespace:=my_temoto

and then:

roslaunch ta_component_pipe_test invoke_action.launch wake_word:=my_temoto

This action is programmed to run for 20 seconds and then it shuts down. While it runs check the rosnode list and rostopic list to see how pipes are assembled via ROS topics.

Clone this wiki locally