Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ArmMC Class Reference

#include <ArmMC.h>

Inheritance diagram for ArmMC:

Detailed Description

Definition at line 12 of file ArmMC.h.

List of all members.

Public Member Functions

 ArmMC ()
 Constructor, defaults to all joints to current value in state (i.e. calls takeSnapshot() automatically).
virtual ~ArmMC ()
virtual void setHold (bool h=true)
 Constructor.
virtual bool getHold ()
 return hold
virtual void setTolerance (float t)
 sets tolerance
virtual float getTolerance ()
 returns tolerance
virtual void setTimeout (unsigned int delay)
 sets timeout
virtual unsigned int getTimeout ()
 returns timeout
virtual void freezeMotion ()
 sets the target to last sent commands, and dirty to false; essentially freezes motion in place
virtual void takeSnapshot ()
 sets the target joint positions to current sensor values
void setDirty ()
 if completionReported, copies armCmds from MotionManager::getOutputCmd(), then sets dirty to true and completionReported to false
Speed Control

void noMaxSpeed ()
 Sets maxSpeed to 0 (no maximum).
void defaultMaxSpeed (float x=1)
 Restores maxSpeed to default settings from Config::Motion_Config.
void setMaxSpeed (float x)
 Sets maxSpeed for all joints in rad/sec.
void setMaxSpeed (unsigned int i, float x)
 Sets maxSpeed for join i in rad/sec.
void setGripperSpeed (float x)
 Set speed of gripper joints.
float getMaxSpeed (unsigned int i)
 Returns maxSpeed in rad/sec.
Joint Accessors

void setWeight (float w)
 Sets the weight values for all the arm joints.
void setWeight (int x, float w)
 Sets the weight values for all the arm joints.
float armJointValue (unsigned int i)
 Sets the weight values for all the arm joints.
void setJointValue (unsigned int i, float value)
 Sets the weight values for all the arm joints.
float getJointValue (unsigned int i) const
 Returns the target value of joint i. Use this if you want to know the current commanded joint value; To get the current joint position, look in WorldState::outputs.
void setJoints (float shoulder, float elbow, float wrist)
 Set joint values for a three-link arm.
void setJoints (float shoulder, float elbow, float yaw, float pitch, float roll, float gripper)
 Set joint values for a Chiara-style arm.
void setWrist (float pitch, float roll, float gripper)
 Sets the weight values for all the arm joints.
void setGripperPulse (unsigned int onPeriod, unsigned int offPeriod)
 Pulse the gripper to prevent load errors.
void clearGripperPulse ()
 Sets the weight values for all the arm joints.
void requestGripperLoad (int newLoad)
 Sets the desired load value for subsequent grip operations.
int getGripperLoad ()
 Returns the current active load on the gripper's servos.
void setGraspSpeed (float speed)
 Sets the member angleIncrement to the specified value (default = 0.05).
void setGraspWait (unsigned int cycles)
 Sets the member idleCycles to the specified value (default = 8).
int getDesiredLoad ()
 Returns the value of desiredLoad last set by the user.
bool moveToPoint (float x, float y, float z)
 Move arm to specified point in base frame coordinates; return false if unreachable.
bool moveToPoint (const fmat::Column< 3 > &tgt)
 Sets the weight values for all the arm joints.
bool moveOffsetToPoint (const fmat::Column< 3 > &offset, const fmat::Column< 3 > &tgt)
 Sets the weight values for all the arm joints.
bool moveOffsetToPointWithOrientation (const fmat::Column< 3 > &offset, const fmat::Column< 3 > &tgt, const fmat::Quaternion &ori)
 Sets the weight values for all the arm joints.
bool setFingerGap (float dist)
 Move the fingers or gripper to achieve the specified gap.
bool openGripper (float percentage=0.5)
 Open the gripper to a certain percentage of its range of travel.
void setOutputCmd (unsigned int i, const OutputCmd &c)
 Sets the weight values for all the arm joints.
Inherited:

virtual int updateOutputs ()
 Updates where the arm is looking.
virtual int isDirty ()
 true if a change has been made since the last updateJointCmds() and we're active
virtual int isAlive ()
 Alive while target is not reached.
virtual void doStart ()
 marks this as dirty each time it is added

Protected Member Functions

void incrementGrasp ()
 Helper function to execute a grasp.

Static Protected Member Functions

static float normalizeAngle (float x)
 puts x in the range (-pi,pi)
static float clipAngularRange (unsigned int i, float x)
 if x is outside of the range of joint i, it is set to either the min or the max, whichever is closer
static bool ensureValidJoint (unsigned int &i)
 Makes sure i is in the range (0,NumArmJoints). If it is instead in the range (ArmOffset,ArmOffset+NumArmJoints), output a warning and reset i to the obviously intended value.

Protected Attributes

bool dirty
 true if a change has been made since last call to updateJointCmds()
bool hold
 if set to true, the posture will be kept active; otherwise joints will be marked unused after each posture is achieved (as if the posture was pruned); set through setHold()
float tolerance
 when autopruning, if the maxdiff() of this posture and the robot's current position is below this value, isAlive() will be false, defaults to 0.01 (5.7 degree error)
bool completionReported
 true if the most recent movement request has completed
unsigned int targetTimestamp
 time at which the completionReported flag was set
unsigned int timeout
 number of milliseconds to wait before giving up on a target that should have already been reached, a value of -1U will try forever
float armTargets [NumArmJoints]
 stores the target value of each joint
OutputCmd armCmds [NumArmJoints]
 stores the last values we sent from updateOutputs
float maxSpeed [NumArmJoints]
 initialized from Config::motion_config, but can be overridden by setMaxSpeed(); rad per frame
unsigned int pulseOnPeriod
 number of milliseconds to keep servo power on, when pulsing
unsigned int pulseOffPeriod
 number of milliseconds to keep servo power off, when pulsing
unsigned int pulseStartTime
 when the current pulse cycle started
signed int desiredLoad
 how tightly to grasp an object (negative is for tighter loads; -280 is a good value)
float angleIncrement
 How fast to close the gripper (0.05 by default).
unsigned int idleCycles
 How long to wait before updating the gripper angle by angleIncrement (8 by default).

Constructor & Destructor Documentation

ArmMC::ArmMC (  ) 

Constructor, defaults to all joints to current value in state (i.e. calls takeSnapshot() automatically).

Definition at line 16 of file ArmMC.cc.

virtual ArmMC::~ArmMC (  )  [virtual]

Definition at line 16 of file ArmMC.h.


Member Function Documentation

float ArmMC::armJointValue ( unsigned int  i  ) 

Sets the weight values for all the arm joints.

Definition at line 47 of file ArmMC.cc.

void ArmMC::clearGripperPulse (  ) 

Sets the weight values for all the arm joints.

Definition at line 220 of file ArmMC.cc.

static float ArmMC::clipAngularRange ( unsigned int  i,
float  x 
) [static, protected]

if x is outside of the range of joint i, it is set to either the min or the max, whichever is closer

Definition at line 177 of file ArmMC.h.

Referenced by setJointValue().

void ArmMC::defaultMaxSpeed ( float  x = 1  ) 

Restores maxSpeed to default settings from Config::Motion_Config.

Parameters:
x ratio of the max speed to use; so 0.5 would limit motion to half the recommended upper limit

Definition at line 56 of file ArmMC.cc.

Referenced by ArmMC().

virtual void ArmMC::doStart (  )  [virtual]

marks this as dirty each time it is added

Reimplemented from MotionCommand.

Definition at line 148 of file ArmMC.h.

bool ArmMC::ensureValidJoint ( unsigned int &  i  )  [static, protected]

Makes sure i is in the range (0,NumArmJoints). If it is instead in the range (ArmOffset,ArmOffset+NumArmJoints), output a warning and reset i to the obviously intended value.

Parameters:
[in] i joint offset relative to either ArmOffset (i.e. one of TPROffset_t) or 0
[out] i joint offset relative to ArmOffset (i.e. one of TPROffset_t)
Returns:
true if the intended joint could be ascertained, false otherwise

Definition at line 429 of file ArmMC.cc.

Referenced by getJointValue(), and setJointValue().

void ArmMC::freezeMotion (  )  [virtual]

sets the target to last sent commands, and dirty to false; essentially freezes motion in place

This is very similar to takeSnapshot(), but will do the "right thing" (retain current position) when motion blending is involved. A status event will be generated if/when the joints reach the currently commanded position. Probably should use freezeMotion() if you want to stop a motion underway, but takeSnapshot() if you want to reset/intialize to the current joint positions.

Definition at line 31 of file ArmMC.cc.

int ArmMC::getDesiredLoad (  ) 

Returns the value of desiredLoad last set by the user.

Definition at line 117 of file ArmMC.h.

int ArmMC::getGripperLoad (  ) 

Returns the current active load on the gripper's servos.

Definition at line 147 of file ArmMC.cc.

Referenced by incrementGrasp().

virtual bool ArmMC::getHold (  )  [virtual]

return hold

Definition at line 22 of file ArmMC.h.

float ArmMC::getJointValue ( unsigned int  i  )  const

Returns the target value of joint i. Use this if you want to know the current commanded joint value; To get the current joint position, look in WorldState::outputs.

Parameters:
i joint offset relative to ArmOffset (i.e. one of TPROffset_t)

Definition at line 87 of file ArmMC.h.

float ArmMC::getMaxSpeed ( unsigned int  i  ) 

Returns maxSpeed in rad/sec.

Parameters:
i joint offset relative to ArmOffset (i.e. one of TPROffset_t)
Returns:
the maximum speed of joint i in radians per second

Definition at line 64 of file ArmMC.h.

virtual unsigned int ArmMC::getTimeout (  )  [virtual]

returns timeout

Definition at line 27 of file ArmMC.h.

virtual float ArmMC::getTolerance (  )  [virtual]

returns tolerance

Definition at line 25 of file ArmMC.h.

void ArmMC::incrementGrasp (  )  [protected]

Helper function to execute a grasp.

Definition at line 172 of file ArmMC.cc.

Referenced by updateOutputs().

int ArmMC::isAlive (  )  [virtual]

Alive while target is not reached.

Implements MotionCommand.

Definition at line 398 of file ArmMC.cc.

virtual int ArmMC::isDirty (  )  [virtual]

true if a change has been made since the last updateJointCmds() and we're active

Implements MotionCommand.

Definition at line 146 of file ArmMC.h.

Referenced by updateOutputs().

bool ArmMC::moveOffsetToPoint ( const fmat::Column< 3 > &  offset,
const fmat::Column< 3 > &  tgt 
)

Sets the weight values for all the arm joints.

Definition at line 232 of file ArmMC.cc.

Referenced by moveToPoint().

bool ArmMC::moveOffsetToPointWithOrientation ( const fmat::Column< 3 > &  offset,
const fmat::Column< 3 > &  tgt,
const fmat::Quaternion ori 
)

Sets the weight values for all the arm joints.

Definition at line 259 of file ArmMC.cc.

bool ArmMC::moveToPoint ( const fmat::Column< 3 > &  tgt  ) 

Sets the weight values for all the arm joints.

Definition at line 122 of file ArmMC.h.

bool ArmMC::moveToPoint ( float  x,
float  y,
float  z 
)

Move arm to specified point in base frame coordinates; return false if unreachable.

Definition at line 121 of file ArmMC.h.

void ArmMC::noMaxSpeed (  ) 

Sets maxSpeed to 0 (no maximum).

Definition at line 44 of file ArmMC.h.

static float ArmMC::normalizeAngle ( float  x  )  [static, protected]

puts x in the range (-pi,pi)

Definition at line 174 of file ArmMC.h.

Referenced by clipAngularRange().

bool ArmMC::openGripper ( float  percentage = 0.5  ) 

Open the gripper to a certain percentage of its range of travel.

Definition at line 306 of file ArmMC.cc.

void ArmMC::requestGripperLoad ( int  newLoad = -280  ) 

Sets the desired load value for subsequent grip operations.

Definition at line 138 of file ArmMC.cc.

Referenced by openGripper().

void ArmMC::setDirty (  ) 

if completionReported, copies armCmds from MotionManager::getOutputCmd(), then sets dirty to true and completionReported to false

should be called each time a joint value gets modified in case the arm isn't where it's supposed to be, it won't jerk around

MotionManager::getOutputCmd() is called instead of WorldState::outputs[] because if this is being called rapidly (i.e. after every sensor reading) using the sensor values will cause problems with very slow acceleration due to sensor lag continually resetting the current position. Using the last value sent by the MotionManager fixes this.

Definition at line 420 of file ArmMC.cc.

Referenced by doStart(), requestGripperLoad(), setGripperPulse(), setJointValue(), and setWeight().

bool ArmMC::setFingerGap ( float  dist  ) 

Move the fingers or gripper to achieve the specified gap.

Definition at line 286 of file ArmMC.cc.

void ArmMC::setGraspSpeed ( float  speed  ) 

Sets the member angleIncrement to the specified value (default = 0.05).

This is only applicable for CALLIOPE2 and will do nothing for any other robot.

Definition at line 156 of file ArmMC.cc.

Referenced by setGripperSpeed().

void ArmMC::setGraspWait ( unsigned int  cycles  ) 

Sets the member idleCycles to the specified value (default = 8).

This is only applicable for CALLIOPE2 and will do nothing for any other robot. The purpose of this parameter is to control how fast often angleIncrement is used. If it is used too often, the gripper will move too fast, generate an invalid load, and then not close correctly.

Definition at line 164 of file ArmMC.cc.

void ArmMC::setGripperPulse ( unsigned int  onPeriod,
unsigned int  offPeriod 
)

Pulse the gripper to prevent load errors.

Definition at line 130 of file ArmMC.cc.

void ArmMC::setGripperSpeed ( float  x  ) 

Set speed of gripper joints.

Definition at line 117 of file ArmMC.cc.

virtual void ArmMC::setHold ( bool  h = true  )  [virtual]

Constructor.

Sets hold - if this is set to false, it will allow a persistent motion to behave the same as a pruned motion, without being pruned

Definition at line 21 of file ArmMC.h.

void ArmMC::setJoints ( float  shoulder,
float  elbow,
float  yaw,
float  pitch,
float  roll,
float  gripper 
)

Set joint values for a Chiara-style arm.

Definition at line 89 of file ArmMC.cc.

void ArmMC::setJoints ( float  shoulder,
float  elbow,
float  wrist 
)

Set joint values for a three-link arm.

Definition at line 78 of file ArmMC.cc.

void ArmMC::setJointValue ( unsigned int  i,
float  value 
)

Sets the weight values for all the arm joints.

Definition at line 76 of file ArmMC.h.

Referenced by incrementGrasp(), openGripper(), setFingerGap(), setJoints(), and setWrist().

void ArmMC::setMaxSpeed ( unsigned int  i,
float  x 
)

Sets maxSpeed for join i in rad/sec.

Parameters:
i joint offset relative to ArmOffset (i.e. one of TPROffset_t)
x maximum radians per second to move

Definition at line 56 of file ArmMC.h.

void ArmMC::setMaxSpeed ( float  x  ) 

Sets maxSpeed for all joints in rad/sec.

Definition at line 51 of file ArmMC.h.

Referenced by setGripperSpeed(), setJoints(), setMaxSpeed(), and setWrist().

void ArmMC::setOutputCmd ( unsigned int  i,
const OutputCmd c 
)

Sets the weight values for all the arm joints.

Definition at line 132 of file ArmMC.h.

Referenced by moveOffsetToPoint(), and moveOffsetToPointWithOrientation().

virtual void ArmMC::setTimeout ( unsigned int  delay  )  [virtual]

sets timeout

Definition at line 26 of file ArmMC.h.

virtual void ArmMC::setTolerance ( float  t  )  [virtual]

sets tolerance

Definition at line 24 of file ArmMC.h.

void ArmMC::setWeight ( int  x,
float  w 
)

Sets the weight values for all the arm joints.

Definition at line 71 of file ArmMC.cc.

void ArmMC::setWeight ( float  w  ) 

Sets the weight values for all the arm joints.

Definition at line 63 of file ArmMC.cc.

Referenced by ArmMC(), and setJointValue().

void ArmMC::setWrist ( float  pitch,
float  roll,
float  gripper 
)

Sets the weight values for all the arm joints.

Definition at line 106 of file ArmMC.cc.

void ArmMC::takeSnapshot (  )  [virtual]

sets the target joint positions to current sensor values

Similar to freezeMotion() when a motion is underway, but only if no other MotionCommands are using neck joints. A status event will not be generated unless a motion was already underway. Probably should use freezeMotion() if you want to stop a motion underway, but takeSnapshot() if you want to reset/intialize to the current joint positions.

Definition at line 39 of file ArmMC.cc.

Referenced by ArmMC().

int ArmMC::updateOutputs (  )  [virtual]

Updates where the arm is looking.

Implements MotionCommand.

Definition at line 324 of file ArmMC.cc.


Member Data Documentation

How fast to close the gripper (0.05 by default).

Definition at line 213 of file ArmMC.h.

Referenced by incrementGrasp(), and setGraspSpeed().

OutputCmd ArmMC::armCmds[NumArmJoints] [protected]

stores the last values we sent from updateOutputs

Definition at line 207 of file ArmMC.h.

Referenced by freezeMotion(), setDirty(), setOutputCmd(), setWeight(), takeSnapshot(), and updateOutputs().

float ArmMC::armTargets[NumArmJoints] [protected]

stores the target value of each joint

Definition at line 206 of file ArmMC.h.

Referenced by armJointValue(), freezeMotion(), getJointValue(), isAlive(), setJointValue(), setOutputCmd(), takeSnapshot(), and updateOutputs().

bool ArmMC::completionReported [protected]

true if the most recent movement request has completed

Definition at line 203 of file ArmMC.h.

Referenced by isAlive(), isDirty(), setDirty(), setOutputCmd(), and updateOutputs().

signed int ArmMC::desiredLoad [protected]

how tightly to grasp an object (negative is for tighter loads; -280 is a good value)

Definition at line 212 of file ArmMC.h.

Referenced by getDesiredLoad(), incrementGrasp(), requestGripperLoad(), and updateOutputs().

bool ArmMC::dirty [protected]

true if a change has been made since last call to updateJointCmds()

Definition at line 200 of file ArmMC.h.

Referenced by freezeMotion(), isAlive(), isDirty(), setDirty(), setOutputCmd(), takeSnapshot(), and updateOutputs().

bool ArmMC::hold [protected]

if set to true, the posture will be kept active; otherwise joints will be marked unused after each posture is achieved (as if the posture was pruned); set through setHold()

Definition at line 201 of file ArmMC.h.

Referenced by getHold(), isAlive(), setHold(), and updateOutputs().

unsigned int ArmMC::idleCycles [protected]

How long to wait before updating the gripper angle by angleIncrement (8 by default).

Definition at line 214 of file ArmMC.h.

Referenced by incrementGrasp(), and setGraspWait().

float ArmMC::maxSpeed[NumArmJoints] [protected]

initialized from Config::motion_config, but can be overridden by setMaxSpeed(); rad per frame

Definition at line 208 of file ArmMC.h.

Referenced by defaultMaxSpeed(), getMaxSpeed(), noMaxSpeed(), setMaxSpeed(), and updateOutputs().

unsigned int ArmMC::pulseOffPeriod [protected]

number of milliseconds to keep servo power off, when pulsing

Definition at line 210 of file ArmMC.h.

Referenced by clearGripperPulse(), setGripperPulse(), and updateOutputs().

unsigned int ArmMC::pulseOnPeriod [protected]

number of milliseconds to keep servo power on, when pulsing

Definition at line 209 of file ArmMC.h.

Referenced by clearGripperPulse(), setGripperPulse(), and updateOutputs().

unsigned int ArmMC::pulseStartTime [protected]

when the current pulse cycle started

Definition at line 211 of file ArmMC.h.

Referenced by setGripperPulse(), and updateOutputs().

unsigned int ArmMC::targetTimestamp [protected]

time at which the completionReported flag was set

Definition at line 204 of file ArmMC.h.

Referenced by isAlive(), and updateOutputs().

unsigned int ArmMC::timeout [protected]

number of milliseconds to wait before giving up on a target that should have already been reached, a value of -1U will try forever

Definition at line 205 of file ArmMC.h.

Referenced by getTimeout(), isAlive(), and setTimeout().

float ArmMC::tolerance [protected]

when autopruning, if the maxdiff() of this posture and the robot's current position is below this value, isAlive() will be false, defaults to 0.01 (5.7 degree error)

Definition at line 202 of file ArmMC.h.

Referenced by getTolerance(), isAlive(), and setTolerance().


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

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