11#include <yarp/math/Math.h>
18using namespace yarp::os;
19using namespace yarp::sig;
20using namespace yarp::math;
28 Bottle &part=b.addList();
30 Bottle &vect=part.addList();
32 for (
size_t i=0; i<v.length(); i++)
33 vect.addFloat64(v[i]);
39 Vector &odhat, Vector &qdhat)
54 for (
size_t i=0; i<xdhat.length(); i++)
55 xdhat[i]=xData->get(i).asFloat64();
58 for (
size_t i=0; i<odhat.length(); i++)
59 odhat[i]=xData->get(xdhat.length()+i).asFloat64();
71 qdhat.resize(qData->size());
72 for (
size_t i=0; i<qdhat.length(); i++)
73 qdhat[i]=qData->get(i).asFloat64();
116 Bottle &posePart=b.addList();
129 Bottle &modePart=b.addList();
142 Bottle &tokenPart=b.addList();
144 tokenPart.addFloat64(token);
187 Matrix HL=eyeL.
getH();
188 Matrix HR=eyeR.
getH();
191 double qty1=
dot(HR,2,HL,2);
193 Matrix H2L=HL-qty1*HR;
194 Matrix H2R=qty1*HL-HR;
195 double qty2L=
dot(H2L,2,H1,3);
196 double qty2R=
dot(H2R,2,H1,3);
197 double qty3=qty1*qty1-1.0;
202 double tL=qty2L/qty3;
203 double tR=qty2R/qty3;
208 for (
int i=0; i<3; i++)
209 fp[i]=0.5*(HL(i,3)+tL*HL(i,2)+HR(i,3)+tR*HR(i,2));
218 Vector &
fp, Matrix &J)
220 Vector dfp1(4), dfp2(4);
221 Vector dfpL1(4),dfpL2(4);
222 Vector dfpR1(4),dfpR2(4);
224 Matrix HL=eyeL.
getH();
225 Matrix HR=eyeR.
getH();
228 double qty1=
dot(HR,2,HL,2);
230 Matrix H2L=HL-qty1*HR;
231 Matrix H2R=qty1*HL-HR;
232 Matrix H3(4,4); H3(3,2)=0.0;
233 double qty2L=
dot(H2L,2,H1,3);
234 double qty2R=
dot(H2R,2,H1,3);
235 double qty3=qty1*qty1-1.0;
240 double tL=qty2L/qty3;
241 double tR=qty2R/qty3;
250 double dqty1, dqty1L, dqty1R;
251 double dqty2, dqty2L, dqty2R;
254 Vector Hz=HL.getCol(2);
255 Matrix M=GeoJacobP_L.submatrix(0,3,0,1)+tL*AnaJacobZ_L.submatrix(0,3,0,1);
259 dqty1=
dot(AnaJacobZ_R,j,HL,2)+
dot(HR,2,AnaJacobZ_L,j);
260 for (
int i=0; i<3; i++)
261 H3(i,2)=AnaJacobZ_L(i,j)-dqty1*HR(i,2)-qty1*AnaJacobZ_R(i,j);
262 dqty2=
dot(H3,2,H1,3)+
dot(H2L,2,GeoJacobP_L-GeoJacobP_R,j);
263 dfp1=M.getCol(j)+Hz*((dqty2-2.0*qty1*qty2L*dqty1/qty3)/qty3);
267 dqty1L=
dot(HR,2,AnaJacobZ_L,j);
268 for (
int i=0; i<3; i++)
269 H3(i,2)=AnaJacobZ_L(i,j)-dqty1*HR(i,2);
270 dqty2L=
dot(H3,2,H1,3)+
dot(H2L,2,GeoJacobP_L,j);
271 dfpL1=M.getCol(j)+Hz*((dqty2L-2.0*qty1*qty2L*dqty1L/qty3)/qty3);
274 dqty1R=
dot(AnaJacobZ_R,j,HL,2);
275 for (
int i=0; i<3; i++)
276 H3(i,2)=-dqty1*HR(i,2)-qty1*AnaJacobZ_R(i,j);
277 dqty2R=
dot(H3,2,H1,3)+
dot(H2L,2,-1.0*GeoJacobP_R,j);
278 dfpR1=Hz*((dqty2R-2.0*qty1*qty2L*dqty1R/qty3)/qty3);
283 double dqty1, dqty1L, dqty1R;
284 double dqty2, dqty2L, dqty2R;
287 Vector Hz=HR.getCol(2);
288 Matrix M=GeoJacobP_R.submatrix(0,3,0,1)+tR*AnaJacobZ_R.submatrix(0,3,0,1);
292 dqty1=
dot(AnaJacobZ_R,j,HL,2)+
dot(HR,2,AnaJacobZ_L,j);
293 for (
int i=0; i<3; i++)
294 H3(i,2)=qty1*AnaJacobZ_L(i,j)+dqty1*HL(i,2)-AnaJacobZ_R(i,j);
295 dqty2=
dot(H3,2,H1,3)+
dot(H2R,2,GeoJacobP_L-GeoJacobP_R,j);
296 dfp2=M.getCol(j)+Hz*((dqty2-2.0*qty1*qty2R*dqty1/qty3)/qty3);
300 dqty1L=
dot(HR,2,AnaJacobZ_L,j);
301 for (
int i=0; i<3; i++)
302 H3(i,2)=qty1*AnaJacobZ_L(i,j)+dqty1L*HL(i,2);
303 dqty2L=
dot(H3,2,H1,3)+
dot(H2R,2,GeoJacobP_L,j);
304 dfpL2=Hz*((dqty2L-2.0*qty1*qty2R*dqty1L/qty3)/qty3);
307 dqty1R=
dot(AnaJacobZ_R,j,HL,2);
308 for (
int i=0; i<3; i++)
309 H3(i,2)=dqty1R*HL(i,2)-AnaJacobZ_R(i,j);
310 dqty2R=
dot(H3,2,H1,3)+
dot(H2R,2,-1.0*GeoJacobP_R,j);
311 dfpR2=M.getCol(j)+Hz*((dqty2R-2.0*qty1*qty2R*dqty1R/qty3)/qty3);
317 if ((J.rows()!=3) || (J.cols()!=3))
320 for (
int i=0; i<3; i++)
323 fp[i]=0.5*(HL(i,3)+tL*HL(i,2)+HR(i,3)+tR*HR(i,2));
329 J(i,0)=0.50*(dfp1[i] + dfp2[i]);
330 J(i,1)=0.50*(dfpL1[i]+dfpR1[i] + dfpL2[i]+dfpR2[i]);
331 J(i,2)=0.25*(dfpL1[i]-dfpR1[i] + dfpL2[i]-dfpR2[i]);
static yarp::os::Bottle * getEndEffectorPoseOption(const yarp::os::Bottle &b)
Retrieves the end-effector pose data.
static void addVectorOption(yarp::os::Bottle &b, const int vcb, const yarp::sig::Vector &v)
static yarp::os::Bottle * getJointsOption(const yarp::os::Bottle &b)
Retrieves the joints configuration data.
static yarp::os::Bottle * getTargetOption(const yarp::os::Bottle &b)
Retrieves commanded target data from a bottle.
static void addModeOption(yarp::os::Bottle &b, const bool tracking)
Appends to a bottle all data needed to change the tracking mode.
static bool computeFixationPointData(iKinChain &eyeL, iKinChain &eyeR, yarp::sig::Vector &fp)
Retrieves current fixation point given the current kinematics configuration of the eyes.
static void addTargetOption(yarp::os::Bottle &b, const yarp::sig::Vector &xd)
Appends to a bottle all data needed to command a target.
static void addJointsResPosOption(yarp::os::Bottle &b, const yarp::sig::Vector &restPos)
Appends to a bottle all data needed to modify joints rest position.
static void addDOFOption(yarp::os::Bottle &b, const yarp::sig::Vector &dof)
Appends to a bottle all data needed to reconfigure chain's dof.
static bool getDesiredOption(const yarp::os::Bottle &reply, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
static bool getTokenOption(const yarp::os::Bottle &b, double *token)
Retrieves the token from the bottle.
static void addJointsRestWeightsOption(yarp::os::Bottle &b, const yarp::sig::Vector &restWeights)
Appends to a bottle all data needed to modify joints rest weights.
static void addTokenOption(yarp::os::Bottle &b, const double token)
Appends to a bottle a token to be exchanged with the solver.
static void addPoseOption(yarp::os::Bottle &b, const unsigned int pose)
Appends to a bottle all data needed to change the pose mode.
A Base class for defining a Serial Link Chain.
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...
yarp::sig::Matrix GeoJacobian(const unsigned int i)
Returns the geometric Jacobian of the ith link.
yarp::sig::Matrix AnaJacobian(const unsigned int i, unsigned int col)
Returns the analitical Jacobian of the ith link.
double dot(const yarp::sig::Matrix &A, int colA, const yarp::sig::Matrix &B, int colB)
Returns the dot product between two vectors given in the form: matrix(:,col).
#define IKINCTRL_POSE_FULL
#define IKINCTRL_POSE_XYZ
#define IKINSLV_VOCAB_OPT_DOF
#define IKINSLV_VOCAB_VAL_POSE_FULL
#define IKINSLV_VOCAB_VAL_MODE_TRACK
#define IKINSLV_VOCAB_VAL_MODE_SINGLE
#define IKINSLV_VOCAB_OPT_POSE
#define IKINSLV_VOCAB_OPT_Q
#define IKINSLV_VOCAB_OPT_MODE
#define IKINSLV_VOCAB_REP_ACK
#define IKINSLV_VOCAB_OPT_TOKEN
#define IKINSLV_VOCAB_OPT_REST_POS
#define IKINSLV_VOCAB_VAL_POSE_XYZ
#define IKINSLV_VOCAB_OPT_REST_WEIGHTS
#define IKINSLV_VOCAB_OPT_X
#define IKINSLV_VOCAB_OPT_XD
static struct bpf_program fp