YARP
Yet Another Robot Platform
yarp::dev::ServerGrabber Class Reference

#include <ServerGrabber/ServerGrabber.h>

+ Inheritance diagram for yarp::dev::ServerGrabber:

Detailed Description

Description of input parameters

A Network grabber for camera devices. In base of the configuration this device can handle one or two cameras.
In case of two cameras, the RGB or RAW streaming will be produced on two separated ports or on a single port with the two images stitched horizontally.
Moreover it has two rpc ports that have the same name of the streaming ports + "/rpc" suffix.
The inheritance from yarp::dev::IWrapper and yarp::dev::IMultipleWrapper allows to be instantiated also through yarprobotinterface. See their documentation for more details about each interface.

This device is paired with its client called RemoteFrameGrabber to receive the data streams and perform remote operations.

Parameters required by this device are:

Parameter name SubParameter Type Units Default Value Required Description Notes
period - int ms 30 No refresh period(in ms) of the broadcasted values through yarp ports default 30ms
name - string - /grabber No Prefix name of the ports opened by the ServerGrabber Required suffix like '/rpc' will be added by the device
capabilities - string - COLOR No two capabilities supported, COLOR and RAW respectively for rgb and raw streaming -
twoCameras - bool - - required only for instantiating this device with the yarprobotinterface if true ServerGrabber will open and handle two devices, if false only one =true it makes required left_config and right_config parameters, =false subdevice parameter becomes required
split - bool - false No set 'true' to split the streaming of the input camera/s on two different ports Useful in case of dual cameras, the image will be split vertically in the 2 output ports 'left' and 'right'
subdevice - string - - used for opening and handling a single device, alternative to 'attach' action name of the subdevice to use as a data source when used, parameters for the subdevice must be provided as well
left_config - string - - used for opening and handling two devices, required if right_config present and/or twoCameras set to true name of the ini file containing the configuration of one of two subdevices to use as a data source when used, parameters for the subdevice must be provided in the file specified. This parameter is not admitted if the device is configured for working with one device.
right_config - string - - used for opening and handling two devices, required if left_config present and/or twoCameras set to true name of the ini file containing the configuration of one of two subdevices to use as a data source when used, parameters for the subdevice must be provided in the file specified. This parameter is not admitted if the device is configured for working with one device.
context - string - - No name of context where the yarp::os::ResourceFinder will search the ini files specified in left_config and right_config -

Some example of configuration files:

Example of configuration file using .ini format, for handling two cameras.

device grabberDual
capabilities RAW
split false
period 30
twoCameras true
left_config left_config.ini #name of the config file containing the parameters for the camera device
right_config right_config.ini #name of the config file containing the parameters for the camera device

Example of configuration file using .ini format, for handling one camera.

device grabberDual
capabilities COLOR # not necessary to specify 'COLOR', this is the default value if capabilities is omitted
period 30
subdevice test_grabber

Example of configuration file using .xml format, for handling two cameras.

<device name="serverGrabber" type="grabberDual">
<param name="period"> 30 </param>
<param name="name"> /grabber </param>
<param name="capabilities"> RGB </param>
<param name="split"> false </param>
<param name="twoCameras"> true </param>
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
<elem name="LEFT"> testCamera_left </elem>
<elem name="RIGHT"> testCamera_right </elem>
</paramlist>
</action>
<action phase="shutdown" level="5" type="detach" />
</device>

Example of configuration file using .xml format, for handling one camera.

<device name="serverGrabber" type="grabberDual">
<param name="period"> 30 </param>
<param name="name"> /grabber </param>
<param name="capabilities"> RGB </param>
<param name="split"> false </param>
<param name="twoCameras"> true </param>
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
<elem name="subdevice"> usbCamera_left_single </elem>
</paramlist>
</action>
<action phase="shutdown" level="5" type="detach" />
</device>

Definition at line 180 of file ServerGrabber.h.

Public Member Functions

 ServerGrabber ()
 Constructor. More...
 
 ~ServerGrabber ()
 
bool close () override
 Close the DeviceDriver. More...
 
bool open (yarp::os::Searchable &config) override
 Configure with a set of options. More...
 
bool respond (const yarp::os::Bottle &command, yarp::os::Bottle &reply, bool left, bool both)
 
bool attachAll (const PolyDriverList &device2attach) override
 Attach to a list of objects. More...
 
bool detachAll () override
 Detach the object (you must have first called attach). More...
 
bool attach (PolyDriver *poly) override
 Attach to another object. More...
 
bool detach () override
 Detach the object (you must have first called attach). More...
 
bool threadInit () override
 Initialization method. More...
 
void threadRelease () override
 Release method. More...
 
void run () override
 Loop function. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
virtual ~DeviceDriver ()
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 
- Public Member Functions inherited from yarp::dev::IWrapper
virtual ~IWrapper ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::dev::IMultipleWrapper
virtual ~IMultipleWrapper ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::os::PeriodicThread
 PeriodicThread (double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No)
 Constructor. More...
 
virtual ~PeriodicThread ()
 
bool start ()
 Call this to start the thread. More...
 
void step ()
 Call this to "step" the thread rather than starting it. More...
 
void stop ()
 Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() called). More...
 
void askToStop ()
 Stop the thread. More...
 
bool isRunning () const
 Returns true when the thread is started, false otherwise. More...
 
bool isSuspended () const
 Returns true when the thread is suspended, false otherwise. More...
 
bool setPeriod (double period)
 Set the (new) period of the thread. More...
 
double getPeriod () const
 Return the current period of the thread. More...
 
void suspend ()
 Suspend the thread, the thread keeps running by doLoop is never executed. More...
 
void resume ()
 Resume the thread if previously suspended. More...
 
void resetStat ()
 Reset thread statistics. More...
 
double getEstimatedPeriod () const
 Return estimated period since last reset. More...
 
void getEstimatedPeriod (double &av, double &std) const
 Return estimated period since last reset. More...
 
unsigned int getIterations () const
 Return the number of iterations performed since last reset. More...
 
double getEstimatedUsed () const
 Return the estimated duration of the run() function since last reset. More...
 
void getEstimatedUsed (double &av, double &std) const
 Return estimated duration of the run() function since last reset. More...
 
int setPriority (int priority, int policy=-1)
 Set the priority and scheduling policy of the thread, if the OS supports that. More...
 
int getPriority () const
 Query the current priority of the thread, if the OS supports that. More...
 
int getPolicy () const
 Query the current scheduling policy of the thread, if the OS supports that. More...
 

Protected Member Functions

bool fromConfig (yarp::os::Searchable &config)
 
bool initialize_YARP (yarp::os::Searchable &params)
 
void stopThread ()
 
void setupFlexImage (const yarp::sig::Image &img, yarp::sig::FlexImage &flex_i)
 
void shallowCopyImages (const yarp::sig::FlexImage &src, yarp::sig::FlexImage &dest)
 
void cleanUp ()
 
- Protected Member Functions inherited from yarp::os::PeriodicThread
virtual void beforeStart ()
 Called just before a new thread starts. More...
 
virtual void afterStart (bool success)
 Called just after a new thread starts (or fails to start), this is executed by the same thread that calls start(). More...
 

Constructor & Destructor Documentation

◆ ServerGrabber()

ServerGrabber::ServerGrabber ( )

Constructor.

Definition at line 197 of file ServerGrabber.cpp.

◆ ~ServerGrabber()

ServerGrabber::~ServerGrabber ( )

Definition at line 235 of file ServerGrabber.cpp.

Member Function Documentation

◆ attach()

bool ServerGrabber::attach ( PolyDriver poly)
overridevirtual

Attach to another object.

Parameters
polythe polydriver that you want to attach to.
Returns
true/false on success failure.

Implements yarp::dev::IWrapper.

Definition at line 982 of file ServerGrabber.cpp.

◆ attachAll()

bool ServerGrabber::attachAll ( const PolyDriverList p)
overridevirtual

Attach to a list of objects.

Parameters
pthe polydriver list that you want to attach to.
Returns
true/false on success failure.

Implements yarp::dev::IMultipleWrapper.

Definition at line 778 of file ServerGrabber.cpp.

◆ cleanUp()

void ServerGrabber::cleanUp ( )
protected

Definition at line 1366 of file ServerGrabber.cpp.

◆ close()

bool ServerGrabber::close ( void  )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 241 of file ServerGrabber.cpp.

◆ detach()

bool ServerGrabber::detach ( )
overridevirtual

Detach the object (you must have first called attach).

Returns
true/false on success failure.

Implements yarp::dev::IWrapper.

Definition at line 1003 of file ServerGrabber.cpp.

◆ detachAll()

bool ServerGrabber::detachAll ( )
overridevirtual

Detach the object (you must have first called attach).

Returns
true/false on success failure.

Implements yarp::dev::IMultipleWrapper.

Definition at line 948 of file ServerGrabber.cpp.

◆ fromConfig()

bool ServerGrabber::fromConfig ( yarp::os::Searchable config)
protected

Definition at line 364 of file ServerGrabber.cpp.

◆ initialize_YARP()

bool ServerGrabber::initialize_YARP ( yarp::os::Searchable params)
protected

Definition at line 465 of file ServerGrabber.cpp.

◆ open()

bool ServerGrabber::open ( yarp::os::Searchable config)
overridevirtual

Configure with a set of options.

Parameters
configThe options to use
Returns
true iff the object could be configured.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 299 of file ServerGrabber.cpp.

◆ respond()

bool ServerGrabber::respond ( const yarp::os::Bottle command,
yarp::os::Bottle reply,
bool  left,
bool  both = false 
)

Definition at line 511 of file ServerGrabber.cpp.

◆ run()

void ServerGrabber::run ( )
overridevirtual

Loop function.

This is the thread itself. The thread calls the run() function every <period> ms. At the end of each run, the thread will sleep the amounth of time required, taking into account the time spent inside the loop function. Example: requested period is 10ms, the run() function take 3ms to be executed, the thread will sleep for 7ms.

Note: after each run is completed, the thread will call a yield() in order to facilitate other threads to run.

Implements yarp::os::PeriodicThread.

Definition at line 1172 of file ServerGrabber.cpp.

◆ setupFlexImage()

void ServerGrabber::setupFlexImage ( const yarp::sig::Image img,
yarp::sig::FlexImage flex_i 
)
protected

Definition at line 974 of file ServerGrabber.cpp.

◆ shallowCopyImages()

void ServerGrabber::shallowCopyImages ( const yarp::sig::FlexImage src,
yarp::sig::FlexImage dest 
)
protected

Definition at line 1360 of file ServerGrabber.cpp.

◆ stopThread()

void ServerGrabber::stopThread ( )
protected

Definition at line 957 of file ServerGrabber.cpp.

◆ threadInit()

bool ServerGrabber::threadInit ( )
overridevirtual

Initialization method.

The thread executes this function when it starts and before "run". This is a good place to perform initialization tasks that need to be done by the thread itself (device drivers initialization, memory allocation etc). If the function returns false the thread quits and never calls "run". The return value of threadInit() is notified to the class and passed as a parameter to afterStart(). Note that afterStart() is called by the same thread that is executing the "start" method.

Reimplemented from yarp::os::PeriodicThread.

Definition at line 1111 of file ServerGrabber.cpp.

◆ threadRelease()

void ServerGrabber::threadRelease ( )
overridevirtual

Release method.

The thread executes this function once when it exits, after the last "run". This is a good place to release resources that were initialized in threadInit() (release memory, and device driver resources).

Reimplemented from yarp::os::PeriodicThread.

Definition at line 1166 of file ServerGrabber.cpp.


The documentation for this class was generated from the following files: