24 LibInstantiated =
true;
32 LibInstantiated =
true;
33 std::vector<double> thetaw, dw, aw, alphaw;
34 for (
int i = 0; i < theta->
length; ++i) {
35 thetaw.push_back(theta->
data[i]);
36 dw.push_back(d->
data[i]);
37 aw.push_back(a->
data[i]);
38 alphaw.push_back(alpha->
data[i]);
40 int ok = _kinematics->
setMDH(thetaw, dw, aw, alphaw, typeNr);
41 int error = (ok < 0) ? -1 : 0;
48 std::vector<double> fw;
49 for (
int i = 0; i < links->
length; ++i) {
50 fw.push_back(links->
data[i]);
53 int error = (ok < 0) ? -1 : 0;
60 int ok = _kinematics->
setImmob(immobile);
61 int error = (ok < 0) ? -1 : 0;
69 for (
int i = 0; i < epc->
length; ++i) {
70 iw.push_back(epc->
data[i]);
72 int ok = _kinematics->
setEPC(iw);
73 int error = (ok < 0) ? -1 : 0;
81 for (
int i = 0; i < encOffset->
length; ++i) {
82 iw.push_back(encOffset->
data[i]);
85 int error = (ok < 0) ? -1 : 0;
93 for (
int i = 0; i < rotDir->
length; ++i) {
94 iw.push_back(rotDir->
data[i]);
97 int error = (ok < 0) ? -1 : 0;
102 if (!LibInstantiated)
104 std::vector<double> fw;
105 for (
int i = 0; i < angleOffset->
length; ++i) {
106 fw.push_back(angleOffset->
data[i]);
109 int error = (ok < 0) ? -1 : 0;
114 if (!LibInstantiated)
117 std::vector<double> fw;
118 for (
int i = 0; i < angleRange->
length; ++i) {
119 fw.push_back(angleRange->
data[i]);
122 int error = (ok < 0) ? -1 : 0;
127 if (!LibInstantiated)
129 std::vector<double> fw;
130 for (
int i = 0; i < tcpOffset->
length; ++i) {
131 fw.push_back(tcpOffset->
data[i]);
134 int error = (ok < 0) ? -1 : 0;
141 if (!LibInstantiated)
147 if (!LibInstantiated)
153 if (!LibInstantiated)
155 return _kinematics->
getDOF();
159 if (!LibInstantiated)
161 return _kinematics->
getDOM();
166 if (!LibInstantiated)
168 std::vector<double> thetaw, dw, aw, alphaw;
169 int ok = _kinematics->
getMDH(thetaw, dw, aw, alphaw);
170 for (
int i = 0; i < (int)thetaw.size(); ++i) {
171 theta->
data[i] = (float)thetaw.at(i);
172 d->
data[i] = (float)dw.at(i);
173 a->
data[i] = (float)aw.at(i);
174 alpha->
data[i] = (float)alphaw.at(i);
176 theta->
length = (int)thetaw.size();
177 d->
length = (int)thetaw.size();
178 a->
length = (int)thetaw.size();
179 alpha->
length = (int)thetaw.size();
180 int error = (ok < 0) ? -1 : 0;
185 if (!LibInstantiated)
191 if (!LibInstantiated)
194 int ok = _kinematics->
getEPC(iw);
195 for (
int i = 0; i < (int)iw.size(); ++i) {
196 epc->
data[i] = iw.at(i);
198 epc->
length = (int)iw.size();
199 if ((
int)iw.size() == 5) {
200 epc->
data[5] = 51200;
203 int error = (ok < 0) ? -1 : 0;
208 if (!LibInstantiated)
212 for (
int i = 0; i < (int)iw.size(); ++i) {
213 encOffset->
data[i] = iw.at(i);
215 encOffset->
length = iw.size();
216 if ((
int)iw.size() == 5) {
217 encOffset->
data[5] = 31000;
220 int error = (ok < 0) ? -1 : 0;
225 if (!LibInstantiated)
229 for (
int i = 0; i < (int)iw.size(); ++i) {
230 rotDir->
data[i] = iw.at(i);
232 rotDir->
length = iw.size();
233 if ((
int)iw.size() == 5) {
237 int error = (ok < 0) ? -1 : 0;
242 if (!LibInstantiated)
244 std::vector<double> fw;
246 for (
int i = 0; i < (int)fw.size(); ++i) {
247 angleOffset->
data[i] = (float)fw.at(i);
249 angleOffset->
length = fw.size();
250 if ((
int)fw.size() == 5) {
251 angleOffset->
data[5] = 0.0;
254 int error = (ok < 0) ? -1 : 0;
259 if (!LibInstantiated)
261 std::vector<double> fw;
263 for (
int i = 0; i < (int)fw.size(); ++i) {
264 angleRange->
data[i] = (float)fw.at(i);
266 angleRange->
length = fw.size();
267 if ((
int)fw.size() == 5) {
268 angleRange->
data[5] = 0.0;
271 int error = (ok < 0) ? -1 : 0;
276 if (!LibInstantiated)
278 std::vector<double> fw;
280 for (
int i = 0; i < (int)fw.size(); ++i) {
281 tcpOffset->
data[i] = (float)fw.at(i);
283 tcpOffset->
length = fw.size();
284 int error = (ok < 0) ? -1 : 0;
290 if (LibInstantiated) {
293 for (
int i = 0; i < (int)iw.size(); ++i) {
294 version->
data[i] = iw.at(i);
296 version->
length = iw.size();
297 error = (ok < 0) ? -1 : 0;
311 if (!LibInstantiated)
313 int ok = _kinematics->
init();
314 int error = (ok < 0) ? -1 : 0;
321 if (LibInstantiated ==
true)
323 LibInstantiated =
false;
330 if (!LibInstantiated)
332 std::vector<double> k4d, mdh;
333 for (
int i = 0; i < angleK4D->
length; ++i) {
334 k4d.push_back(angleK4D->
data[i]);
337 for (
int i = 0; i < (int)mdh.size(); ++i) {
338 angleMDH->
data[i] = (float)mdh.at(i);
340 angleMDH->
length = mdh.size();
341 int error = (ok < 0) ? -1 : 0;
346 if (!LibInstantiated)
348 std::vector<double> mdh, k4d;
349 for (
int i = 0; i < angleMDH->
length; ++i) {
350 mdh.push_back(angleMDH->
data[i]);
353 for (
int i = 0; i < (int)k4d.size(); ++i) {
354 angleK4D->
data[i] = (float)k4d.at(i);
356 angleK4D->
length = k4d.size();
357 int error = (ok < 0) ? -1 : 0;
362 if (!LibInstantiated)
365 for (
int i = 0; i < enc->
length; ++i) {
366 iw.push_back(enc->
data[i]);
368 std::vector<double> fw;
369 int ok = _kinematics->
enc2rad(iw, fw);
370 for (
int i = 0; i < (int)fw.size(); ++i) {
371 angle->
data[i] = (float)fw.at(i);
373 angle->
length = fw.size();
374 int error = (ok < 0) ? -1 : 0;
379 if (!LibInstantiated)
381 std::vector<double> fw;
382 for (
int i = 0; i < angle->
length; ++i) {
383 fw.push_back(angle->
data[i]);
386 int ok = _kinematics->
rad2enc(fw, iw);
387 for (
int i = 0; i < (int)iw.size(); ++i) {
388 enc->
data[i] = iw.at(i);
391 int error = (ok < 0) ? -1 : 0;
396 if (!LibInstantiated)
398 std::vector<double> aw, pw;
399 for (
int i = 0; i < angle->
length; ++i) {
400 aw.push_back(angle->
data[i]);
403 for (
int i = 0; i < (int)pw.size(); ++i) {
404 pose->
data[i] = (float)pw.at(i);
407 int error = (ok < 0) ? -1 : 0;
413 if (!LibInstantiated)
415 std::vector<double> pw;
416 for (
int i = 0; i < pose->
length; ++i) {
417 pw.push_back(pose->
data[i]);
419 std::vector<double> paw;
420 for (
int i = 0; i < prev->
length; ++i) {
421 paw.push_back(prev->
data[i]);
423 std::vector<double> aw;
425 for (
int i = 0; i < (int)aw.size(); ++i) {
426 angle->
data[i] = (float)aw.at(i);
428 angle->
length = aw.size();
429 int error = (ok < 0) ? -1 : 0;
FloatVector FloatVector FloatVector int typeNr
Kinematics class using the kinematics lib.
int kin_K4D2mDHAng(FloatVector *angleK4D, FloatVector *angleMDH)
int kin_IK(FloatVector *pose, FloatVector *prev, FloatVector *angle, int maxBisection)
int kin_setAngRan(FloatVector *angleRange)
int setEncOff(std::vector< int > encOffset)
This sets the encoder offsets.
int getImmob()
Get the immobile flag of the last joint.
int setAngRan(std::vector< double > angleRange)
This sets the angle range.
int kin_getRotDir(IntVector *rotDir)
int kin_setEncOff(IntVector *encOffset)
int kin_getVersion(IntVector *version)
int rad2enc(std::vector< double > angles, std::vector< int > &encoders)
Converts angles to encoders.
int kin_setType(int type)
int setRotDir(std::vector< int > rotDir)
This sets the rotation direction.
int kin_setMDH(FloatVector *theta, FloatVector *d, FloatVector *a, FloatVector *alpha, int typeNr)
int kin_setLinkLen(FloatVector *links)
int getAngRan(std::vector< double > &angleRange)
Get the angle range.
int getEncOff(std::vector< int > &encOffset)
Get the encoder offsets.
int kin_DK(FloatVector *angle, FloatVector *pose)
int setMDH(std::vector< double > theta, std::vector< double > d, std::vector< double > a, std::vector< double > alpha, int typeNr=-1)
This sets the modified Denavit-Hartenberg parameters.
KinematicsLib * _kinematics
int getAngOff(std::vector< double > &angleOffset)
Get the angle offsets.
int getDOF()
Get the degree of freedom.
int kin_mDH2K4DAng(FloatVector *angleMDH, FloatVector *angleK4D)
#define KINLIB_VERSION_MINOR
int kin_getAngRan(FloatVector *angleRange)
FloatVector FloatVector int maxBisection
int getDOM()
Get the degree of mobility.
int kin_getEPC(IntVector *epc)
int kin_setEPC(IntVector *epc)
#define KINLIB_VERSION_MAJOR
int init()
This initializes the kinematics.
int kin_getAngOff(FloatVector *angleOffset)
int setAngOff(std::vector< double > angleOffset)
This sets the angle offsets.
int kin_setRotDir(IntVector *rotDir)
int mDH2K4DAng(std::vector< double > angleMDH, std::vector< double > &angleK4D)
This converts angles from mDH to Katana4D convention.
int getType()
Get the robot type.
FloatVector FloatVector * a
int kin_setTcpOff(FloatVector *tcpOffset)
int kin_setImmob(int immobile)
int setImmob(int immobile)
This sets the immobile flag of the last joint.
int kin_enc2rad(IntVector *enc, FloatVector *angle)
int kin_rad2enc(FloatVector *angle, IntVector *enc)
int getTcpOff(std::vector< double > &tcpOffset)
Get the tcp offset.
int kin_setAngOff(FloatVector *angleOffset)
FloatVector FloatVector FloatVector * alpha
int inverseKinematics(std::vector< double > pose, std::vector< double > prev, std::vector< double > &angles, int maxBisection=0)
Calculates the inverse kinematics.
int setLinkLen(std::vector< double > links)
This sets the link length parameters (part of mDH-parameters)
int getVersion(std::vector< int > &version)
Get the version number of the library.
int setTcpOff(std::vector< double > tcpOffset)
This sets the tcp offset.
int getEPC(std::vector< int > &epc)
Get the encoders per cycle.
int K4D2mDHAng(std::vector< double > angleK4D, std::vector< double > &angleMDH)
This converts angles from Katana4D to mDH convention.
int kin_getEncOff(IntVector *encOffset)
int directKinematics(std::vector< double > angles, std::vector< double > &pose)
Calculates the direct kinematics.
int getRotDir(std::vector< int > &rotDir)
Get the rotation direction.
int enc2rad(std::vector< int > encoders, std::vector< double > &angles)
Converts encoders to angles.
#define KINLIB_VERSION_REVISION
int kin_getMDH(FloatVector *theta, FloatVector *d, FloatVector *a, FloatVector *alpha)
int getMaxDOF()
Get the maximum degree of freedom.
int setEPC(std::vector< int > epc)
This sets the encoders per cycle.
int kin_getTcpOff(FloatVector *tcpOffset)
int getMDH(std::vector< double > &theta, std::vector< double > &d, std::vector< double > &a, std::vector< double > &alpha)
Get the modified Denavit-Hartenberg parameters.