YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Devices

In YARP, a Device is a software abstraction of a hardware or logical component, which provides a standardized interface to access specific functionalities within the middleware. More...

+ Collaboration diagram for Devices:

Modules

 Device Creation/Configuration
 Basic classes and methods related to creating and configuring devices, and network communication to and from devices.
 
 Device Implementations
 Concrete device drivers that implement sets of interfaces.
 
 Tutorials and Examples about Devices
 Tutorials and Examples about Devices.
 

Detailed Description

In YARP, a Device is a software abstraction of a hardware or logical component, which provides a standardized interface to access specific functionalities within the middleware.

Devices can abstract everything: motor controllers, sensors, cameras, simulated components and even algorithms.

A device ideally should use the minimal set of interfaces needed to implement a particular task.

In Yarp, devices are implemented as plugins , meaning that they are not a stand-alone executables: they require an external wrapper to be executed. More in particular, they can be started from the commandline, via yarprobotinterface or from a programming language (c++, python, etc.).

Running a Device via command line

Devices that can be created and configured from the command-line tool yarpdev by specifying a --device option followed by their name, for example:

yarpdev --device fakeFrameGrabber

This creates a fakeFrameGrabber device with default options. Additional configuration options can be added as optional parameters:

yarpdev --device fakeFrameGrabber --width 640 --height 480

The special parameter "--help" will show all the available parameters for that specific device.

You can check the documentation of that device (list of all devices Device Implementations here). Or When you try to run "yarpdev --device yourdevice" and add the "--help" flag, it will tell you what options it is checking, and any documentation present for those options.

yarpdev --device fakeFrameGrabber --help

You can also write the parameters in a .ini file a load it from command line. For example, you create a grabber_test.ini file with the following text:

device frameGrabber_nws_yarp
subdevice fakeFrameGrabber
name /test
width 640
height 480

and launch the device with:

yarpdev --file grabber_test.ini

Running a Device via Yarprobotinterface

The commandline executable yarprobotinterface provides a more advanced way to open one or more devices simultaneously (or in a specific order), and to attach them each other so that they can exchange data. Additional information is provided in yarprobotinterface documentation page.

Running a Device via programming language

A user application can easily open a device in c++ by instantiating a yarp::dev::PolyDriver object and passing to it the required parameters via a yarp::os::Property.

p.fromConfigFile("grabber_test.ini");
// of course you could construct the Property object on-the-fly
dev.open(p);
if (!dev.isValid()) {return;}
yarp::dev::IGrabberInterface* igrab= nullptr;
dev.view(igrab);
//do something with igrab interface...
dev.close();
bool view(T *&x)
Get an interface to the device driver.
A container for a device driver.
Definition PolyDriver.h:23
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A class for storing options and configuration information.
Definition Property.h:33
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.

Other programming languages (e.g. python) are available through yarp bindings.

driver = yarp.PolyDriver()
options = yarp.Property()
options.put("robot", "icub")
options.put("device", "remote_controlboard")
options.put("remote", "/icub/left_arm")
driver.open(options)
if not driver.isValid():
print('Cannot open the driver!')
sys.exit()
ienc = driver.viewIEncoders()
//do something with ienc interface...
driver.close()