Skip to content

Commit a39f1d0

Browse files
committed
add fixes
Signed-off-by: Jose Mayoral <jocamaba1989@gmail.com>
1 parent 96eb96f commit a39f1d0

File tree

3 files changed

+57
-15
lines changed

3 files changed

+57
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gz_find_package(DART
7878
utils
7979
utils-urdf
8080
CONFIG
81-
VERSION 6.10
81+
VERSION 6.16.0
8282
REQUIRED_BY dartsim
8383
PKGCONFIG dart
8484
PKGCONFIG_VER_COMPARISON >=)

dartsim/src/FreeGroupFeatures.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "FreeGroupFeatures.hh"
1919

2020
#include <dart/constraint/ConstraintSolver.hpp>
21+
#include <dart/dynamics/KinematicJoint.hpp>
2122
#include <dart/dynamics/FreeJoint.hpp>
2223
#include <gz/common/Console.hh>
2324

@@ -38,11 +39,13 @@ Identity FreeGroupFeatures::FindFreeGroupForModel(
3839
if (skeleton->getNumBodyNodes() == 0 && modelInfo->nestedModels.empty())
3940
return this->GenerateInvalidId();
4041

41-
// Verify that all root joints are FreeJoints
42+
// Verify that all root joints are FreeJoints or KinematicJoints
4243
for (std::size_t i = 0; i < skeleton->getNumTrees(); ++i)
4344
{
4445
if (skeleton->getRootJoint(i)->getType()
45-
!= dart::dynamics::FreeJoint::getStaticType())
46+
!= dart::dynamics::FreeJoint::getStaticType() &&
47+
skeleton->getRootJoint(i)->getType()
48+
!= dart::dynamics::KinematicJoint::getStaticType())
4649
{
4750
return this->GenerateInvalidId();
4851
}
@@ -85,7 +88,9 @@ Identity FreeGroupFeatures::FindFreeGroupForLink(
8588
while (bn)
8689
{
8790
if (bn->getParentJoint()->getType()
88-
== dart::dynamics::FreeJoint::getStaticType())
91+
== dart::dynamics::FreeJoint::getStaticType() ||
92+
bn->getParentJoint()->getType()
93+
== dart::dynamics::KinematicJoint::getStaticType())
8994
{
9095
break;
9196
}

dartsim/src/SDFFeatures.cc

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <dart/dynamics/CylinderShape.hpp>
3232
#include <dart/dynamics/EllipsoidShape.hpp>
3333
#include <dart/dynamics/FreeJoint.hpp>
34+
#include <dart/dynamics/KinematicJoint.hpp>
3435
#include <dart/dynamics/HeightmapShape.hpp>
3536
#include <dart/dynamics/MeshShape.hpp>
3637
#include <dart/dynamics/PlaneShape.hpp>
@@ -672,28 +673,63 @@ Identity SDFFeatures::ConstructSdfLink(
672673
const Eigen::Vector3d localCom =
673674
math::eigen3::convert(sdfInertia.Pose().Pos());
674675

676+
const bool isKinematic = _sdfLink.Kinematic();
677+
675678
bodyProperties.mInertia.setLocalCOM(localCom);
676679

677680
bodyProperties.mGravityMode = _sdfLink.EnableGravity();
678681

679682
dart::dynamics::FreeJoint::Properties jointProperties;
680683
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.
683684

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;
689693

690-
dart::dynamics::FreeJoint * const joint = result.first;
691694
const Eigen::Isometry3d tf =
692695
GetParentModelFrame(modelInfo) * ResolveSdfPose(_sdfLink.SemanticPose());
693696

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+
}
695732

696-
dart::dynamics::BodyNode * const bn = result.second;
697733

698734
auto worldID = this->GetWorldOfModelImpl(_modelID);
699735
if (worldID == INVALID_ENTITY_ID)
@@ -1106,7 +1142,8 @@ Identity SDFFeatures::ConstructSdfJoint(
11061142
{
11071143
auto childsParentJoint = _child->getParentJoint();
11081144
std::string parentName = worldParent? "world" : _parent->getName();
1109-
if (childsParentJoint->getType() != "FreeJoint")
1145+
if (childsParentJoint->getType() != "FreeJoint" &&
1146+
childsParentJoint->getType() != "KinematicJoint")
11101147
{
11111148
gzerr << "Asked to create a joint between links "
11121149
<< "[" << parentName << "] as parent and ["

0 commit comments

Comments
 (0)