#include <bhandforce.h>
Inheritance diagram for BHandForce:
Public Member Functions | |
BHandForce (std::string devName) | |
Constructor for class BHandForce. | |
void | init () throw (BHandException) |
Initializes the BarrettHand. | |
void | setRTDefaults () |
Sets the default parameters for real time mode. | |
void | setRTForceDefaults () |
Sets the default parameters for force red mode. | |
virtual | ~BHandForce () |
Destructor. | |
Movement Commands | |
Movement commands are motor commands: they immediately affect one or more of the motors. | |
void | adjustForce (const Motors motors, const int force) throw (BHandException) |
Moves the finger(s) that the force is obtained. | |
void | closeFingers (const Motors motors) throw (BHandException) |
Closes the fingers of the BarrettHand. | |
void | closeSpread () throw (BHandException) |
void | force2File (std::string fileName, bool showPlot=false) |
Records force values to file. | |
void | forceCalib (std::string fileName, bool showPlot=false) |
void | move (const Motors motors, const int position[4]) throw (BHandException) |
Moves all Motors to the given Position. | |
void | move (const Motors motors, const int position) throw (BHandException) |
Moves all Motors to the given Position. | |
void | move (const Motors motors, const bool plotIt=false) throw (BHandException) |
Moves vereryone of the motors to its desired position. | |
void | moveForce (const Motors motors, int force[3]) throw (BHandException) |
Moves (closes) the fingers until the finger is not moving or the limit force is reached. | |
void | moveForce (const Motors motors) throw (BHandException) |
Moves (closes) the fingers until the finger is not moving or the limit force is reached. | |
void | moveG (const Motors motors, const int position) throw (BHandException) |
void | moveG (const Motors motors) throw (BHandException) |
void | openFingers (const Motors motors) throw (BHandException) |
Opens the fingers of the BarrettHand. | |
void | openSpread () throw (BHandException) |
Force commands | |
int | forceInRange (const BHandKin::FINGER f, const bool update=true) |
Returns if force on finger is in desired range or not. | |
void | getForce (int *forces, const bool update=true) |
Returns the finger force values. | |
void | getForce () |
Reads the real finger force values, without moving them and updates force values on internal data structures. | |
void | getForceReal (int *forces) |
Reads the real finger force values, without moving them. | |
RTFlags | getRTFlags () |
Returns the current state of the RealTime mode. | |
void | initForceSensor (const Motors motors=FINGERS) |
Method to initialize finger force sensors. | |
Methods to references to Objects of MoveStruct | |
BHFinger & | getFinger (const BHandKin::FINGER f) const |
Returns reference of BHFinger object from BHandForce::MoveParams. | |
BHMotorExt & | getMotor (const Motors motor) const |
Returns reference of Motor object BHandForce::MoveParams. | |
BHSpread & | getSpread () const |
Returns reference of BHSpread object from BHandForce::MoveParams. | |
Movement Parameter Commands | |
Movement parameter commands have effects on the movement commands. | |
void | setMaxForce (const short force, const Motors motors=FINGERS) |
Sets the maximal allowed force for the given fingers. | |
void | setMaxPosErrorF (const int error) |
Set the maximal allowed error for finger positioning. | |
void | setMaxPosErrorS (const int error) |
Set the maximal allowed error for spread positioning. | |
void | setMinForce (const short force, const Motors motors=FINGERS) |
Sets the minimal allowed force for the given fingers. | |
void | setPos (const Motors motors, const int position) |
Sets the desired positions. | |
void | setPropGain (const Motors motors, const unsigned short gain) |
Sets the proportional gain vlaue. | |
void | setSpeed (const Motors motors, const int speed) |
Sets speed value for desired finger/spread. | |
void | setVelCoeff (const Motors motors, const unsigned short coeff) |
Sets the LoopCtrlCoeff. | |
Protected Member Functions | |
int | clipGain (int gain) |
Clips gain to limits. | |
int | clipSpeed (double speed) |
int | clipSpeed (int speed) |
Clips finger speed to limits. | |
int | clipSSpeed (double speed) |
Clips spread speed to limits. | |
void | resetDeltaPos () |
Resets the DeltaPos value in the feedbackblock for all Motors to zero. | |
Protected Attributes | |
ControlBlock | Cb |
FeedbackBlock | Fb |
unsigned short | LoopCtrlCoeff |
int | MaxPosErrorFinger |
int | MaxPosErrorSpread |
MoveStruct * | MoveParams |
RTFlags | RealTimeFlags |
The state of the real time mode. |
This class provides higher-level functions for force controll of the BarrettHand with use of the strain-gage sensors.
Due to the fact that the TorqueSwitch is not detectable by hardware a force log mechanis is implemented to detect the activation. For activation the speed has to be above 40. The logging mechanis is implemented to detect activations at a speed of 50. If the speed is over 70 a secure detection is not possible, because you do not get enough force feedback value for detection.
The activation of the TorqueSwicth has a dramatical impact on the force values observed by the force sensor of the corresponding finger. For this reasion it is impossible to have both: contorl of the TorqueSwitch and a force to reach.
add force calibration for fingers after pos 8000...
adjust controller for position movements
BHandForce::BHandForce | ( | std::string | devName | ) |
Constructor for class BHandForce.
devName | Name for the device the BarrettHand is connected to (e.g. /dev/ttyS0). |
BHandForce::~BHandForce | ( | ) | [virtual] |
Destructor.
void BHandForce::adjustForce | ( | const Motors | motors, | |
const int | force | |||
) | throw (BHandException) |
Moves the finger(s) that the force is obtained.
The direction of the movement depends on the dircetion of the force. Negative force will close the hand and positive will open it.
So, if you want to hold an object with a specific force, you have to define the force negative.
WARNING The move functions (re)start the realtime mode by themself for the motors of the movement. If rt-mode is enabled it will not be disabled, because it costs to much time. So if you start rt-mode for F1 and want ot adjust the force for F2 you will have call stop() before calling adjustForce() !
motors | Motors to be Moved. If spread is included it will be ignored. | |
force | Force which should be applied to finger tips. |
Reimplemented in BHandForceKinGL.
int BHandForce::clipGain | ( | int | gain | ) | [inline, protected] |
Clips gain to limits.
The Gain value is kept in the range of MIN_GAIN to MAX_GAIN
gain | Gain value to be clipped |
int BHandForce::clipSpeed | ( | double | speed | ) | [inline, protected] |
Clips finger speed to limits.
The Speed is kept in the range of MIN_FINGER_SPEED to MAX_FINGER_SPEED
speed | Speed value to be clipped |
int BHandForce::clipSpeed | ( | int | speed | ) | [inline, protected] |
Clips finger speed to limits.
The Speed is kept in the range of MIN_FINGER_SPEED to MAX_FINGER_SPEED
speed | Speed value to be clipped |
int BHandForce::clipSSpeed | ( | double | speed | ) | [inline, protected] |
Clips spread speed to limits.
The Speed is kept in the range of MIN_SPREAD_SPEED to MAX_SPREAD_SPEED
speed | Speed value to be clipped |
void BHandForce::closeFingers | ( | const Motors | motors | ) | throw (BHandException) [inline] |
Closes the fingers of the BarrettHand.
Stops motion if force limit is reached. Spread motor is ignored by this command.
motors | Fingers to be moved. If paramter contains spread, it will be ignored. |
void BHandForce::closeSpread | ( | ) | throw (BHandException) [inline] |
Moves Spread to close Position.
Any force limits are ignored by this command
Here is the call graph for this function:
void BHandForce::force2File | ( | std::string | fileName, | |
bool | showPlot = false | |||
) |
Records force values to file.
The Hand opens all Fingers and closes them with a rather small velocity. During this close movement all force values form the fingers ar recorded into the given file. If the output file exist, it will be clear before recording.
The output file has the format:
position_F1 force_F1 position_F2 force_F2 poistion_F3 force_F3
fileName | Output file with force and positon values. | |
showPlot | If true the force-position data will be plotted with gnuplot. |
Reimplemented in BHandForceExt.
int BHandForce::forceInRange | ( | const BHandKin::FINGER | f, | |
const bool | update = true | |||
) | [inline] |
Returns if force on finger is in desired range or not.
Computes if the the applied force on a finger is between minForce and maxForce.
NOT (!forceInRange(...)) is the question you normaly want to ask! Because method returns 0 if everything is fine.
f | Finger for which the function should be computed. | |
update | Weather the force values should be updated or not. Maybe the update is done before by getForce() or getForce(int *forces) or getForceN(int *forces). |
Here is the call graph for this function:
BHFinger & BHandForce::getFinger | ( | const BHandKin::FINGER | f | ) | const [inline] |
Returns reference of BHFinger object from BHandForce::MoveParams.
f | Finger of the reference |
void BHandForce::getForce | ( | int * | forces, | |
const bool | update = true | |||
) | [inline] |
Returns the finger force values.
I.e. Reads the finger force values, without moving them and updates force values on internal data structures. Returns the force vlaue minus initialization force value.
forces | Array in which the forces are stored (Must have size of 3). | |
update | Weather the force values should be updated or not. Maybe the update is done before by getForce() or getForce(int *forces). |
Here is the call graph for this function:
void BHandForce::getForce | ( | ) |
Reads the real finger force values, without moving them and updates force values on internal data structures.
void BHandForce::getForceReal | ( | int * | forces | ) |
Reads the real finger force values, without moving them.
If BarrettHand is not int rtMode, rtMode is startet for finger Motors and force values are derived from each finger. Force values in internal data structures are also updated.
The values are directly the ones from the strain gauge of the Hand.
forces | Array in which the forces are stored (Must have size of 3). |
BHMotorExt & BHandForce::getMotor | ( | const Motors | motor | ) | const [inline] |
Returns reference of Motor object BHandForce::MoveParams.
Returns reference to BHMotorExt object from BHandForce::MoveParams.
If motor contains more than one motor the reference of first one will be returned (in oder of enumeration BHand::Motors).
motor | Motor of which the reference should be returned. |
RTFlags BHandForce::getRTFlags | ( | ) | [inline] |
Returns the current state of the RealTime mode.
BHSpread & BHandForce::getSpread | ( | ) | const [inline] |
Returns reference of BHSpread object from BHandForce::MoveParams.
void BHandForce::init | ( | ) | throw (BHandException) |
Initializes the BarrettHand.
Does the same as BHand::init() but additionally it sets the default prameters for rel time mode.
Reimplemented from BHand.
Reimplemented in BHandForceExt.
void BHandForce::initForceSensor | ( | const Motors | motors = FINGERS |
) |
Method to initialize finger force sensors.
Initializes the force sensors of the fingers. I.e. sets BHFinger::initForce()
motors | Argument for which fingers the sensor(s) should be initialized. |
void BHandForce::move | ( | const Motors | motors, | |
const int | position[4] | |||
) | throw (BHandException) |
Moves all Motors to the given Position.
If the Limit force of one of the fingers is reached, the motion for the coressponding will be stopped. If F1 or F2 force is exceeded Spread Motion will be stoped also.
The proportional gain value of each motor is ignored!
The function watches the Temperature of the Hand!
motors | Motors to move. | |
position | Desired positions of motors. Unit: MotorCounts The order of the positions must be is [F!,F2,F3,Spread] |
Reimplemented in BHandForceExt.
void BHandForce::move | ( | const Motors | motors, | |
const int | position | |||
) | throw (BHandException) |
Moves all Motors to the given Position.
If the Limit force of one of the fingers is reached, the motion for the coressponding finger will be stopped. If F1 or F2 force is exceeded Spread Motion will be stoped also.
The proportional gain value of each motor is ignored!
The function watches the Temperature of the Hand!
motors | Motors to move. | |
position | Destinated position. Unit: Motor Counts |
Reimplemented from BHand.
Reimplemented in BHandForceExt, and BHandForceExtKin.
void BHandForce::move | ( | const Motors | motors, | |
const bool | plotIt = false | |||
) | throw (BHandException) |
Moves vereryone of the motors to its desired position.
If the Hand is not in RTMode it will be started. If the hand is already in RTMode and RTMode was set for different motors than the parameter given to this command. is probably will fail.
motors | Motors to move. |
Reimplemented in BHandForceExt.
void BHandForce::moveForce | ( | const Motors | motors, | |
int | force[3] | |||
) | throw (BHandException) |
Moves (closes) the fingers until the finger is not moving or the limit force is reached.
motors | Motors to be Moved. If spread is included it will be ignored. | |
force | Force which should be applied to finger tips. |
void BHandForce::moveForce | ( | const Motors | motors | ) | throw (BHandException) |
Moves (closes) the fingers until the finger is not moving or the limit force is reached.
As force linit force maxForce (of each finger) is used.
motors | Motors to be Moved. If spread is included it will be ignored. |
void BHandForce::openFingers | ( | const Motors | motors | ) | throw (BHandException) [inline] |
Opens the fingers of the BarrettHand.
Stops motion if force limit is reached. Spread motor is ignored by this command.
motors | Fingers to be moved. If paramter contains spread, it will be ignored. |
void BHandForce::openSpread | ( | ) | throw (BHandException) [inline] |
Moves Spread to open Position.
Any force limits are ignored by this command
Here is the call graph for this function:
void BHandForce::resetDeltaPos | ( | ) | [inline, protected] |
Resets the DeltaPos value in the feedbackblock for all Motors to zero.
void BHandForce::setMaxForce | ( | const short | force, | |
const Motors | motors = FINGERS | |||
) |
Sets the maximal allowed force for the given fingers.
The positive froce is the force in open direction.
motors | Fingers for which the minimum force should be set. (Spread joint has no force sensor). | |
force | The value of maximal allowed force. |
void BHandForce::setMaxPosErrorF | ( | const int | error | ) | [inline] |
Set the maximal allowed error for finger positioning.
error | Maximal position error. Unit: MotorCounts |
void BHandForce::setMaxPosErrorS | ( | const int | error | ) | [inline] |
Set the maximal allowed error for spread positioning.
error | Maximal position error. Unit: MotorCounts |
void BHandForce::setMinForce | ( | const short | force, | |
const Motors | motors = FINGERS | |||
) |
Sets the minimal allowed force for the given fingers.
The minmum foce is the force in close direction.
motors | Fingers for which the minimum force should be set. (Spread joint has no force sensor). | |
force | The value of minimal allowed force. |
void BHandForce::setPos | ( | const Motors | motors, | |
const int | position | |||
) |
Sets the desired positions.
Sets the positoin to wich the motor should be moved by the nect move(const Motors motors) command.
motors | Motors to be moved | |
position | position for the motors. Unit: MotorCounts |
void BHandForce::setPropGain | ( | const Motors | motors, | |
const unsigned short | gain | |||
) |
Sets the proportional gain vlaue.
The velocity of a mvement is calculated by speed * gain * LoopCtrlCoeff. So this parameter has dircetly an influence on the speed. The gain value is only used by the moveG() function
motors | Motors for which the gain value should be set | |
gain | Gain value for the motors |
void BHandForce::setRTDefaults | ( | ) |
Sets the default parameters for real time mode.
The default parameter for rtMode are: setParam(ALL, LOOP_CTRL_PROP_GAIN, 0);
setParam(ALL, LOOP_CTRL_VEL_COEFF, LoopCtrlCoeff);
setParam(ALL, LOOP_CTRL_VEL, 1);
setParam(FINGERS, LOOP_FEEDBACK_STRAIN, 1);
setParam(ALL, LOOP_FEEDBACK_ABS_POS, 1);
setParam(ALL, LOOP_FEEDBACK_VEL, 0);
setParam(ALL, LOOP_FEEDBACK_DELTA_POS, 0);
setGlobalParam(LOOP_FEEDBACK_TEMP,1);
void BHandForce::setRTForceDefaults | ( | ) |
Sets the default parameters for force red mode.
void BHandForce::setSpeed | ( | const Motors | motors, | |
const int | speed | |||
) |
Sets speed value for desired finger/spread.
Sets the speed value for the corresponding finger(s)/spread.
motors | Motors for which the value should be set. | |
speed | Speed for motors. |
void BHandForce::setVelCoeff | ( | const Motors | motors, | |
const unsigned short | coeff | |||
) | [inline] |
Sets the LoopCtrlCoeff.
The velocity of a mvement is calculated by speed * gain * LoopCtrlCoeff. So this parameter has dircetly an influence on the speed.
WARNING : Because this parameter directly has an influence on the speed of a motor movement you would have to readjust the controller of the affected motors, otherwise you will probbably get osscilation.
motors | Motors for which the gain value should be set | |
coeff | Value for LoopCtrlCoeff. SHould be in Range form 1 to 255 |
Here is the call graph for this function:
ControlBlock BHandForce::Cb [protected] |
Control block for realtime mode
FeedbackBlock BHandForce::Fb [protected] |
Feedback block for realtime mode
unsigned short BHandForce::LoopCtrlCoeff [protected] |
Loop control velocity coefficent. LOOP_CTRL_VEL_COEFF
int BHandForce::MaxPosErrorFinger [protected] |
Maximal allowed error for finger position
int BHandForce::MaxPosErrorSpread [protected] |
Maximal allowed error for spread position
MoveStruct* BHandForce::MoveParams [protected] |
Container for movement parameters of Barretthand
RTFlags BHandForce::RealTimeFlags [protected] |
The state of the real time mode.
![]() |
Generated Wed Aug 16 14:58:54 2006 by
![]() |