Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

HeadPointerMC Class Reference

This class gives some quick and easy functions to point the head at things. More...

#include <HeadPointerMC.h>

Inheritance diagram for HeadPointerMC:

Detailed Description

This class gives some quick and easy functions to point the head at things.

Definition at line 15 of file HeadPointerMC.h.

List of all members.

Public Member Functions

 HeadPointerMC ()
 Constructor, defaults to all joints to current value in state (i.e. calls takeSnapshot() automatically).
virtual ~HeadPointerMC ()
 Destructor.
virtual void setHold (bool h=true)
 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.
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 targetReached, reassigns headCmds from MotionManager::getOutputCmd(), then sets dirty to true and targetReached 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 (unsigned int i, float x)
 Sets maxSpeed in rad/sec.
float getMaxSpeed (unsigned int i)
 Returns maxSpeed in rad/sec.
Joint Accessors

void setWeight (float w)
 Sets the weight values for all the neck joints.
void setJoints (float pan, float tilt)
 Request a set of neck joint values.
void setJoints (float tilt, float pan, float tilt2)
 Sets the weight values for all the neck joints.
void setJoints (float pan, float shoulder, float elbow, float pitch)
 Sets the weight values for all the neck joints.
void setJointValue (unsigned int i, float value)
 Directly set a single neck joint value.
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.
bool lookAtPoint (float x, float y, float z)
 Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.
bool lookAtPoint (const DualCoding::Point &p)
 Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.
bool lookAtPoint (const fmat::Column< 3 > &p)
 Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.
bool lookAtPoint (float x, float y, float z, float d)
 Centers the camera on a point in space, attempting to move the camera d millimeters away from the point.
bool lookInDirection (float x, float y, float z)
 Points the camera in a given direction.
bool lookAtJoint (unsigned int j)
 Points the camera at a given robot joint; most useful with GripperFrameOffset.
Inherited:

virtual int updateOutputs ()
 Updates where the head 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

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,NumHeadJoints). If it is instead in the range (HeadOffset,HeadOffset+NumHeadJoints), 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.05 radian (2.86 degree error)
bool targetReached
 false if the head is still moving towards its target
unsigned int targetTimestamp
 time at which the targetReached 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 headTargets [NumHeadJoints]
 stores the target value of each joint
OutputCmd headCmds [NumHeadJoints]
 stores the last values we sent from updateOutputs
float maxSpeed [NumHeadJoints]
 initialized from Config::motion_config, but can be overridden by setMaxSpeed(); rad per frame

Constructor & Destructor Documentation

HeadPointerMC::HeadPointerMC (  ) 

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

Definition at line 20 of file HeadPointerMC.cc.

virtual HeadPointerMC::~HeadPointerMC (  )  [virtual]

Destructor.

Definition at line 21 of file HeadPointerMC.h.


Member Function Documentation

static float HeadPointerMC::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 172 of file HeadPointerMC.h.

Referenced by setJoints(), and setJointValue().

void HeadPointerMC::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 45 of file HeadPointerMC.cc.

Referenced by HeadPointerMC().

virtual void HeadPointerMC::doStart (  )  [virtual]

marks this as dirty each time it is added

Reimplemented from MotionCommand.

Definition at line 152 of file HeadPointerMC.h.

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

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

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

Definition at line 302 of file HeadPointerMC.cc.

Referenced by getJointValue(), and setJointValue().

void HeadPointerMC::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 29 of file HeadPointerMC.cc.

virtual bool HeadPointerMC::getHold (  )  [virtual]

return hold

Definition at line 25 of file HeadPointerMC.h.

float HeadPointerMC::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 HeadOffset (i.e. one of TPROffset_t)

Definition at line 101 of file HeadPointerMC.h.

Referenced by DualCoding::Lookout::searchAt().

float HeadPointerMC::getMaxSpeed ( unsigned int  i  ) 

Returns maxSpeed in rad/sec.

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

Definition at line 60 of file HeadPointerMC.h.

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

returns timeout

Definition at line 30 of file HeadPointerMC.h.

virtual float HeadPointerMC::getTolerance (  )  [virtual]

returns tolerance

Definition at line 28 of file HeadPointerMC.h.

int HeadPointerMC::isAlive (  )  [virtual]

Alive while target is not reached.

Implements MotionCommand.

Definition at line 272 of file HeadPointerMC.cc.

virtual int HeadPointerMC::isDirty (  )  [virtual]

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

Implements MotionCommand.

Definition at line 150 of file HeadPointerMC.h.

Referenced by updateOutputs().

bool HeadPointerMC::lookAtJoint ( unsigned int  j  ) 

Points the camera at a given robot joint; most useful with GripperFrameOffset.

Definition at line 228 of file HeadPointerMC.cc.

bool HeadPointerMC::lookAtPoint ( float  x,
float  y,
float  z,
float  d 
)

Centers the camera on a point in space, attempting to move the camera d millimeters away from the point.

Point should be relative to the body reference frame (see BaseFrameOffset). Returns true if the target is reachable.

Parameters:
x location in millimeters
y location in millimeters
z location in millimeters
d target distance from point in millimeters

Definition at line 176 of file HeadPointerMC.cc.

bool HeadPointerMC::lookAtPoint ( const fmat::Column< 3 > &  p  ) 

Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.

Point should be relative to the body reference frame (see BaseFrameOffset). Returns true if the target is reachable.

Parameters:
p point to look at

Definition at line 172 of file HeadPointerMC.cc.

bool HeadPointerMC::lookAtPoint ( const DualCoding::Point &  p  ) 

Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.

Point should be relative to the body reference frame (see BaseFrameOffset). Returns true if the target is reachable.

Parameters:
p point to look at

Definition at line 147 of file HeadPointerMC.cc.

bool HeadPointerMC::lookAtPoint ( float  x,
float  y,
float  z 
)

Centers the camera on a point in space, attempting to keep the camera as far away from the point as possible.

Point should be relative to the body reference frame (see BaseFrameOffset). Returns true if the target is reachable.

Parameters:
x location in millimeters
y location in millimeters
z location in millimeters
Todo:
this method is an approximation, could be more precise, and perhaps faster, although this is pretty good.

Definition at line 117 of file HeadPointerMC.cc.

Referenced by DualCoding::MapBuilder::determineNextGazePoint(), lookAtJoint(), lookAtPoint(), and DualCoding::Lookout::searchAt().

bool HeadPointerMC::lookInDirection ( float  x,
float  y,
float  z 
)

Points the camera in a given direction.

Vector should be relative to the body reference frame (see BaseFrameOffset). Returns true if the target is reachable.

Parameters:
x component of the direction vector
y component of the direction vector
z component of the direction vector

Definition at line 202 of file HeadPointerMC.cc.

void HeadPointerMC::noMaxSpeed (  ) 

Sets maxSpeed to 0 (no maximum).

Definition at line 46 of file HeadPointerMC.h.

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

puts x in the range (-pi,pi)

Definition at line 169 of file HeadPointerMC.h.

Referenced by clipAngularRange().

void HeadPointerMC::setDirty (  ) 

if targetReached, reassigns headCmds from MotionManager::getOutputCmd(), then sets dirty to true and targetReached to false

should be called each time a joint value gets modified in case the head 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 293 of file HeadPointerMC.cc.

Referenced by doStart(), lookAtPoint(), lookInDirection(), setJoints(), setJointValue(), and setWeight().

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

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 24 of file HeadPointerMC.h.

void HeadPointerMC::setJoints ( float  pan,
float  shoulder,
float  elbow,
float  pitch 
)

Sets the weight values for all the neck joints.

Definition at line 103 of file HeadPointerMC.cc.

void HeadPointerMC::setJoints ( float  tilt,
float  pan,
float  tilt2 
)

Sets the weight values for all the neck joints.

Definition at line 79 of file HeadPointerMC.cc.

void HeadPointerMC::setJoints ( float  pan,
float  tilt 
)

Request a set of neck joint values.

Originally this corresponded directly to the neck joints of the aibo, however on other platforms it will use capabilties mapping to try to set correspnding joints if available. (we're not doing kinematics here, trying to set joint values directly. If your want a more generic/abstract interface, use lookAtPoint()/lookInDirection().

Note that for a "pan-tilt" camera, you actually want to set the last two parameters, not the first two!

Parameters:
tilt value - this is an initial rotation about the camera x axis
pan value - this is a rotation about the camera y axis
tilt2 value - a second rotation about the camera x axis ("nod")

On ERS-210 and 220, the tilt2 is actually a roll about camera z (ugly, but no one's using those anymore, so moot issue)

Definition at line 74 of file HeadPointerMC.cc.

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

Directly set a single neck joint value.

Parameters:
i joint offset relative to HeadOffset (i.e. one of TPROffset_t)
value the value to be assigned to join i, in radians

Definition at line 90 of file HeadPointerMC.h.

Referenced by setJoints().

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

Sets maxSpeed in rad/sec.

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

Definition at line 55 of file HeadPointerMC.h.

Referenced by setJoints().

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

sets timeout

Definition at line 29 of file HeadPointerMC.h.

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

sets tolerance

Definition at line 27 of file HeadPointerMC.h.

void HeadPointerMC::setWeight ( float  w  ) 

Sets the weight values for all the neck joints.

Definition at line 66 of file HeadPointerMC.cc.

Referenced by HeadPointerMC().

void HeadPointerMC::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 37 of file HeadPointerMC.cc.

Referenced by HeadPointerMC().

int HeadPointerMC::updateOutputs (  )  [virtual]

Updates where the head is looking.

Implements MotionCommand.

Definition at line 233 of file HeadPointerMC.cc.


Member Data Documentation

bool HeadPointerMC::dirty [protected]

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

Definition at line 192 of file HeadPointerMC.h.

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

OutputCmd HeadPointerMC::headCmds[NumHeadJoints] [protected]

stores the last values we sent from updateOutputs

Definition at line 199 of file HeadPointerMC.h.

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

float HeadPointerMC::headTargets[NumHeadJoints] [protected]

stores the target value of each joint

Definition at line 198 of file HeadPointerMC.h.

Referenced by freezeMotion(), getJointValue(), isAlive(), lookAtPoint(), lookInDirection(), setJoints(), setJointValue(), takeSnapshot(), and updateOutputs().

bool HeadPointerMC::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 193 of file HeadPointerMC.h.

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

float HeadPointerMC::maxSpeed[NumHeadJoints] [protected]

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

Definition at line 200 of file HeadPointerMC.h.

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

bool HeadPointerMC::targetReached [protected]

false if the head is still moving towards its target

Definition at line 195 of file HeadPointerMC.h.

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

unsigned int HeadPointerMC::targetTimestamp [protected]

time at which the targetReached flag was set

Definition at line 196 of file HeadPointerMC.h.

Referenced by isAlive(), and updateOutputs().

unsigned int HeadPointerMC::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 197 of file HeadPointerMC.h.

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

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.05 radian (2.86 degree error)

Definition at line 194 of file HeadPointerMC.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:09 2016 by Doxygen 1.6.3