YARP  2.3.70.1
Yet Another Robot Platform
yarp::dev::ServerInertial Class Reference

#include <ServerInertial/ServerInertial.h>

+ Inheritance diagram for yarp::dev::ServerInertial:

Public Member Functions

 ServerInertial ()
 Constructor. More...
 
virtual ~ServerInertial ()
 
virtual bool open (yarp::os::Searchable &config) override
 Open the device driver. More...
 
virtual bool close () override
 Close the DeviceDriver. More...
 
virtual bool getInertial (yarp::os::Bottle &bot)
 
virtual void run () override
 Main body of the new thread. More...
 
virtual bool read (yarp::os::ConnectionReader &connection) override
 Read this object from a network connection. More...
 
virtual bool read (yarp::sig::Vector &out) override
 Read a vector from the sensor. More...
 
virtual bool getChannels (int *nc) override
 Get the number of channels of the sensor. More...
 
virtual bool calibrate (int ch, double v) override
 Calibrate the sensor, single channel. More...
 
virtual bool attach (PolyDriver *poly) override
 IWrapper interface Attach to another object. More...
 
virtual bool detach () override
 Detach the object (you must have first called attach). More...
 
virtual bool attachAll (const PolyDriverList &p) override
 IMultipleWrapper interface Attach to a list of objects. More...
 
virtual bool detachAll () override
 Detach the object (you must have first called attach). 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::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType ()
 
- Public Member Functions inherited from yarp::dev::IGenericSensor
virtual ~IGenericSensor ()
 

Private Member Functions

bool openDeferredAttach (yarp::os::Property &prop)
 
bool openAndAttachSubDevice (yarp::os::Property &prop)
 
- Private Member Functions inherited from yarp::os::Thread
 Thread ()
 Constructor. More...
 
virtual ~Thread ()
 Destructor. More...
 
virtual void onStop ()
 Call-back, called while halting the thread (before join). More...
 
bool start ()
 Start the new thread running. More...
 
bool stop ()
 Stop the thread. More...
 
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...
 
virtual bool threadInit ()
 Initialization method. More...
 
virtual void threadRelease ()
 Release method. More...
 
bool isStopping ()
 Returns true if the thread is stopping (Thread::stop has been called). More...
 
bool isRunning ()
 Returns true if the thread is running (Thread::start has been called successfully and the thread has not stopped). More...
 
void setOptions (int stackSize=0)
 Set the stack size for the new thread. More...
 
long int getKey ()
 Get a unique identifier for the thread. 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 ()
 Query the current priority of the thread, if the OS supports that. More...
 
int getPolicy ()
 Query the current scheduling policy of the thread, if the OS supports that. More...
 
bool join (double seconds=-1)
 The function returns when the thread execution has completed. More...
 

Private Attributes

bool ownDevices
 
yarp::dev::PolyDriversubDeviceOwned
 

Additional Inherited Members

- Static Private Member Functions inherited from yarp::os::Thread
static int getCount ()
 Check how many threads are running. More...
 
static long int getKeyOfCaller ()
 Get a unique identifier for the calling thread. More...
 
static void setDefaultStackSize (int stackSize)
 Set the default stack size for all threads created after this point. More...
 
static void yield ()
 Reschedule the execution of current thread, allowing other threads to run. More...
 

Detailed Description

Description of input parameters

Export an inertial sensor. The network interface is a single Port. We will stream bottles with 12 floats:

0 1 2 = Euler orientation data (X, Y, Z) global frame representation.
3 4 5 = Calibrated 3-axis (X, Y, Z) acceleration data
6 7 8 = Calibrated 3-axis (X, Y, Z) gyroscope data
9 10 11 = Calibrated 3-axis (X, Y, Z) magnetometer data
Author
Alexis Maldonado, Radu Bogdan Rusu, Alberto Cardellino

It reads the data from an Inertial measurement unit sensor and sends them through yarp port.

Parameters accepted in the config argument of the open method:

Parameter name Type Units Default Value Required Description Notes
name string - - Yes full name of the port opened by the device, like /robotName/deviceId/sensorType:o must start with a '/' character
period double s 0.005 No refresh period of the broadcasted values in ms (optional, default 5ms) -
subdevice string - - alternative to attach actionname of the yarp IMU device driver to be instantiated if using yarprobotinterface or custom program the 'attach' action can be used instead
ROS group - - No Group containing parameter for ROS topic initialization if missing, it is assumed to not use ROS topics
useROS string true/false/only- if ROS group is present set 'true' to have both yarp ports and ROS topic, set 'only' to have only ROS topic and no yarp port-
ROS_TopicName string - - if ROS group is present set the name for ROS topic must start with a leading '/'
ROS_nodeName string - - if ROS group is present set the name for ROS node must start with a leading '/'
ROS_msgType string enum - if ROS group is present choose the message to be sent through ROS topic supported value now is ONLY geometry_msgs/WrenchedStamped
frame_id string - - if ROS group is present name of reference frame the measures are referred to -

ROS message type used is sensor_msgs/Imu.msg (http://docs.ros.org/api/sensor_msgs/html/msg/Imu.html)

Some example of configuration files:

Configuration file using .ini format

name /inertial
period 0.02
[ROS]
useROS true
ROS_topicName /ROSinertial
ROS_nodeName /IMUPublisher
frame_id r_shoulder

Configuration file using .xml format.

<param name="name"> /inertial </param>
<param name="period"> 0.02 </param>
<group name="ROS">
<param name="useROS"> true </param> // use 'only' if you want only ROS topic and NOT yarp ports
<param name="ROS_topicName"> /ROSinertial </param>
<param name="ROS_nodeName"> /IMUPublisher </param>
<param name="frame_id"> r_shoulder </param>
</group>
<!-- Following parameters are meaningful ONLY for yarprobotinterface -->
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
<!-- The param value must match the device name in the corresponding device configuration file -->
<elem name="imu_device"> left_upper_arm_mc </elem>
</paramlist>
</action>
<action phase="shutdown" level="5" type="detach" />

ROS message type used is sensor_msgs/Imu.msg

Definition at line 116 of file ServerInertial.h.

Constructor & Destructor Documentation

◆ ServerInertial()

yarp::dev::ServerInertial::ServerInertial ( )

Constructor.

Definition at line 36 of file ServerInertial.cpp.

◆ ~ServerInertial()

yarp::dev::ServerInertial::~ServerInertial ( )
virtual

Definition at line 79 of file ServerInertial.cpp.

Member Function Documentation

◆ attach()

bool yarp::dev::ServerInertial::attach ( PolyDriver poly)
overridevirtual

IWrapper interface 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 515 of file ServerInertial.cpp.

◆ attachAll()

bool yarp::dev::ServerInertial::attachAll ( const PolyDriverList p)
overridevirtual

IMultipleWrapper interface 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 546 of file ServerInertial.cpp.

◆ calibrate()

bool yarp::dev::ServerInertial::calibrate ( int  ch,
double  v 
)
overridevirtual

Calibrate the sensor, single channel.

Parameters
chchannel number
vreset valure
Returns
true/false success/failure

Implements yarp::dev::IGenericSensor.

Definition at line 508 of file ServerInertial.cpp.

◆ close()

bool yarp::dev::ServerInertial::close ( void  )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 340 of file ServerInertial.cpp.

◆ detach()

bool yarp::dev::ServerInertial::detach ( )
overridevirtual

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

Returns
true/false on success failure.

Implements yarp::dev::IWrapper.

Definition at line 541 of file ServerInertial.cpp.

◆ detachAll()

bool yarp::dev::ServerInertial::detachAll ( )
overridevirtual

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

Returns
true/false on success failure.

Implements yarp::dev::IMultipleWrapper.

Definition at line 557 of file ServerInertial.cpp.

◆ getChannels()

bool yarp::dev::ServerInertial::getChannels ( int *  nc)
overridevirtual

Get the number of channels of the sensor.

Parameters
ncpointer to storage, return value
Returns
true/false success/failure

Implements yarp::dev::IGenericSensor.

Definition at line 502 of file ServerInertial.cpp.

◆ getInertial()

bool yarp::dev::ServerInertial::getInertial ( yarp::os::Bottle bot)
virtual

Definition at line 360 of file ServerInertial.cpp.

◆ open()

bool yarp::dev::ServerInertial::open ( yarp::os::Searchable config)
overridevirtual

Open the device driver.

Configure with a set of options.

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

These are:

subdevice Common name of device to wrap (e.g. "test_grabber").
name Port name to assign to this server (default /grabber).
Parameters
configThe options to use
Returns
true iff the object could be configured.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 272 of file ServerInertial.cpp.

◆ openAndAttachSubDevice()

bool yarp::dev::ServerInertial::openAndAttachSubDevice ( yarp::os::Property prop)
private

Definition at line 224 of file ServerInertial.cpp.

◆ openDeferredAttach()

bool yarp::dev::ServerInertial::openDeferredAttach ( yarp::os::Property prop)
private

Definition at line 217 of file ServerInertial.cpp.

◆ read() [1/2]

bool yarp::dev::ServerInertial::read ( yarp::os::ConnectionReader reader)
overridevirtual

Read this object from a network connection.

Override this for your particular class.

Parameters
readeran interface to the network connection for reading
Returns
true iff the object is successfully read

Implements yarp::os::PortReader.

Definition at line 486 of file ServerInertial.cpp.

◆ read() [2/2]

bool yarp::dev::ServerInertial::read ( yarp::sig::Vector out)
overridevirtual

Read a vector from the sensor.

Parameters
outa vector containing the sensor's last readings.
Returns
true/false success/failure

Implements yarp::dev::IGenericSensor.

Definition at line 496 of file ServerInertial.cpp.

◆ run()

void yarp::dev::ServerInertial::run ( )
overridevirtual

Main body of the new thread.

Override this method to do what you want. After Thread::start is called, this method will start running in a separate thread. It is important that this method either keeps checking Thread::isStopping to see if it should stop, or you override the Thread::onStop method to interact with it in some way to shut the new thread down. There is no really reliable, portable way to stop a thread cleanly unless that thread cooperates.

wait 5 ms.

Implements yarp::os::Thread.

Definition at line 392 of file ServerInertial.cpp.

Member Data Documentation

◆ ownDevices

bool yarp::dev::ServerInertial::ownDevices
private

Definition at line 200 of file ServerInertial.h.

◆ subDeviceOwned

yarp::dev::PolyDriver* yarp::dev::ServerInertial::subDeviceOwned
private

Definition at line 201 of file ServerInertial.h.


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