iCub-main
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
iCub::iKin::SteepCtrl Class Reference

A class derived from iKinCtrl implementing two standard algorithms based on steepest descent qdot=-Kp*grad. More...

#include <iKinInv.h>

+ Inheritance diagram for iCub::iKin::SteepCtrl:

Public Member Functions

 SteepCtrl (iKinChain &c, unsigned int _type, unsigned int _ctrlPose, double _Ts, double _Kp)
 Constructor. More...
 
virtual yarp::sig::Vector computeGPM ()
 Returns the further contribution to the qdot=pinvJ*xdot equation according to the Gradient Projection Method, i.e. More...
 
virtual void setChainConstraints (bool _constrained)
 Enables/Disables joint angles constraints. More...
 
virtual yarp::sig::Vector iterate (yarp::sig::Vector &xd, const unsigned int verbose=0)
 Executes one iteration of the control algorithm. More...
 
virtual void restart (const yarp::sig::Vector &q0)
 Reinitializes the algorithm's internal state and resets the starting point. More...
 
virtual bool test_convergence (const double tol_size)
 Tests convergence by comparing the size of the algorithm internal structure (may be the gradient norm or the simplex size or whatever) to a certain tolerance. More...
 
virtual std::string getAlgoName ()
 Returns the algorithm's name. More...
 
void resetInt ()
 Resets integral status at the current joint angles. More...
 
yarp::sig::Vector get_qdot () const
 Returns the actual derivative of joint angles. More...
 
yarp::sig::Vector get_gpm () const
 Returns the actual value of Gradient Projected. More...
 
double get_Kp () const
 Returns the gain. More...
 
virtual ~SteepCtrl ()
 Destructor. More...
 
- Public Member Functions inherited from iCub::iKin::iKinCtrl
 iKinCtrl (iKinChain &c, unsigned int _ctrlPose)
 Constructor. More...
 
virtual yarp::sig::Vector solve (yarp::sig::Vector &xd, const double tol_size=IKINCTRL_DISABLED, const int max_iter=IKINCTRL_DISABLED, const unsigned int verbose=0, int *exit_code=NULL, bool *exhalt=NULL)
 Iterates the control algorithm trying to converge on the target. More...
 
void switchWatchDog (bool sw)
 Switch on/off the watchDog mechanism to trigger deadLocks. More...
 
virtual void setInTargetTol (double tol_x)
 Sets tolerance for in-target check (5e-3 by default). More...
 
virtual double getInTargetTol () const
 Returns tolerance for in-target check. More...
 
virtual void setWatchDogTol (double tol_q)
 Sets tolerance for watchDog check (1e-4 by default). More...
 
virtual double getWatchDogTol () const
 Returns tolerance for watchDog check. More...
 
virtual void setWatchDogMaxIter (int maxIter)
 Sets maximum number of iterations to trigger the watchDog (200 by default). More...
 
virtual int getWatchDogMaxIter () const
 Returns maximum number of iterations to trigger the watchDog. More...
 
virtual bool isInTarget ()
 Checks if the End-Effector is in target. More...
 
int get_state () const
 Returns the algorithm's state. More...
 
void set_ctrlPose (unsigned int _ctrlPose)
 Sets the state of Pose control settings. More...
 
unsigned int get_ctrlPose () const
 Returns the state of Pose control settings. More...
 
unsigned int get_dim () const
 Returns the number of Chain DOF. More...
 
unsigned int get_iter () const
 Returns the number of performed iterations. More...
 
virtual yarp::sig::Vector get_x () const
 Returns the actual cartesian position of the End-Effector. More...
 
virtual yarp::sig::Vector get_e () const
 Returns the actual cartesian position error. More...
 
virtual void set_q (const yarp::sig::Vector &q0)
 Sets the joint angles values. More...
 
virtual yarp::sig::Vector get_q () const
 Returns the actual joint angles values. More...
 
virtual yarp::sig::Vector get_grad () const
 Returns the actual gradient. More...
 
virtual yarp::sig::Matrix get_J () const
 Returns the actual Jacobian used in computation. More...
 
virtual double dist () const
 Returns the actual distance from the target in cartesian space (euclidean norm is used). More...
 
virtual ~iKinCtrl ()
 Default destructor. More...
 

Protected Member Functions

virtual void inTargetFcn ()
 Method called whenever in target. More...
 
virtual void deadLockRecoveryFcn ()
 Method called whenever the watchDog is triggered. More...
 
virtual void printIter (const unsigned int verbose)
 Dumps warning or status messages. More...
 
virtual yarp::sig::Vector update_qdot ()
 
- Protected Member Functions inherited from iCub::iKin::iKinCtrl
virtual yarp::sig::Vector calc_e ()
 Computes the error according to the current controller settings (complete pose/translational/rotational part). More...
 
virtual void update_state ()
 Updates the control state. More...
 
virtual void watchDog ()
 Handles the watchDog. More...
 
virtual yarp::sig::Vector checkVelocity (const yarp::sig::Vector &_qdot, double _Ts)
 Checks each joint velocity and sets it to zero if it steers the joint out of range. More...
 
unsigned int printHandling (const unsigned int verbose=0)
 Method to be called within the printIter routine inherited by children in order to handle the highest word of verbose integer. More...
 

Protected Attributes

double Ts
 
ctrl::IntegratorI
 
unsigned int type
 
bool constrained
 
double Kp
 
yarp::sig::Vector qdot
 
yarp::sig::Vector gpm
 
- Protected Attributes inherited from iCub::iKin::iKinCtrl
iKinChainchain
 
unsigned int ctrlPose
 
yarp::sig::Vector x_set
 
yarp::sig::Vector x
 
yarp::sig::Vector e
 
yarp::sig::Vector q
 
yarp::sig::Matrix J
 
yarp::sig::Matrix Jt
 
yarp::sig::Matrix pinvJ
 
yarp::sig::Vector grad
 
yarp::sig::Vector q_old
 
double inTargetTol
 
double watchDogTol
 
unsigned int dim
 
unsigned int iter
 
int state
 
bool watchDogOn
 
int watchDogCnt
 
int watchDogMaxIter
 

Detailed Description

A class derived from iKinCtrl implementing two standard algorithms based on steepest descent qdot=-Kp*grad.

1) grad=-Jt*e 2) grad=-pinv(J)*e.

Definition at line 411 of file iKinInv.h.

Constructor & Destructor Documentation

◆ SteepCtrl()

SteepCtrl::SteepCtrl ( iKinChain c,
unsigned int  _type,
unsigned int  _ctrlPose,
double  _Ts,
double  _Kp 
)

Constructor.

Parameters
cis the Chain object on which the control operates. Do not change Chain DOF from this point onwards!!
_typeone of the following: IKINCTRL_STEEP_JT => implements J transposed method. IKINCTRL_STEEP_PINV => implements J pseudo-inverse method.
_ctrlPoseone of the following: IKINCTRL_POSE_FULL => complete pose control. IKINCTRL_POSE_XYZ => translational part of pose controlled. IKINCTRL_POSE_ANG => rotational part of pose controlled.
_Tsis the controller sample time.
_Kpis constant gain.

Definition at line 270 of file iKinInv.cpp.

◆ ~SteepCtrl()

SteepCtrl::~SteepCtrl ( )
virtual

Destructor.

Definition at line 406 of file iKinInv.cpp.

Member Function Documentation

◆ computeGPM()

virtual yarp::sig::Vector iCub::iKin::SteepCtrl::computeGPM ( )
inlinevirtual

Returns the further contribution to the qdot=pinvJ*xdot equation according to the Gradient Projection Method, i.e.

qdot=pinvJ*xdot+(I-pinvJ*J)*w

Returns
shall return the quantity (I-pinvJ*J)*w.
Note
This method shall be inherited and handled accordingly (here a vector of 0s is returned). To do that, J and pinvJ are already computed when this method is called.

Definition at line 464 of file iKinInv.h.

◆ deadLockRecoveryFcn()

virtual void iCub::iKin::SteepCtrl::deadLockRecoveryFcn ( )
inlineprotectedvirtual

Method called whenever the watchDog is triggered.

Put here the code to recover from deadLock. Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Definition at line 433 of file iKinInv.h.

◆ get_gpm()

yarp::sig::Vector iCub::iKin::SteepCtrl::get_gpm ( ) const
inline

Returns the actual value of Gradient Projected.

Returns
the actual value of Gradient Projected.

Definition at line 487 of file iKinInv.h.

◆ get_Kp()

double iCub::iKin::SteepCtrl::get_Kp ( ) const
inline

Returns the gain.

Returns
the gain.

Definition at line 493 of file iKinInv.h.

◆ get_qdot()

yarp::sig::Vector iCub::iKin::SteepCtrl::get_qdot ( ) const
inline

Returns the actual derivative of joint angles.

Returns
the actual derivative of joint angles.

Definition at line 481 of file iKinInv.h.

◆ getAlgoName()

virtual std::string iCub::iKin::SteepCtrl::getAlgoName ( )
inlinevirtual

Returns the algorithm's name.

Returns
algorithm name as string. Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Reimplemented in iCub::iKin::VarKpSteepCtrl.

Definition at line 470 of file iKinInv.h.

◆ inTargetFcn()

virtual void iCub::iKin::SteepCtrl::inTargetFcn ( )
inlineprotectedvirtual

Method called whenever in target.

Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Reimplemented in iCub::iKin::VarKpSteepCtrl.

Definition at line 432 of file iKinInv.h.

◆ iterate()

Vector SteepCtrl::iterate ( yarp::sig::Vector &  xd,
const unsigned int  verbose = 0 
)
virtual

Executes one iteration of the control algorithm.

Parameters
xdis the End-Effector target Pose to be tracked.
verboseis a integer whose 32 bits are intended as follows. The lowest word (16 bits) progressively enables different levels of warning messages or status dump: the larger this value the more detailed is the output (0x####0000=>off by default). The highest word indicates how many successive calls to the dump shall be skipped in order to reduce the amount of information on the screen (ex: 0x0000####=>print all iterations, 0x0001####=>print one iteration and skip the next one, 0x0002####=> print one iteration and skip the next two).
Returns
current estimation of joints configuration. Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Definition at line 312 of file iKinInv.cpp.

◆ printIter()

void SteepCtrl::printIter ( const unsigned int  verbose)
protectedvirtual

Dumps warning or status messages.

Parameters
verboseis a integer whose 32 bits are intended as follows. The lowest word (16 bits) progressively enables different levels of warning messages or status dump: the larger this value the more detailed is the output (0x####0000=>off by default). The highest word indicates how many successive calls to the dump shall be skipped in order to reduce the amount of information on the screen (ex: 0x0000####=>print all iterations, 0x0001####=>print one iteration and skip the next one, 0x0002####=> print one iteration and skip the next two).
Note
Angles are dumperd as degrees. Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Definition at line 372 of file iKinInv.cpp.

◆ resetInt()

void iCub::iKin::SteepCtrl::resetInt ( )
inline

Resets integral status at the current joint angles.

Definition at line 475 of file iKinInv.h.

◆ restart()

void SteepCtrl::restart ( const yarp::sig::Vector &  q0)
virtual

Reinitializes the algorithm's internal state and resets the starting point.

Parameters
q0is the new starting point.

Reimplemented from iCub::iKin::iKinCtrl.

Reimplemented in iCub::iKin::VarKpSteepCtrl.

Definition at line 363 of file iKinInv.cpp.

◆ setChainConstraints()

void SteepCtrl::setChainConstraints ( bool  _constrained)
virtual

Enables/Disables joint angles constraints.

Parameters
_constrainedif true then constraints are applied.

Reimplemented from iCub::iKin::iKinCtrl.

Definition at line 293 of file iKinInv.cpp.

◆ test_convergence()

virtual bool iCub::iKin::SteepCtrl::test_convergence ( const double  tol_size)
inlinevirtual

Tests convergence by comparing the size of the algorithm internal structure (may be the gradient norm or the simplex size or whatever) to a certain tolerance.

Parameters
tol_sizeis tolerance to compare to. Shall be implemented.

Implements iCub::iKin::iKinCtrl.

Definition at line 469 of file iKinInv.h.

◆ update_qdot()

Vector SteepCtrl::update_qdot ( )
protectedvirtual

Reimplemented in iCub::iKin::VarKpSteepCtrl.

Definition at line 303 of file iKinInv.cpp.

Member Data Documentation

◆ constrained

bool iCub::iKin::SteepCtrl::constrained
protected

Definition at line 426 of file iKinInv.h.

◆ gpm

yarp::sig::Vector iCub::iKin::SteepCtrl::gpm
protected

Definition at line 430 of file iKinInv.h.

◆ I

ctrl::Integrator* iCub::iKin::SteepCtrl::I
protected

Definition at line 423 of file iKinInv.h.

◆ Kp

double iCub::iKin::SteepCtrl::Kp
protected

Definition at line 428 of file iKinInv.h.

◆ qdot

yarp::sig::Vector iCub::iKin::SteepCtrl::qdot
protected

Definition at line 429 of file iKinInv.h.

◆ Ts

double iCub::iKin::SteepCtrl::Ts
protected

Definition at line 422 of file iKinInv.h.

◆ type

unsigned int iCub::iKin::SteepCtrl::type
protected

Definition at line 425 of file iKinInv.h.


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