In YARP, a device driver is a class that implements one or more interfaces.
In YARP, a device driver is a class that implements one or more interfaces.
If you're interested in learning how to use device drivers, see Getting Started with YARP Devices, Device invocation examples, and yarpdev: the standard YARP device utility. If you're read all that before and are interested in learning how to create devices, then read on...
A device driver should derive from the abstract class yarp::dev::DeviceDriver
. This interface contains methods common to all device drivers, such as open and close.
Additionally a device driver should implement a selection of other interfaces that capture what it shares with other families of devices. For example a camera might implement yarp:dev:
:IFrameGrabber (a "raw" interface to the raw data) and/or yarp::dev::IFrameGrabberImage
(a higher-level source of images). For example, the yarp::dev::DragonflyDeviceDriver
class implements a few of these interfaces. Interfaces are abstract classes, the idea is that from outside the user can access a device by using a pointer to the interface he/she needs, if that interface is supported by the device. This is quite similar to the way COM works (in a simplified way).
In practice to implement a new device you create a new class which derives from DeviceDriver
and from the interfacees you want to support, and you implement them. The interfaces are documented in the code, using the doxygen standard. See Getting Started with YARP Devices for an example.
So you want to add a device to YARP?
$YARP_ROOT/src/devices
. This isn't actually a requirement, but it is the easiest way to start. Let us say you pick the directory foo. yarp::dev::DeviceDriver
. Let's suppose that class is called FooDriver
, and is defined in FooDriver.h
foo/CMakeLists.txt
file might look something like this: COMPILE_DEVICE_LIBRARY
variable. So please modify your CMakeLists.txt
so that if this variable is set, all it does is add your device library, and skips any testing you might do. CMakeLists.txt
SKIP_foo
variable will be set, so you can do: $YARP_ROOT/src/devices/CMakeLists
.txt and add in where all the similar lines are: $YARP_ROOT/src/devices/CMakeLists
.txt to some other directory, remove all the other add_subdirectory
lines and just leave your own)