YARP
Yet Another Robot Platform

inertial: Export an inertial sensor. More...

#include <ServerInertial/ServerInertial.h>

+ Inheritance diagram for ServerInertial:

Public Member Functions

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

Detailed Description

inertial: 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

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

Description of input parameters

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 action name 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 108 of file ServerInertial.h.

Constructor & Destructor Documentation

◆ ServerInertial() [1/3]

ServerInertial::ServerInertial ( )

Constructor.

Definition at line 35 of file ServerInertial.cpp.

◆ ServerInertial() [2/3]

ServerInertial::ServerInertial ( const ServerInertial )
delete

◆ ServerInertial() [3/3]

ServerInertial::ServerInertial ( ServerInertial &&  )
delete

◆ ~ServerInertial()

ServerInertial::~ServerInertial ( )
override

Definition at line 81 of file ServerInertial.cpp.

Member Function Documentation

◆ attach()

bool ServerInertial::attach ( yarp::dev::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 517 of file ServerInertial.cpp.

◆ attachAll()

bool ServerInertial::attachAll ( const yarp::dev::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 548 of file ServerInertial.cpp.

◆ calibrate()

bool 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 510 of file ServerInertial.cpp.

◆ close()

bool ServerInertial::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 342 of file ServerInertial.cpp.

◆ detach()

bool 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 543 of file ServerInertial.cpp.

◆ detachAll()

bool 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 559 of file ServerInertial.cpp.

◆ getChannels()

bool 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 504 of file ServerInertial.cpp.

◆ getInertial()

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

Definition at line 362 of file ServerInertial.cpp.

◆ open()

bool 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. "fakeFrameGrabber").
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 274 of file ServerInertial.cpp.

◆ operator=() [1/2]

ServerInertial& ServerInertial::operator= ( const ServerInertial )
delete

◆ operator=() [2/2]

ServerInertial& ServerInertial::operator= ( ServerInertial &&  )
delete

◆ read() [1/2]

bool 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 488 of file ServerInertial.cpp.

◆ read() [2/2]

bool 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 498 of file ServerInertial.cpp.

◆ run()

void 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 394 of file ServerInertial.cpp.


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