-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WeldJointConstraint
for fixed joints if the parent is not a FreeJoint
#345
Changes from all commits
80d780b
59e4428
a261ed7
54c29f1
ffb1f6a
0690374
a43f308
f921d76
3325673
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||
#include <dart/dynamics/BodyNode.hpp> | ||||
#include <dart/dynamics/SimpleFrame.hpp> | ||||
#include <dart/dynamics/Skeleton.hpp> | ||||
#include <dart/constraint/WeldJointConstraint.hpp> | ||||
#include <dart/simulation/World.hpp> | ||||
|
||||
#include <memory> | ||||
|
@@ -73,6 +74,15 @@ struct JointInfo | |||
{ | ||||
dart::dynamics::JointPtr joint; | ||||
dart::dynamics::SimpleFramePtr frame; | ||||
|
||||
enum JointType | ||||
{ | ||||
JOINT, | ||||
CONSTRAINT | ||||
}; | ||||
|
||||
JointType type{JOINT}; | ||||
dart::constraint::WeldJointConstraintPtr constraint; | ||||
}; | ||||
|
||||
struct ShapeInfo | ||||
|
@@ -221,6 +231,7 @@ class Base : public Implements3d<FeatureList<Feature>> | |||
public: using DartBodyNodePtr = dart::dynamics::BodyNodePtr; | ||||
public: using DartJoint = dart::dynamics::Joint; | ||||
public: using DartJointPtr = dart::dynamics::JointPtr; | ||||
public: using DartWeldJointConsPtr = dart::constraint::WeldJointConstraintPtr; | ||||
public: using DartShapeNode = dart::dynamics::ShapeNode; | ||||
public: using DartShapeNodePtr = std::shared_ptr<DartShapeNode>; | ||||
public: using ModelInfoPtr = std::shared_ptr<ModelInfo>; | ||||
|
@@ -353,6 +364,7 @@ class Base : public Implements3d<FeatureList<Feature>> | |||
this->joints.idToObject[id] = std::make_shared<JointInfo>(); | ||||
this->joints.idToObject[id]->joint = _joint; | ||||
this->joints.objectToID[_joint] = id; | ||||
this->joints.idToObject[id]->type = JointInfo::JointType::JOINT; | ||||
dart::dynamics::SimpleFramePtr jointFrame = | ||||
dart::dynamics::SimpleFrame::createShared( | ||||
_joint->getChildBodyNode(), _joint->getName() + "_frame", | ||||
|
@@ -364,6 +376,25 @@ class Base : public Implements3d<FeatureList<Feature>> | |||
return id; | ||||
} | ||||
|
||||
public: inline std::size_t AddJointConstraint(DartWeldJointConsPtr _joint) | ||||
{ | ||||
const std::size_t id = this->GetNextEntity(); | ||||
this->joints.idToObject[id] = std::make_shared<JointInfo>(); | ||||
this->joints.idToObject[id]->constraint = _joint; | ||||
this->joints.idToObject[id]->type = JointInfo::JointType::CONSTRAINT; | ||||
// TODO(arjo): Refactor the joints.objectToId to support constraints. | ||||
// this->joints.objectToID[_joint] = id; | ||||
// dart::dynamics::SimpleFramePtr jointFrame = | ||||
// dart::dynamics::SimpleFrame::createShared( | ||||
// _joint->getChildBodyNode(), _joint->getName() + "_frame", | ||||
// _joint->getTransformFromChildBodyNode()); | ||||
|
||||
// this->joints.idToObject[id]->frame = jointFrame; | ||||
// this->frames[id] = this->joints.idToObject[id]->frame.get(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this code or is this relevant to the todo comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah honestly I'm not sure where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two containers are used for implementing frame semantics (see
So yes, we need to implement this since the weld constraint represents an actual joint whose frame semantics could be queried by the user (although I don't think we do that currently in gz-sim). BTW, a |
||||
|
||||
return id; | ||||
} | ||||
|
||||
public: inline std::size_t AddShape( | ||||
const ShapeInfo &_info) | ||||
{ | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Use
enum class
.