184 JointTypeUndefined = 0,
195 JointTypeTranslationXYZ,
196 JointTypeFloatingBase,
214static const JointMapEntry JointMap[] = {
215 { JointTypeUndefined ,
"Undefined" ,
"UNDEFINED"},
216 { JointTypeRevolute ,
"Revolute" ,
"" },
217 { JointTypePrismatic ,
"Prismatic" ,
"" },
218 { JointTypeRevoluteX ,
"RevoluteX" ,
"" },
219 { JointTypeRevoluteY ,
"RevoluteY" ,
"" },
220 { JointTypeRevoluteZ ,
"RevoluteZ" ,
"" },
221 { JointTypeSpherical ,
"Spherical" ,
"Sphere" },
222 { JointTypeEulerZYX ,
"EulerZYX" ,
"EaZYX" },
223 { JointTypeEulerXYZ ,
"EulerXYZ" ,
"EaXYZ" },
224 { JointTypeEulerYXZ ,
"EulerYXZ" ,
"EaYXZ" },
225 { JointTypeEulerZXY ,
"EulerZXY" ,
"EaZXY" },
226 { JointTypeTranslationXYZ ,
"TranslationXYZ" ,
"TrXYZ" },
227 { JointTypeFloatingBase ,
"FloatingBase" ,
"FloBas" },
228 { JointTypeFixed ,
"Fixed" ,
"Fixed" },
229 { JointTypeHelical ,
"Helical" ,
"Helic" },
230 { JointType1DoF ,
"1DoF" ,
"" },
231 { JointType2DoF ,
"2DoF" ,
"" },
232 { JointType3DoF ,
"3DoF" ,
"" },
233 { JointType4DoF ,
"4DoF" ,
"" },
234 { JointType5DoF ,
"5DoF" ,
"" },
235 { JointType6DoF ,
"6DoF" ,
"" },
236 { JointTypeCustom ,
"Custom" ,
"Cus" }
244static const AxisMapEntry AxisMap[]={
259struct RBDL_DLLAPI Joint {
262 mJointType (JointTypeUndefined),
265 custom_joint_index(-1) {};
266 Joint (JointType type) :
271 custom_joint_index(-1)
273 if (type == JointTypeRevoluteX) {
277 }
else if (type == JointTypeRevoluteY) {
281 }
else if (type == JointTypeRevoluteZ) {
285 }
else if (type == JointTypeSpherical) {
293 }
else if (type == JointTypeEulerZYX) {
301 }
else if (type == JointTypeEulerXYZ) {
309 }
else if (type == JointTypeEulerYXZ) {
317 }
else if (type == JointTypeEulerZXY) {
325 }
else if (type == JointTypeTranslationXYZ) {
333 }
else if (type >= JointType1DoF && type <= JointType6DoF) {
336 mDoFCount = type - JointType1DoF + 1;
338 std::cerr <<
"Warning: uninitalized vector" << std::endl;
339 }
else if (type == JointTypeCustom) {
342 std::ostringstream errormsg;
343 errormsg <<
"Error: Invalid use of Joint constructor Joint(JointType"
344 <<
" type). Only allowed when type != JointTypeCustom"
346 throw Errors::RBDLError(errormsg.str());
347 }
else if (type != JointTypeFixed && type != JointTypeFloatingBase) {
348 std::ostringstream errormsg;
350 "Error: Invalid use of Joint constructor Joint(JointType type). Only allowed when type == JointTypeFixed or JointTypeSpherical."
352 throw Errors::RBDLError(errormsg.str());
355 Joint (JointType type,
int degreesOfFreedom) :
360 custom_joint_index(-1)
362 if (type == JointTypeCustom) {
363 mDoFCount = degreesOfFreedom;
365 for(
unsigned int i=0; i<mDoFCount; ++i) {
369 std::ostringstream errormsg;
370 errormsg <<
"Error: Invalid use of Joint constructor Joint(JointType"
371 <<
" type, int degreesOfFreedom). Only allowed when "
372 <<
"type == JointTypeCustom."
374 throw Errors::RBDLError(errormsg.str());
377 Joint (
const Joint &joint) :
378 mJointType (joint.mJointType),
379 mDoFCount (joint.mDoFCount),
380 q_index (joint.q_index),
381 custom_joint_index(joint.custom_joint_index)
385 for (
unsigned int i = 0; i < mDoFCount; i++) {
386 mJointAxes[i] = joint.mJointAxes[i];
389 Joint& operator= (
const Joint &joint)
391 if (
this != &joint) {
396 mJointType = joint.mJointType;
397 mDoFCount = joint.mDoFCount;
398 custom_joint_index = joint.custom_joint_index;
401 for (
unsigned int i = 0; i < mDoFCount; i++) {
402 mJointAxes[i] = joint.mJointAxes[i];
405 q_index = joint.q_index;
416 custom_joint_index = -1;
429 const JointType joint_type,
439 assert ( joint_type == JointTypeRevolute || joint_type == JointTypePrismatic );
441 mJointType = joint_type;
443 if (joint_type == JointTypeRevolute) {
452 }
else if (joint_type == JointTypePrismatic) {
454#ifndef RBDL_USE_CASADI_MATH
455 assert (joint_axis.squaredNorm() == 1.);
483#ifdef RBDL_USE_CASADI_MATH
484 if (!axis_0[0].is_zero()) {
488 mJointType = JointTypeRevoluteX;
489#ifdef RBDL_USE_CASADI_MATH
490 }
else if (!axis_0[1].is_zero()) {
494 mJointType = JointTypeRevoluteY;
495#ifdef RBDL_USE_CASADI_MATH
496 }
else if (!axis_0[2].is_zero()) {
500 mJointType = JointTypeRevoluteZ;
501#ifdef RBDL_USE_CASADI_MATH
502 }
else if (axis_0[0].is_zero() && axis_0[1].is_zero() && axis_0[2].is_zero()) {
504 }
else if (axis_0[0] == 0. && axis_0[1] == 0. && axis_0[2] == 0.) {
506 mJointType = JointTypePrismatic;
508 mJointType = JointTypeHelical;
510 validate_spatial_axis (mJointAxes[0]);
528 mJointType = JointType2DoF;
532 mJointAxes[0] = axis_0;
533 mJointAxes[1] = axis_1;
535 validate_spatial_axis (mJointAxes[0]);
536 validate_spatial_axis (mJointAxes[1]);
556 mJointType = JointType3DoF;
561 mJointAxes[0] = axis_0;
562 mJointAxes[1] = axis_1;
563 mJointAxes[2] = axis_2;
565 validate_spatial_axis (mJointAxes[0]);
566 validate_spatial_axis (mJointAxes[1]);
567 validate_spatial_axis (mJointAxes[2]);
589 mJointType = JointType4DoF;
594 mJointAxes[0] = axis_0;
595 mJointAxes[1] = axis_1;
596 mJointAxes[2] = axis_2;
597 mJointAxes[3] = axis_3;
599 validate_spatial_axis (mJointAxes[0]);
600 validate_spatial_axis (mJointAxes[1]);
601 validate_spatial_axis (mJointAxes[2]);
602 validate_spatial_axis (mJointAxes[3]);
626 mJointType = JointType5DoF;
631 mJointAxes[0] = axis_0;
632 mJointAxes[1] = axis_1;
633 mJointAxes[2] = axis_2;
634 mJointAxes[3] = axis_3;
635 mJointAxes[4] = axis_4;
637 validate_spatial_axis (mJointAxes[0]);
638 validate_spatial_axis (mJointAxes[1]);
639 validate_spatial_axis (mJointAxes[2]);
640 validate_spatial_axis (mJointAxes[3]);
641 validate_spatial_axis (mJointAxes[4]);
667 mJointType = JointType6DoF;
672 mJointAxes[0] = axis_0;
673 mJointAxes[1] = axis_1;
674 mJointAxes[2] = axis_2;
675 mJointAxes[3] = axis_3;
676 mJointAxes[4] = axis_4;
677 mJointAxes[5] = axis_5;
679 validate_spatial_axis (mJointAxes[0]);
680 validate_spatial_axis (mJointAxes[1]);
681 validate_spatial_axis (mJointAxes[2]);
682 validate_spatial_axis (mJointAxes[3]);
683 validate_spatial_axis (mJointAxes[4]);
684 validate_spatial_axis (mJointAxes[5]);
694#ifdef RBDL_USE_CASADI_MATH
698 bool axis_rotational =
false;
699 bool axis_translational =
false;
704 if (
fabs(rotation.norm()) > 1.0e-8) {
705 axis_rotational =
true;
708 if (
fabs(translation.norm()) > 1.0e-8) {
709 axis_translational =
true;
712 if(axis_rotational && rotation.norm() - 1.0 > 1.0e-8) {
713 std::cerr <<
"Warning: joint rotation axis is not unit!" << std::endl;
716 if(axis_translational && translation.norm() - 1.0 > 1.0e-8) {
717 std::cerr <<
"Warning: joint translation axis is not unit!" << std::endl;
720 return axis_rotational != axis_translational;
727 JointType mJointType;
731 unsigned int mDoFCount;
732 unsigned int q_index;
733 unsigned int custom_joint_index;
749 unsigned int joint_id,
757 unsigned int joint_id,
763 unsigned int joint_id,
767struct RBDL_DLLAPI CustomJoint {
770 virtual ~CustomJoint() {};
772 virtual void jcalc (Model &model,
773 unsigned int joint_id,
778 unsigned int joint_id,
782 unsigned int mDoFCount;
783 Math::SpatialTransform XJ;
SpatialVector_t SpatialVector
RBDL_DLLAPI void jcalc(Model &model, unsigned int joint_id, const VectorNd &q, const VectorNd &qdot)
RBDL_DLLAPI Math::SpatialTransform jcalc_XJ(Model &model, unsigned int joint_id, const Math::VectorNd &q)
RBDL_DLLAPI void jcalc_X_lambda_S(Model &model, unsigned int joint_id, const VectorNd &q)
MX_Xd_dynamic fabs(const MX_Xd_dynamic &m)