Rock

the Robot Construction Kit

... in oroGen

To make life easier while using the stream aligner, an oroGen plug-in was created. Using this plugin, the laser filter that we outlined in the previous pages would be declared with:

task_context "Task" do
  input_port "lidar_samples", "/base/samples/LaserScan"
  input_port "transformation", "/base/samples/RigidBodyState"
  output_port "filtered_samples", "/base/samples/LaserScan"

  stream_aligner do
    max_latency 0.5
    align_port "lidar_samples", 0
    align_port "transformation", 0
  end

  port_driven
end

The usage of this plugin requires the drivers/orogen/aggregator package. The project’s manifest.xml must therefore contain:

<depend package="drivers/orogen/aggregator" />

The following statements are available in the task context definition:

stream_aligner
The stream_aligner statement will add a instance of the stream aligner to the task base class. If needed, this instance of aggregator::StreamAligner (from the drivers/aggregator package) can be accessed from the C++ code as the _stream_aligner attribute.
max_latency(timeout_in_seconds)
The max_latency statement sets the timeout of the stream aligner. It can be overriden through a generated aggregator_max_latency property on the task.
align_port(name, period)
Registers a stream on the task’s stream aligner, and pushes all the data that arrives on the specified port to this stream. The provided period is the default period for the stream. It can be overriden at runtime by setting a generated property called “port_name”_period (e.g. lidar_samples_period for the lidar_samples stream)

In the C++ task, for each stream declared with align_port, a C++ callback method, of the form “void stream_nameCallback(timestamp, sample)” is generated.

void lidar_samplesCallback(base::Time const& timestamp,
    base::samples::LaserScan const& sample)
{
  // process the sample
}

As usual with oroGen, if you add or remove streams after the first code generation, you must update the files in tasks/ yourself, using if needed the templates generated in templates/tasks/

Your task implementation MUST call TaskBase::configureHook() and TaskBase::updateHook() if you reimplement the hooks. The hook code generated by default by oroGen does this already.

The next page will now deal on the usage, at runtime, of a component that is using the stream aligner as well as its online and offline monitoring.