Note: This tutorial assumes that you have completed the previous tutorials: Getting started.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Pattern creation

Description: This tutorial covers the creation of transforms and patterns of transforms for the pattern_manager to manage.

Tutorial Level: BEGINNER

Next Tutorial: Iterating patterns

This tutorial covers the creation of transforms and patterns of transforms.

Creating transforms

To create a transform call the service /create_transform with the desired parameters:

$ rosservice call /pattern_manager/create_transform "params:
  parent_id: 140718458909632 
  name: 'grp1'
  translation:
    x: 0.0
    y: 0.0
    z: 0.0
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 0.0" 

The data for the newly created transform looks like this:

$ rosservice call /pattern_manager/get_transform_info "id: 140718458909984"
params: 
  name: "grp1"
  parent_id: 140718458909632
  ref_frame: "root"
  id: 140718458909984
  active: False
  translation: 
    x: 0.0
    y: 0.0
    z: 0.0
  rotation: 
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
  number: 1

Notice that by default a newly created transform will have its parent transforms name as its reference frame. This can be altered with the previously demonstrated /set_reference_frame service. Now that we have created a transform, we can use it to hold different patterns, like a pattern container transform (or "pattern group"). Next, we will add some patterns under our newly created grp1 transform.

Creating patterns

Creating patterns is nearly as simple as creating a transform, although more paramters are required. Each pattern type has its own service:

/pattern_manager/create_circular_pattern
/pattern_manager/create_linear_pattern
/pattern_manager/create_rectangular_pattern
/pattern_manager/create_scatter_pattern

We will now add a linear pattern to grp1:

$ rosservice call /pattern_manager/create_linear_pattern "parent:
  parent_id: 140718458909984
  name: 'lin1'
  translation:
    x: 0.0
    y: 0.0
    z: 0.0
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 0.0
num_points: 4
step_size: 1.0
length: 3.0"

To check that the pattern was correctly generated under the correct transform we use the service: /get_children_info supplied with the ID of grp1 as parent_id:

$ rosservice call /pattern_manager/get_children_info "parent_id: 140718458909984"
transforms:
  -
    name: "lin1"
    parent_id: 140718458909984
    ref_frame: "grp1"
    id: 140718458910248
    active: False
    translation:
      x: 0.0
      y: 0.0
      z: 0.0
    rotation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
    number: 1
  -
    name: "lin1_0"
    parent_id: 140718458910248
    ref_frame: "lin1"
    id: 140718458910336
    active: False
    translation:
      x: 0.0
      y: 0.0
      z: 0.0
    rotation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
    number: 2
  -
    ...

This service retrives all immediate children of the transform which owns the parent_id value. As listed we can see that a transform consists of a parent transform, lin1, and a number of child transforms (lin1_0, lin1_1 etc.), which make up the pattern. All child transforms reference the pattern parent in their reference frame attribute. Note that the /print_tree service can also be used to print out the current structure of the tree in the node shell output.

Now that you know how to create transforms and patterns it is time to cover the aspect of iterating through the transform tree.

Wiki: pattern_manager/Tutorials/Pattern creation (last edited 2020-01-20 11:00:36 by Mads)