iCub-main
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
yarp::dev::EsdMessageSniffer Class Reference

The EsdMessageSniffer device driver. More...

#include <EsdMessageSniffer.h>

+ Inheritance diagram for yarp::dev::EsdMessageSniffer:

Public Member Functions

 EsdMessageSniffer ()
 Constructor. More...
 
virtual ~EsdMessageSniffer ()
 Destructor. More...
 
virtual bool open (EsdMessageSnifferParameters &params)
 Open the device driver. More...
 
virtual bool open (yarp::os::Searchable &config)
 Open the device driver and start communication with the hardware. More...
 
virtual bool close (void)
 Close the device driver. More...
 
virtual bool getAxes (int *axis)
 Get the number of controlled axes. More...
 
virtual bool resetEncoderRaw (int j)
 
virtual bool resetEncodersRaw ()
 
virtual bool setEncoderRaw (int j, double val)
 
virtual bool setEncodersRaw (const double *vals)
 
virtual bool getEncoderSpeedRaw (int j, double *sp)
 
virtual bool getEncoderSpeedsRaw (double *spds)
 
virtual bool getEncoderAccelerationRaw (int j, double *spds)
 
virtual bool getEncoderAccelerationsRaw (double *accs)
 
virtual bool getEncoderRaw (int j, double *v)
 Read the value of an encoder. More...
 
virtual bool getEncodersRaw (double *encs)
 Read the position of all axes. More...
 
virtual bool getErrorRaw (int j, double *err)
 Get the current error for a joint. More...
 
virtual bool getErrorsRaw (double *errs)
 Get the error of all joints. More...
 
virtual bool getOutputRaw (int j, double *out)
 Get the output of the controller (e.g. More...
 
virtual bool getOutputsRaw (double *outs)
 Get the output of the controllers (e.g. More...
 
virtual bool setPidRaw (int j, const Pid &pid)
 
virtual bool setPidsRaw (const Pid *pids)
 
virtual bool setReferenceRaw (int j, double ref)
 
virtual bool setReferencesRaw (const double *refs)
 
virtual bool setErrorLimitRaw (int j, double limit)
 
virtual bool setErrorLimitsRaw (const double *limits)
 
virtual bool getPidRaw (int j, Pid *pid)
 
virtual bool getPidsRaw (Pid *pids)
 
virtual bool getReferenceRaw (int j, double *ref)
 
virtual bool getReferencesRaw (double *refs)
 
virtual bool getErrorLimitRaw (int j, double *limit)
 
virtual bool getErrorLimitsRaw (double *limits)
 
virtual bool resetPidRaw (int j)
 
virtual bool disablePidRaw (int j)
 
virtual bool enablePidRaw (int j)
 
virtual bool setOffsetRaw (int j, double v)
 
virtual bool getCurrentsRaw (double *vals)
 Read the electric current going to all motors. More...
 
virtual bool getCurrentRaw (int j, double *val)
 Read the electric current going to a given motor. More...
 
virtual bool getAmpStatusRaw (int *st)
 
virtual bool enableAmpRaw (int j)
 
virtual bool disableAmpRaw (int j)
 
virtual bool setMaxCurrentRaw (int j, double v)
 

Protected Types

enum  {
  MAX_SHORT = 32767 ,
  MIN_SHORT = -32768 ,
  MAX_INT = 0x7fffffff ,
  MIN_INT = 0x80000000
}
 
enum  { ESD_CAN_SKIP_ADDR = 0x80 }
 

Protected Member Functions

bool NOT_YET_IMPLEMENTED (const char *txt)
 
bool setBCastMessages (int i, int value)
 sets the broadcast policy for a given board (don't need to be called twice). More...
 
bool getBCastPositions (double *p)
 
bool getBCastPosition (int i, double *value)
 reads an array of double from the broadcast message position buffer. More...
 
bool getBCastPIDOutput (int i, double *value)
 
bool getBCastPIDOutputs (double *p)
 
bool getBCastCurrent (int i, double *value)
 
bool getBCastCurrents (double *p)
 
bool getBCastFaults (int *p)
 
bool getBCastPositionError (int i, double *value)
 
bool getBCastPositionErrors (double *cmd)
 
bool setDebugPrintFunction (void *cmd)
 
bool ENABLED (int axis)
 helper function to check whether the enabled flag is on or off. More...
 
virtual void run (void)
 
bool _writeWord16 (int msg, int axis, short s)
 helper functions More...
 
bool _writeWord16Ex (int msg, int axis, short s1, short s2)
 two shorts in a single Can message (both must belong to the same control card). More...
 
bool _readWord16 (int msg, int axis, short &value)
 
bool _readWord16Array (int msg, double *out)
 reads an array. More...
 
bool _readDWord (int msg, int axis, int &value)
 sends a message and gets a dword back. More...
 
bool _readDWordArray (int msg, double *out)
 reads an array of double words. More...
 
bool _writeDWord (int msg, int axis, int value)
 write a DWord More...
 
bool _writeNone (int msg, int axis)
 helper functions. More...
 
short S_16 (double x) const
 
int S_32 (double x) const
 

Protected Attributes

void * system_resources
 
std::mutex _mutex
 
std::mutex mtx_done
 
std::condition_variable cv_done
 
bool _writerequested
 
bool _noreply
 
int(* _p )(const char *fmt,...)
 pointer to the function printing the device debug information. More...
 

Detailed Description

The EsdMessageSniffer device driver.

Poll the CAN bus for incoming broadcast messages and make them available through appropriate interfaces.

Definition at line 77 of file EsdMessageSniffer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MAX_SHORT 
MIN_SHORT 
MAX_INT 
MIN_INT 

Definition at line 278 of file EsdMessageSniffer.h.

◆ anonymous enum

anonymous enum
protected
Enumerator
ESD_CAN_SKIP_ADDR 

Definition at line 279 of file EsdMessageSniffer.h.

Constructor & Destructor Documentation

◆ EsdMessageSniffer()

EsdMessageSniffer::EsdMessageSniffer ( void  )

Constructor.

Definition at line 411 of file EsdMessageSniffer.cpp.

◆ ~EsdMessageSniffer()

EsdMessageSniffer::~EsdMessageSniffer ( )
virtual

Destructor.

Definition at line 421 of file EsdMessageSniffer.cpp.

Member Function Documentation

◆ _readDWord()

bool EsdMessageSniffer::_readDWord ( int  msg,
int  axis,
int &  value 
)
protected

sends a message and gets a dword back.

Definition at line 1160 of file EsdMessageSniffer.cpp.

◆ _readDWordArray()

bool EsdMessageSniffer::_readDWordArray ( int  msg,
double *  out 
)
protected

reads an array of double words.

Definition at line 1195 of file EsdMessageSniffer.cpp.

◆ _readWord16()

bool EsdMessageSniffer::_readWord16 ( int  msg,
int  axis,
short &  value 
)
protected

reads back position info.

Definition at line 973 of file EsdMessageSniffer.cpp.

◆ _readWord16Array()

bool EsdMessageSniffer::_readWord16Array ( int  msg,
double *  out 
)
protected

reads an array.

Definition at line 1009 of file EsdMessageSniffer.cpp.

◆ _writeDWord()

bool EsdMessageSniffer::_writeDWord ( int  msg,
int  axis,
int  value 
)
protected

write a DWord

syncing.

Definition at line 1095 of file EsdMessageSniffer.cpp.

◆ _writeNone()

bool EsdMessageSniffer::_writeNone ( int  msg,
int  axis 
)
protected

helper functions.

sends a message without parameters

syncing.

Definition at line 946 of file EsdMessageSniffer.cpp.

◆ _writeWord16()

bool EsdMessageSniffer::_writeWord16 ( int  msg,
int  axis,
short  s 
)
protected

helper functions

to send a Word16.

prepare Can message.

syncing.

hopefully ok...

Definition at line 1064 of file EsdMessageSniffer.cpp.

◆ _writeWord16Ex()

bool EsdMessageSniffer::_writeWord16Ex ( int  msg,
int  axis,
short  s1,
short  s2 
)
protected

two shorts in a single Can message (both must belong to the same control card).

prepare Can message.

axis is even.

syncing.

hopefully ok...

Definition at line 1124 of file EsdMessageSniffer.cpp.

◆ close()

bool EsdMessageSniffer::close ( void  )
virtual

Close the device driver.

Returns
true/false on success/failure.

Definition at line 508 of file EsdMessageSniffer.cpp.

◆ disableAmpRaw()

virtual bool yarp::dev::EsdMessageSniffer::disableAmpRaw ( int  j)
inlinevirtual

Definition at line 226 of file EsdMessageSniffer.h.

◆ disablePidRaw()

virtual bool yarp::dev::EsdMessageSniffer::disablePidRaw ( int  j)
inlinevirtual

Definition at line 198 of file EsdMessageSniffer.h.

◆ enableAmpRaw()

virtual bool yarp::dev::EsdMessageSniffer::enableAmpRaw ( int  j)
inlinevirtual

Definition at line 225 of file EsdMessageSniffer.h.

◆ ENABLED()

bool EsdMessageSniffer::ENABLED ( int  axis)
inlineprotected

helper function to check whether the enabled flag is on or off.

control card commands.

Parameters
axisis the axis to check for.
Returns
true if the axis is enabled and processing of the message can in fact continue.

Definition at line 805 of file EsdMessageSniffer.cpp.

◆ enablePidRaw()

virtual bool yarp::dev::EsdMessageSniffer::enablePidRaw ( int  j)
inlinevirtual

Definition at line 199 of file EsdMessageSniffer.h.

◆ getAmpStatusRaw()

virtual bool yarp::dev::EsdMessageSniffer::getAmpStatusRaw ( int *  st)
inlinevirtual

Definition at line 223 of file EsdMessageSniffer.h.

◆ getAxes()

bool EsdMessageSniffer::getAxes ( int *  axis)
virtual

Get the number of controlled axes.

This command asks the number of controlled axes for the current physical interface.

Parameters
axispointer to storage, return value
Returns
true/false.

Definition at line 812 of file EsdMessageSniffer.cpp.

◆ getBCastCurrent()

bool EsdMessageSniffer::getBCastCurrent ( int  i,
double *  value 
)
protected

Definition at line 878 of file EsdMessageSniffer.cpp.

◆ getBCastCurrents()

bool EsdMessageSniffer::getBCastCurrents ( double *  p)
protected

Definition at line 888 of file EsdMessageSniffer.cpp.

◆ getBCastFaults()

bool EsdMessageSniffer::getBCastFaults ( int *  p)
protected

Definition at line 901 of file EsdMessageSniffer.cpp.

◆ getBCastPIDOutput()

bool EsdMessageSniffer::getBCastPIDOutput ( int  i,
double *  value 
)
protected

Definition at line 856 of file EsdMessageSniffer.cpp.

◆ getBCastPIDOutputs()

bool EsdMessageSniffer::getBCastPIDOutputs ( double *  p)
protected

Definition at line 866 of file EsdMessageSniffer.cpp.

◆ getBCastPosition()

bool EsdMessageSniffer::getBCastPosition ( int  i,
double *  value 
)
protected

reads an array of double from the broadcast message position buffer.

LATER: add a check of timing/error message.

Definition at line 834 of file EsdMessageSniffer.cpp.

◆ getBCastPositionError()

bool EsdMessageSniffer::getBCastPositionError ( int  i,
double *  value 
)
protected

Definition at line 914 of file EsdMessageSniffer.cpp.

◆ getBCastPositionErrors()

bool EsdMessageSniffer::getBCastPositionErrors ( double *  cmd)
protected

Definition at line 925 of file EsdMessageSniffer.cpp.

◆ getBCastPositions()

bool EsdMessageSniffer::getBCastPositions ( double *  p)
protected

Definition at line 844 of file EsdMessageSniffer.cpp.

◆ getCurrentRaw()

virtual bool yarp::dev::EsdMessageSniffer::getCurrentRaw ( int  j,
double *  val 
)
inlinevirtual

Read the electric current going to a given motor.

Parameters
jmotor number
valpointer to storage for the output value
Returns
probably true, might return false in bad times

Definition at line 215 of file EsdMessageSniffer.h.

◆ getCurrentsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getCurrentsRaw ( double *  vals)
inlinevirtual

Read the electric current going to all motors.

Parameters
valspointer to storage for the output values
Returns
hopefully true, false in bad luck.

Definition at line 207 of file EsdMessageSniffer.h.

◆ getEncoderAccelerationRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncoderAccelerationRaw ( int  j,
double *  spds 
)
inlinevirtual

Definition at line 143 of file EsdMessageSniffer.h.

◆ getEncoderAccelerationsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncoderAccelerationsRaw ( double *  accs)
inlinevirtual

Definition at line 144 of file EsdMessageSniffer.h.

◆ getEncoderRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncoderRaw ( int  j,
double *  v 
)
inlinevirtual

Read the value of an encoder.

Parameters
jencoder number
vpointer to storage for the return value
Returns
true/false, upon success/failure (you knew it, uh?)

Definition at line 152 of file EsdMessageSniffer.h.

◆ getEncoderSpeedRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncoderSpeedRaw ( int  j,
double *  sp 
)
inlinevirtual

Definition at line 141 of file EsdMessageSniffer.h.

◆ getEncoderSpeedsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncoderSpeedsRaw ( double *  spds)
inlinevirtual

Definition at line 142 of file EsdMessageSniffer.h.

◆ getEncodersRaw()

virtual bool yarp::dev::EsdMessageSniffer::getEncodersRaw ( double *  encs)
inlinevirtual

Read the position of all axes.

Parameters
encspointer to the array that will contain the output
Returns
true/false on success/failure

Definition at line 159 of file EsdMessageSniffer.h.

◆ getErrorLimitRaw()

virtual bool yarp::dev::EsdMessageSniffer::getErrorLimitRaw ( int  j,
double *  limit 
)
inlinevirtual

Definition at line 195 of file EsdMessageSniffer.h.

◆ getErrorLimitsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getErrorLimitsRaw ( double *  limits)
inlinevirtual

Definition at line 196 of file EsdMessageSniffer.h.

◆ getErrorRaw()

virtual bool yarp::dev::EsdMessageSniffer::getErrorRaw ( int  j,
double *  err 
)
inlinevirtual

Get the current error for a joint.

Parameters
jjoint number
errpointer to the storage for the return value
Returns
true/false on success failure

Definition at line 166 of file EsdMessageSniffer.h.

◆ getErrorsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getErrorsRaw ( double *  errs)
inlinevirtual

Get the error of all joints.

Parameters
errspointer to the vector that will store the errors

Definition at line 171 of file EsdMessageSniffer.h.

◆ getOutputRaw()

virtual bool yarp::dev::EsdMessageSniffer::getOutputRaw ( int  j,
double *  out 
)
inlinevirtual

Get the output of the controller (e.g.

pwm value)

Parameters
jjoint number
outpointer to storage for return value
Returns
success/failure

Definition at line 178 of file EsdMessageSniffer.h.

◆ getOutputsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getOutputsRaw ( double *  outs)
inlinevirtual

Get the output of the controllers (e.g.

pwm value)

Parameters
outspinter to the vector that will store the output values

Definition at line 183 of file EsdMessageSniffer.h.

◆ getPidRaw()

virtual bool yarp::dev::EsdMessageSniffer::getPidRaw ( int  j,
Pid *  pid 
)
inlinevirtual

Definition at line 191 of file EsdMessageSniffer.h.

◆ getPidsRaw()

virtual bool yarp::dev::EsdMessageSniffer::getPidsRaw ( Pid *  pids)
inlinevirtual

Definition at line 192 of file EsdMessageSniffer.h.

◆ getReferenceRaw()

virtual bool yarp::dev::EsdMessageSniffer::getReferenceRaw ( int  j,
double *  ref 
)
inlinevirtual

Definition at line 193 of file EsdMessageSniffer.h.

◆ getReferencesRaw()

virtual bool yarp::dev::EsdMessageSniffer::getReferencesRaw ( double *  refs)
inlinevirtual

Definition at line 194 of file EsdMessageSniffer.h.

◆ NOT_YET_IMPLEMENTED()

bool yarp::dev::EsdMessageSniffer::NOT_YET_IMPLEMENTED ( const char *  txt)
inlineprotected

Definition at line 92 of file EsdMessageSniffer.h.

◆ open() [1/2]

bool EsdMessageSniffer::open ( EsdMessageSnifferParameters params)
virtual

Open the device driver.

Parameters
paramsis the parameter structure which is expected to be of type EsdMessageSnifferParameters.
Returns
true/false on success/failure.

Definition at line 478 of file EsdMessageSniffer.cpp.

◆ open() [2/2]

bool EsdMessageSniffer::open ( yarp::os::Searchable &  config)
virtual

Open the device driver and start communication with the hardware.

Parameters
configis a Searchable object containing the list of parameters.
Returns
true on success/failure.

Definition at line 428 of file EsdMessageSniffer.cpp.

◆ resetEncoderRaw()

virtual bool yarp::dev::EsdMessageSniffer::resetEncoderRaw ( int  j)
inlinevirtual

Definition at line 137 of file EsdMessageSniffer.h.

◆ resetEncodersRaw()

virtual bool yarp::dev::EsdMessageSniffer::resetEncodersRaw ( )
inlinevirtual

Definition at line 138 of file EsdMessageSniffer.h.

◆ resetPidRaw()

virtual bool yarp::dev::EsdMessageSniffer::resetPidRaw ( int  j)
inlinevirtual

Definition at line 197 of file EsdMessageSniffer.h.

◆ run()

void EsdMessageSniffer::run ( void  )
protectedvirtual

init part.

ok, init completed.

this requires a reply.

class 0 msg.

legitimate message directed here, checks whether replies to any message.

the pending msg doesn't require a reply.

timeout

complains.

tell the caller it can continue.

any write?

wait.

Definition at line 522 of file EsdMessageSniffer.cpp.

◆ S_16()

short yarp::dev::EsdMessageSniffer::S_16 ( double  x) const
inlineprotected

Definition at line 281 of file EsdMessageSniffer.h.

◆ S_32()

int yarp::dev::EsdMessageSniffer::S_32 ( double  x) const
inlineprotected

Definition at line 292 of file EsdMessageSniffer.h.

◆ setBCastMessages()

bool EsdMessageSniffer::setBCastMessages ( int  i,
int  value 
)
protected

sets the broadcast policy for a given board (don't need to be called twice).

the parameter is a 32-bit integer: bit X = 1 -> message X = active e.g. 0x02 activates the broadcast of position information 0x04 activates the broadcast of velocity ...

Definition at line 824 of file EsdMessageSniffer.cpp.

◆ setDebugPrintFunction()

bool EsdMessageSniffer::setDebugPrintFunction ( void *  cmd)
protected

Definition at line 792 of file EsdMessageSniffer.cpp.

◆ setEncoderRaw()

virtual bool yarp::dev::EsdMessageSniffer::setEncoderRaw ( int  j,
double  val 
)
inlinevirtual

Definition at line 139 of file EsdMessageSniffer.h.

◆ setEncodersRaw()

virtual bool yarp::dev::EsdMessageSniffer::setEncodersRaw ( const double *  vals)
inlinevirtual

Definition at line 140 of file EsdMessageSniffer.h.

◆ setErrorLimitRaw()

virtual bool yarp::dev::EsdMessageSniffer::setErrorLimitRaw ( int  j,
double  limit 
)
inlinevirtual

Definition at line 189 of file EsdMessageSniffer.h.

◆ setErrorLimitsRaw()

virtual bool yarp::dev::EsdMessageSniffer::setErrorLimitsRaw ( const double *  limits)
inlinevirtual

Definition at line 190 of file EsdMessageSniffer.h.

◆ setMaxCurrentRaw()

virtual bool yarp::dev::EsdMessageSniffer::setMaxCurrentRaw ( int  j,
double  v 
)
inlinevirtual

Definition at line 227 of file EsdMessageSniffer.h.

◆ setOffsetRaw()

virtual bool yarp::dev::EsdMessageSniffer::setOffsetRaw ( int  j,
double  v 
)
inlinevirtual

Definition at line 200 of file EsdMessageSniffer.h.

◆ setPidRaw()

virtual bool yarp::dev::EsdMessageSniffer::setPidRaw ( int  j,
const Pid &  pid 
)
inlinevirtual

Definition at line 185 of file EsdMessageSniffer.h.

◆ setPidsRaw()

virtual bool yarp::dev::EsdMessageSniffer::setPidsRaw ( const Pid *  pids)
inlinevirtual

Definition at line 186 of file EsdMessageSniffer.h.

◆ setReferenceRaw()

virtual bool yarp::dev::EsdMessageSniffer::setReferenceRaw ( int  j,
double  ref 
)
inlinevirtual

Definition at line 187 of file EsdMessageSniffer.h.

◆ setReferencesRaw()

virtual bool yarp::dev::EsdMessageSniffer::setReferencesRaw ( const double *  refs)
inlinevirtual

Definition at line 188 of file EsdMessageSniffer.h.

Member Data Documentation

◆ _mutex

std::mutex yarp::dev::EsdMessageSniffer::_mutex
protected

Definition at line 246 of file EsdMessageSniffer.h.

◆ _noreply

bool yarp::dev::EsdMessageSniffer::_noreply
protected

Definition at line 251 of file EsdMessageSniffer.h.

◆ _p

int(* yarp::dev::EsdMessageSniffer::_p) (const char *fmt,...)
protected

pointer to the function printing the device debug information.

Definition at line 264 of file EsdMessageSniffer.h.

◆ _writerequested

bool yarp::dev::EsdMessageSniffer::_writerequested
protected

Definition at line 250 of file EsdMessageSniffer.h.

◆ cv_done

std::condition_variable yarp::dev::EsdMessageSniffer::cv_done
protected

Definition at line 248 of file EsdMessageSniffer.h.

◆ mtx_done

std::mutex yarp::dev::EsdMessageSniffer::mtx_done
protected

Definition at line 247 of file EsdMessageSniffer.h.

◆ system_resources

void* yarp::dev::EsdMessageSniffer::system_resources
protected

Definition at line 245 of file EsdMessageSniffer.h.


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