iodrivers_base
README

Generic oroGen integration for drivers based on iodrivers_base

Usage

Your component must depend on the drivers/orogen/iodrivers_base package, and the driver component must subclass iodrivers_base::Task:

In the package's manifest.xml, add

<depend name="drivers/orogen/iodrivers_base" />

At the top of the oroGen file, add:

using_task_library "iodrivers_base"

Then, make your task a subclass of the iodrivers_base::Task task context:

task_context "Task", subclasses: "iodrivers_base::Task" do
end

There is two things left to do:

setDriver(driver)

For instance, one could have a setup looking like:

bool Task::configureHook()
{
// Un-configure the device driver if the configure fails.
// You MUST call guard.commit() once the driver is fully
// functional (usually before the configureHook's "return true;"
iodrivers_base::ConfigureGuard guard(this);
Driver* driver = new Driver();
if (!_io_port.get().empty())
driver->openURI(_io_port.get());
setDriver(driver);
// This is MANDATORY and MUST be called after the setDriver but before you do
// anything with the driver
if (!TaskBase::configureHook())
return false;
// If some device configuration was needed, it must be done after the
// setDriver and call to configureHook on TaskBase (i.e., here)
guard.commit();
return true;
}
void Task::processIO()
{
mDriver->processSamples();
_samples.write(mDriver->getOrientationSample());
}

In addition, you might want to start data acquisition in the startHook and stop it in the stopHook. Whether the acquisition start/stop should be in startHook/stopHook or configureHook/cleanupHook is governed by the following factor:

By default, the standard runtime management of oroGen tasks entails that you will have a full stop/cleanup/configure/start cycle if reconfiguration is needed. You should therefore not care about dynamic reconfiguration in first implementations.

Details about the iodrivers_base::Task interface

This interface provides two means of communication between the device and the driver.

Other properties control the behaviour of the system in both modes (read timeout) and write statistics about the I/O. Some properties are specific to one mode, in which case this is documented in the property documentation directly.