22 #include <yarp/math/SVD.h>
29 const Vector &_counterRotGain,
const unsigned int _period) :
30 PeriodicThread((double)_period/1000.0), drvTorso(_drvTorso), drvHead(_drvHead),
31 commData(_commData), ctrl(_ctrl), period(_period),
32 Ts(_period/1000.0), counterRotGain(_counterRotGain)
76 IEncoders *encTorso;
drvTorso->view(encTorso);
82 IEncoders *encHead;
drvHead->view(encHead);
91 lim=
lim.submatrix(3,5,0,1);
138 lock_guard<mutex> lck(
mtx);
148 lock_guard<mutex> lck(
mtx);
164 lim(2,0)=
lim(2,1)=ver_rad;
184 lock_guard<mutex> lck(
mtx);
201 yInfo(
"eyes cleared");
220 lock_guard<mutex> lck(
mtx);
228 lock_guard<mutex> lck(
mtx);
230 for (
size_t i=0; i<len; i++)
232 yInfo(
"counter-rotation gains set to (%s)",
counterRotGain.toString(3,3).c_str());
260 HN.setSubcol(fph,0,3);
264 ocr_fprelv=ocr_fprelv.subVector(0,2);
275 yInfo(
"Starting Pseudoinverse Reference Generator at %d ms",
period);
294 yInfo(
"Pseudoinverse Reference Generator started successfully");
296 yError(
"Pseudoinverse Reference Generator did not start!");
305 lock_guard<mutex> lck(
mtx);
326 Vector fph=xd; fph.push_back(1.0);
332 ang[0]=-atan2(fph[1],fabs(fph[2]));
333 ang[1]=atan2(fph[0],fph[2]);
347 axis[0]=1.0; axis[1]=0.0; axis[2]=0.0; axis[3]=-ang[0];
348 fph=axis2dcm(axis)*fph;
446 PeriodicThread::suspend();
447 yInfo(
"Pseudoinverse Reference Generator has been suspended!");
454 PeriodicThread::resume();
455 yInfo(
"Pseudoinverse Reference Generator has been resumed!");
462 const unsigned int _period) :
463 PeriodicThread((double)_period/1000.0), drvTorso(_drvTorso), drvHead(_drvHead),
464 commData(_commData), eyesRefGen(_eyesRefGen), loc(_loc),
465 ctrl(_ctrl), period(_period), Ts(_period/1000.0)
503 IEncoders *encTorso;
drvTorso->view(encTorso);
509 IEncoders *encHead;
drvHead->view(encHead);
571 lock_guard<mutex> lck(
mtx);
575 (*chainNeck)(0).setMin(min_rad);
576 (*chainNeck)(0).setMax(max_rad);
578 yInfo(
"neck pitch constrained in [%g,%g] deg",min_deg,max_deg);
585 lock_guard<mutex> lck(
mtx);
589 (*chainNeck)(1).setMin(min_rad);
590 (*chainNeck)(1).setMax(max_rad);
592 yInfo(
"neck roll constrained in [%g,%g] deg",min_deg,max_deg);
599 lock_guard<mutex> lck(
mtx);
603 (*chainNeck)(2).setMin(min_rad);
604 (*chainNeck)(2).setMax(max_rad);
606 yInfo(
"neck yaw constrained in [%g,%g] deg",min_deg,max_deg);
613 lock_guard<mutex> lck(
mtx);
622 lock_guard<mutex> lck(
mtx);
631 lock_guard<mutex> lck(
mtx);
640 lock_guard<mutex> lck(
mtx);
644 yInfo(
"neck pitch cleared");
651 lock_guard<mutex> lck(
mtx);
655 yInfo(
"neck roll cleared");
662 lock_guard<mutex> lck(
mtx);
666 yInfo(
"neck yaw cleared");
700 Vector xdh=xd; xdh.push_back(1.0);
701 xdh=SE3inv(
H)*xdh; xdh[3]=0.0;
711 Vector
z(3,0.0);
z[2]=1.0;
712 Vector xdh=xd; xdh.push_back(1.0);
715 Vector xdh3=xdh; xdh3.pop_back();
723 rot=
H*(axis2dcm(rot)*xdh);
751 yInfo(
"Starting Solver at %d ms",
period);
767 yInfo(
"Solver started successfully");
769 yError(
"Solver did not start!");
776 typedef enum { ctrl_off, ctrl_wait, ctrl_on } cstate;
777 static cstate state_=ctrl_off;
779 lock_guard<mutex> lck(
mtx);
829 Vector gDir(3,0.0); gDir[2]=-1.0;
834 gDir=
H.submatrix(0,2,0,2)*
acc;
849 if (state_==ctrl_off)
858 else if (state_==ctrl_wait)
863 else if (state_==ctrl_on)
875 PeriodicThread::suspend();
876 yInfo(
"Solver has been suspended!");
883 lock_guard<mutex> lck(
mtx);
902 PeriodicThread::resume();
903 yInfo(
"Solver has been resumed!");
bool look(const Vector &x)
void doSaccade(const Vector &ang, const Vector &vel)
ResourceFinder rf_cameras
double saccadesActivationAngle
std::pair< Vector, bool > get_gyro()
void set_fpFrame(const Matrix &_S)
void set_xd(const Vector &_xd)
double gyro_noise_threshold
void set_qd(const Vector &_qd)
void set_q(const Vector &_q)
double saccadesInhibitionPeriod
std::pair< Vector, bool > get_accel()
void resize_counterv(const int sz, const double val)
double minAllowedVergence
void resize_v(const int sz, const double val)
iKinLimbVersion head_version
void set_x(const Vector &_x)
void set_counterv(const Vector &_counterv)
void set_torso(const Vector &_torso)
void minAllowedVergenceChanged() override
EyePinvRefGen(PolyDriver *_drvTorso, PolyDriver *_drvHead, ExchangeData *_commData, Controller *_ctrl, const Vector &_counterRotGain, const unsigned int _period)
Vector getCounterRotGain()
void afterStart(bool s) override
void manageBindEyes(const double ver)
bool bindEyes(const double ver)
void threadRelease() override
bool threadInit() override
Vector getEyesCounterVelocity(const Matrix &eyesJ, const Vector &fp)
void setCounterRotGain(const Vector &gain)
Vector solve(const Vector &q0, Vector &xd, const Vector &gDir)
Solver(PolyDriver *_drvTorso, PolyDriver *_drvHead, ExchangeData *_commData, EyePinvRefGen *_eyesRefGen, Localizer *_loc, Controller *_ctrl, const unsigned int _period)
void threadRelease() override
void bindNeckPitch(const double min_deg, const double max_deg)
void getCurNeckYawRange(double &min_deg, double &max_deg)
bool threadInit() override
void getCurNeckPitchRange(double &min_deg, double &max_deg)
EyePinvRefGen * eyesRefGen
Vector computeTargetUserTolerance(const Vector &xd)
double getNeckAngleUserTolerance() const
double neckTargetRotAngle(const Vector &xd)
void bindNeckYaw(const double min_deg, const double max_deg)
double neckAngleUserTolerance
void setNeckAngleUserTolerance(const double angle)
void getCurNeckRollRange(double &min_deg, double &max_deg)
void afterStart(bool s) override
AWLinEstimator * torsoVel
void bindNeckRoll(const double min_deg, const double max_deg)
Adaptive window linear fitting to estimate the first derivative.
Basic element for adaptive polynomial fitting.
yarp::sig::Vector estimate()
Execute the algorithm upon the elements list, with the max deviation threshold given by D.
void feedData(const AWPolyElement &el)
Feed data into the algorithm.
void reset()
Reinitialize the internal state.
A class for defining a saturated integrator based on Tustin formula: .
const yarp::sig::Vector & integrate(const yarp::sig::Vector &x)
Executes one-step integration of input vector.
void reset(const yarp::sig::Vector &y0)
Resets the internal state and sets the output vector to the given value.
void setLim(const yarp::sig::Matrix &_lim)
Sets the output vector constraints matrix.
A class for defining the iCub Eye.
A class for describing the kinematic of the straight line coming out from the point located between t...
A class for defining the Inertia Sensor Kinematics of the iCub.
yarp::sig::Matrix getH(const unsigned int i, const bool allLink=false)
Returns the rigid roto-translation matrix from the root reference frame to the ith frame in Denavit-H...
bool setHN(const yarp::sig::Matrix &_HN)
Sets HN, the rigid roto-translation matrix from the Nth frame to the end-effector.
yarp::sig::Matrix GeoJacobian(const unsigned int i)
Returns the geometric Jacobian of the ith link.
yarp::sig::Vector EndEffPose(const bool axisRep=true)
Returns the coordinates of end-effector.
yarp::sig::Vector setAng(const yarp::sig::Vector &q)
Sets the free joint angles to values of q[i].
bool blockLink(const unsigned int i, double Ang)
Blocks the ith Link at the a certain value of its joint angle.
void setAllConstraints(bool _constrained)
Sets the constraint status of all chain links.
std::string get_version() const
Return the version string.
iKinChain * asChain()
Returns a pointer to the Limb seen as Chain object.
void init(const Vector &xd0)
double norm(const yarp::sig::Matrix &M, int col)
Returns the norm of the vector given in the form: matrix(:,col).
yarp::sig::Vector cross(const yarp::sig::Matrix &A, int colA, const yarp::sig::Matrix &B, int colB)
Returns the cross product between two vectors given in the form: matrix(:,col).
void copyJointsBounds(iKinChain *ch1, iKinChain *ch2)
bool getAlignHN(const ResourceFinder &rf, const string &type, iKinChain *chain, const bool verbose=false)
bool getFeedback(Vector &fbTorso, Vector &fbHead, PolyDriver *drvTorso, PolyDriver *drvHead, const ExchangeData *commData, double *timeStamp=nullptr)
void updateNeckBlockedJoints(iKinChain *chain, const Vector &fbNeck)
void updateTorsoBlockedJoints(iKinChain *chain, const Vector &fbTorso)
Matrix alignJointsBounds(iKinChain *chain, PolyDriver *drvTorso, PolyDriver *drvHead, const ExchangeData *commData)
double sat(const double val, const double min, const double max)
static struct bpf_program fp
constexpr double NECKSOLVER_ACTIVATIONANGLE_JOINTS
constexpr double SACCADES_VEL
constexpr double EYEPINVREFGEN_GAIN
constexpr double NECKSOLVER_ACTIVATIONANGLE