|
31 | 31 | #include <dart/dynamics/CylinderShape.hpp>
|
32 | 32 | #include <dart/dynamics/EllipsoidShape.hpp>
|
33 | 33 | #include <dart/dynamics/FreeJoint.hpp>
|
| 34 | +#include <dart/dynamics/KinematicJoint.hpp> |
34 | 35 | #include <dart/dynamics/HeightmapShape.hpp>
|
35 | 36 | #include <dart/dynamics/MeshShape.hpp>
|
36 | 37 | #include <dart/dynamics/PlaneShape.hpp>
|
@@ -672,28 +673,63 @@ Identity SDFFeatures::ConstructSdfLink(
|
672 | 673 | const Eigen::Vector3d localCom =
|
673 | 674 | math::eigen3::convert(sdfInertia.Pose().Pos());
|
674 | 675 |
|
| 676 | + const bool isKinematic = _sdfLink.Kinematic(); |
| 677 | + |
675 | 678 | bodyProperties.mInertia.setLocalCOM(localCom);
|
676 | 679 |
|
677 | 680 | bodyProperties.mGravityMode = _sdfLink.EnableGravity();
|
678 | 681 |
|
679 | 682 | dart::dynamics::FreeJoint::Properties jointProperties;
|
680 | 683 | jointProperties.mName = bodyProperties.mName + "_FreeJoint";
|
681 |
| - // TODO(MXG): Consider adding a UUID to this joint name in order to avoid any |
682 |
| - // potential (albeit unlikely) name collisions. |
683 | 684 |
|
684 |
| - // Note: When constructing a link from this function, we always instantiate |
685 |
| - // it as a standalone free body within the model. If it should have any joint |
686 |
| - // constraints, those will be added later. |
687 |
| - const auto result = modelInfo.model->createJointAndBodyNodePair< |
688 |
| - dart::dynamics::FreeJoint>(nullptr, jointProperties, bodyProperties); |
| 685 | + dart::dynamics::BodyNode * bn; |
| 686 | + |
| 687 | + bodyProperties.mInertia.setMass(sdfInertia.MassMatrix().Mass()); |
| 688 | + bodyProperties.mGravityMode = _sdfLink.EnableGravity(); |
| 689 | + bodyProperties.mInertia.setMoment(I_link); |
| 690 | + |
| 691 | + bodyProperties.mInertia.setLocalCOM(localCom); |
| 692 | + bodyProperties.mFrictionCoeff = 0; |
689 | 693 |
|
690 |
| - dart::dynamics::FreeJoint * const joint = result.first; |
691 | 694 | const Eigen::Isometry3d tf =
|
692 | 695 | GetParentModelFrame(modelInfo) * ResolveSdfPose(_sdfLink.SemanticPose());
|
693 | 696 |
|
694 |
| - joint->setTransform(tf); |
| 697 | + if(isKinematic){ |
| 698 | + gzdbg << "Kinematic tag found -> " << bodyProperties.mName << std::endl; |
| 699 | + jointProperties.mName = bodyProperties.mName + "_KinematicJoint"; |
| 700 | + bodyProperties.mGravityMode = false; |
| 701 | + |
| 702 | + //jointProperties.mActuatorType = dart::dynamics::Joint::ActuatorType::PASSIVE; |
| 703 | + //jointProperties.mName = bodyProperties.mName + "_KinematicJoint"; |
| 704 | + |
| 705 | + auto result = modelInfo.model->createJointAndBodyNodePair< |
| 706 | + dart::dynamics::KinematicJoint>(nullptr, jointProperties, bodyProperties); |
| 707 | + // result.first->setAccelerations(Eigen::Vector6d::Zero()); |
| 708 | + //`result.second->setAccelerations(Eigen::Vector6d::Zero()); |
| 709 | + |
| 710 | + dart::dynamics::KinematicJoint * const joint = result.first; |
| 711 | + joint->setTransform(tf); |
| 712 | + |
| 713 | + bn = result.second; |
| 714 | + } |
| 715 | + |
| 716 | + else{ |
| 717 | + // Note: When constructing a link from this function, we always instantiate |
| 718 | + // it as a standalone free body within the model. If it should have any joint |
| 719 | + // constraints, those will be added later. |
| 720 | + |
| 721 | + // TODO(MXG): Consider adding a UUID to this joint name in order to avoid any |
| 722 | + // potential (albeit unlikely) name collisions. |
| 723 | + |
| 724 | + auto result = modelInfo.model->createJointAndBodyNodePair< |
| 725 | + dart::dynamics::FreeJoint>(nullptr, jointProperties, bodyProperties); |
| 726 | + |
| 727 | + dart::dynamics::FreeJoint * const joint = result.first; |
| 728 | + joint->setTransform(tf); |
| 729 | + |
| 730 | + bn = result.second; |
| 731 | + } |
695 | 732 |
|
696 |
| - dart::dynamics::BodyNode * const bn = result.second; |
697 | 733 |
|
698 | 734 | auto worldID = this->GetWorldOfModelImpl(_modelID);
|
699 | 735 | if (worldID == INVALID_ENTITY_ID)
|
@@ -1106,7 +1142,8 @@ Identity SDFFeatures::ConstructSdfJoint(
|
1106 | 1142 | {
|
1107 | 1143 | auto childsParentJoint = _child->getParentJoint();
|
1108 | 1144 | std::string parentName = worldParent? "world" : _parent->getName();
|
1109 |
| - if (childsParentJoint->getType() != "FreeJoint") |
| 1145 | + if (childsParentJoint->getType() != "FreeJoint" && |
| 1146 | + childsParentJoint->getType() != "KinematicJoint") |
1110 | 1147 | {
|
1111 | 1148 | gzerr << "Asked to create a joint between links "
|
1112 | 1149 | << "[" << parentName << "] as parent and ["
|
|
0 commit comments