Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PIDMC Class Reference

A nice little MotionCommand for manually manipulating the PID values. More...

#include <PIDMC.h>

Inheritance diagram for PIDMC:

Detailed Description

A nice little MotionCommand for manually manipulating the PID values.

This will, by default, autoprune after its PID values have been set.

Although this doesn't handle directly sending PID commands to the system (the MotionManager::updatePIDs() does that) a little documentation on how Tekkotsu ad OPEN-R handle the PIDs might be nice.

In Tekkotsu, each of P,I, and D are a single floating point number. However, OPEN-R has, in essence, a limited precision floating point number. Each value is broken into a gain (mantissa) and shift (exponent). The shifts appear to be 4 bit values, and are inverted. In other words, x = g/(1<<(0x10-s)), or $ x = \frac{g}{2^{16-s}} $ The gain is probably 6-8 bits of resolution.

On the ERS-2xx series, each joint is completely independent. One caveat is that the shift value 0x0A gives a warning (AGRMSDriver::SetGain() : 0x0A IS USED FOR GAIN SHIFT VALUE.) for some unknown reason.

On the ERS-7, all the joints share the last set shift values, so a global set of shifts must be enforced. This of course, pretty much kills the whole point of having the shifts.

To understand the conversion from Tekkotsu format to the OPEN-R format, see MotionManager::updatePIDs().

A final note: the OPENR::SetJointGain function seems to be a rather costly function call. You should probably try to avoid setting PIDs at too high a frequency.

Definition at line 42 of file PIDMC.h.

List of all members.

Public Member Functions

 PIDMC ()
 Constructor, uses default PIDs and 0 weight for all.
 PIDMC (float powerlevel, float w=1)
 Constructor, sets general power level of all.
 PIDMC (unsigned int low, unsigned int high, float powerlevel, float w=1)
 Constructor, sets general power level of a range of joints, uses default and 0 weight for others, see setRangePowerLevel().
virtual ~PIDMC ()
 Destructor.
void setDefaults (float weight=1)
 Sets the PIDs to the defaults specified in RobotInfo.
void setJointPowerLevel (unsigned int i, float p, float w=1)
 Sets the PIDs to a percentage of default for a given joint, and sets weight.
void setAllPowerLevel (float p, float w=1)
 Sets the PIDs to a percentage of default for all joints.
void setRangePowerLevel (unsigned int low, unsigned int high, float p, float w=1)
 Sets a range of joints' PIDs to a given power level and weight.
void setPID (unsigned int i, const OutputPID &pid)
 Use this to set the PID value and weight.
OutputPIDgetPID (unsigned int i)
 Use this if you want to double check the PID you set.
const OutputPIDgetPID (unsigned int i) const
 Use this if you want to double check the PID you set.

virtual int updateOutputs ()
 Inherited.
virtual int isDirty ()
 Inherited.
virtual int isAlive ()
 Inherited.
void setDirty ()
 Inherited.
virtual void doStart ()
 marks this as dirty each time it is added

Static Protected Member Functions

static bool isPID (unsigned int i)
 returns true if the output i is a PID joint

Protected Attributes

bool dirty
 true if there are changes that have not been picked up by Motion
bool completionReported
 true if we've reported completion of this motion command
OutputPID PIDs [NumPIDJoints]
 the PIDs being requested

Constructor & Destructor Documentation

PIDMC::PIDMC (  ) 

Constructor, uses default PIDs and 0 weight for all.

Definition at line 45 of file PIDMC.h.

PIDMC::PIDMC ( float  powerlevel,
float  w = 1 
)

Constructor, sets general power level of all.

Definition at line 50 of file PIDMC.h.

PIDMC::PIDMC ( unsigned int  low,
unsigned int  high,
float  powerlevel,
float  w = 1 
)

Constructor, sets general power level of a range of joints, uses default and 0 weight for others, see setRangePowerLevel().

Parameters:
low the first joint to apply powerlevel to
high one-past last joint to apply powerlevel to (i.e. exclusive upper limit)
powerlevel scaling factor for all of the default PID parameters
w MotionManager weight for averaging conflicting commands

Note that if you want to set a single joint i, then low = i, and high = i + 1 because high is an exclusive upper limit

Definition at line 60 of file PIDMC.h.

virtual PIDMC::~PIDMC (  )  [virtual]

Destructor.

Definition at line 68 of file PIDMC.h.


Member Function Documentation

virtual void PIDMC::doStart (  )  [virtual]

marks this as dirty each time it is added

Reimplemented from MotionCommand.

Definition at line 89 of file PIDMC.h.

const OutputPID& PIDMC::getPID ( unsigned int  i  )  const

Use this if you want to double check the PID you set.

Definition at line 153 of file PIDMC.h.

OutputPID& PIDMC::getPID ( unsigned int  i  ) 

Use this if you want to double check the PID you set.

Definition at line 148 of file PIDMC.h.

virtual int PIDMC::isAlive (  )  [virtual]

Inherited.

Implements MotionCommand.

Definition at line 84 of file PIDMC.h.

virtual int PIDMC::isDirty (  )  [virtual]

Inherited.

Implements MotionCommand.

Definition at line 83 of file PIDMC.h.

static bool PIDMC::isPID ( unsigned int  i  )  [static, protected]

returns true if the output i is a PID joint

Definition at line 159 of file PIDMC.h.

void PIDMC::setAllPowerLevel ( float  p,
float  w = 1 
)

Sets the PIDs to a percentage of default for all joints.

Definition at line 111 of file PIDMC.h.

Referenced by PIDMC(), and setDefaults().

void PIDMC::setDefaults ( float  weight = 1  ) 

Sets the PIDs to the defaults specified in RobotInfo.

Definition at line 97 of file PIDMC.h.

Referenced by PIDMC().

void PIDMC::setDirty (  ) 

Inherited.

Definition at line 86 of file PIDMC.h.

void PIDMC::setJointPowerLevel ( unsigned int  i,
float  p,
float  w = 1 
)

Sets the PIDs to a percentage of default for a given joint, and sets weight.

Definition at line 102 of file PIDMC.h.

void PIDMC::setPID ( unsigned int  i,
const OutputPID pid 
)

Use this to set the PID value and weight.

Definition at line 141 of file PIDMC.h.

void PIDMC::setRangePowerLevel ( unsigned int  low,
unsigned int  high,
float  p,
float  w = 1 
)

Sets a range of joints' PIDs to a given power level and weight.

Parameters:
low the first joint to apply power level p to
high one-past last joint to apply power level p to (i.e. exclusive upper limit)
p scaling factor for all of the default PID parameters
w MotionManager weight for averaging conflicting commands

Note that if you want to set a single joint i with this function (as opposed to setJointPowerLevel() which is designed for that...) then you would need to pass low = i, and high = i + 1 because high is an exclusive upper limit

Definition at line 128 of file PIDMC.h.

Referenced by PIDMC().

virtual int PIDMC::updateOutputs (  )  [virtual]

Inherited.

Implements MotionCommand.

Definition at line 72 of file PIDMC.h.


Member Data Documentation

bool PIDMC::completionReported [protected]

true if we've reported completion of this motion command

Definition at line 164 of file PIDMC.h.

Referenced by doStart(), and updateOutputs().

bool PIDMC::dirty [protected]

true if there are changes that have not been picked up by Motion

Definition at line 163 of file PIDMC.h.

Referenced by doStart(), isAlive(), isDirty(), PIDMC(), setAllPowerLevel(), setDirty(), setJointPowerLevel(), setPID(), setRangePowerLevel(), and updateOutputs().

OutputPID PIDMC::PIDs[NumPIDJoints] [protected]

the PIDs being requested

Definition at line 165 of file PIDMC.h.

Referenced by getPID(), setAllPowerLevel(), setJointPowerLevel(), setPID(), setRangePowerLevel(), and updateOutputs().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:14 2016 by Doxygen 1.6.3