19#include <yarp/os/SystemClock.h>
20#include <yarp/sig/Vector.h>
21#include <yarp/math/Math.h>
27using namespace yarp::os;
28using namespace yarp::sig;
29using namespace yarp::math;
86 Vector q0,qf,qhat,xf,
xhat;
113 qf.resize(chain->
getDOF());
114 for (
unsigned int i=0; i<chain->
getDOF(); i++)
116 double min=(*chain)(i).getMin();
117 double max=(*chain)(i).getMax();
131 cout <<
"Actual joints set to " << (
CTRL_RAD2DEG*qf).toString() << endl;
137 cout <<
"Torso blocked links at:" << endl;
138 for (
unsigned int i=0; i<chain->
getN()-chain->
getDOF(); i++)
143 cout <<
"Unblocking the first torso joint... ";
145 cout << chain->
getDOF() <<
" DOFs available" << endl;
146 cout <<
"Blocking the first torso joint again... ";
148 cout << chain->
getDOF() <<
" DOFs available" << endl;
154 cout <<
"Current arm end-effector pose: " << xf.toString() << endl;
170 for (
unsigned int i=0; i<chain->
getN(); i++)
172 cout <<
"link " << i <<
": " <<
173 (chain->
getConstraint(i)?
"constrained":
"not-constrained") << endl;
177 double t=SystemClock::nowSystem();
179 double dt=SystemClock::nowSystem()-t;
183 cout <<
"qhat: " << (
CTRL_RAD2DEG*qhat).toString() << endl;
189 cout <<
"Desired arm end-effector pose xf= " << xf.toString() << endl;
190 cout <<
"Achieved arm end-effector pose K(qhat)= " <<
xhat.toString() << endl;
191 cout <<
"||xf-K(qhat)||=" <<
norm(xf-
xhat) << endl;
192 cout <<
"Solved in " << dt <<
" [s]" << endl;
virtual void allocate(const string &_type)
A class for defining the iCub Arm.
A Base class for defining a Serial Link Chain.
bool releaseLink(const unsigned int i)
Releases the ith Link.
yarp::sig::Vector EndEffPose(const bool axisRep=true)
Returns the coordinates of end-effector.
yarp::sig::Vector getAng()
Returns the current free joint angles values.
yarp::sig::Vector setAng(const yarp::sig::Vector &q)
Sets the free joint angles to values of q[i].
bool getConstraint(unsigned int i)
Returns the constraint status of ith link.
unsigned int getN() const
Returns the number of Links belonging to the Chain.
unsigned int getDOF() const
Returns the current number of Chain's DOF.
bool blockLink(const unsigned int i, double Ang)
Blocks the ith Link at the a certain value of its joint angle.
bool setH0(const yarp::sig::Matrix &_H0)
Sets H0, the rigid roto-translation matrix from the root reference frame to the 0th frame.
Class for inverting chain's kinematics based on IpOpt lib.
void setUserScaling(const bool useUserScaling, const double _obj_scaling, const double _x_scaling, const double _g_scaling)
Enables/disables user scaling factors.
virtual yarp::sig::Vector solve(const yarp::sig::Vector &q0, yarp::sig::Vector &xd, double weight2ndTask, yarp::sig::Vector &xd_2nd, yarp::sig::Vector &w_2nd, double weight3rdTask, yarp::sig::Vector &qd_3rd, yarp::sig::Vector &w_3rd, int *exit_code=NULL, bool *exhalt=NULL, iKinIterateCallback *iterate=NULL)
Executes the IpOpt algorithm trying to converge on target.
A class for defining generic Limb.
void pushLink(iKinLink &l)
iKinChain * asChain()
Returns a pointer to the Limb seen as Chain object.
A Base class for defining a Link with standard Denavit-Hartenberg convention.
double norm(const yarp::sig::Matrix &M, int col)
Returns the norm of the vector given in the form: matrix(:,col).
#define IKINCTRL_POSE_FULL
constexpr double CTRL_RAD2DEG
180/PI.
constexpr double CTRL_DEG2RAD
PI/180.