Skip to content

Commit a9eebd6

Browse files
committed
Model-graph - Add spline joint to model graph
1 parent 1766a2a commit a9eebd6

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

include/pinocchio/parsers/graph/graph-visitor.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ namespace pinocchio
129129
std::invalid_argument,
130130
"Graph - Joint Mimic cannot have a q_ref. Please use the joint offset directly.");
131131
}
132+
133+
SE3 operator()(const JointSpline &) const
134+
{
135+
PINOCCHIO_THROW_PRETTY(
136+
std::invalid_argument,
137+
"Graph - Joint Spline cannot have a q_ref. Please use the joint offset directly.");
138+
}
132139
};
133140

134141
/// Return qref transformation.

include/pinocchio/parsers/graph/joints.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,43 @@ namespace pinocchio
229229
}
230230
};
231231

232+
struct JointSpline
233+
{
234+
std::vector<SE3> ctrlFrames;
235+
int degree = 3;
236+
237+
static constexpr int nq = 1;
238+
static constexpr int nv = 1;
239+
240+
JointSpline() = default;
241+
JointSpline(const int degree)
242+
: degree(degree)
243+
{
244+
}
245+
246+
JointSpline(const SE3 & ctrlFrame, const int degree = 3)
247+
: degree(degree)
248+
{
249+
ctrlFrames.push_back(ctrlFrame);
250+
}
251+
252+
JointSpline(const std::vector<SE3> & ctrlFrames, const int degree = 3)
253+
: degree(degree)
254+
, ctrlFrames(ctrlFrames)
255+
{
256+
}
257+
258+
void addCtrlFrame(const SE3 & ctrlFrame)
259+
{
260+
ctrlFrames.push_back(ctrlFrame);
261+
}
262+
263+
bool operator==(const JointSpline & other) const
264+
{
265+
return degree == other.degree && ctrlFrames == other.ctrlFrames;
266+
}
267+
};
268+
232269
// Forward declare
233270
struct JointComposite;
234271
struct JointMimic;
@@ -245,6 +282,7 @@ namespace pinocchio
245282
JointPlanar,
246283
JointHelical,
247284
JointUniversal,
285+
JointSpline,
248286
boost::recursive_wrapper<JointComposite>,
249287
boost::recursive_wrapper<JointMimic>>
250288
JointVariant;

src/parsers/graph/model-graph-algo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ namespace pinocchio
117117
// Joint Universal
118118
typedef typename JointCollectionDefault::JointModelUniversal JointModelUniversal;
119119

120+
// JointSpline
121+
typedef typename JointCollectionDefault::JointModelSpline JointModelSpline;
122+
120123
typedef JointModel ReturnType;
121124

122125
ReturnType operator()(const JointFixed & /*joint*/) const
@@ -229,6 +232,17 @@ namespace pinocchio
229232
{
230233
return boost::apply_visitor(*this, joint.secondary_joint);
231234
}
235+
ReturnType operator()(const JointSpline & joint) const
236+
{
237+
JointModelSpline jmodel(joint.degree);
238+
239+
for (size_t i = 0; i < joint.ctrlFrames.size(); i++)
240+
{
241+
jmodel.addControlFrame(joint.ctrlFrames[i]);
242+
}
243+
jmodel.buildJoint();
244+
return jmodel;
245+
}
232246
ReturnType operator()(const JointComposite & joint) const
233247
{
234248
JointModelComposite jmodel;

src/parsers/graph/model-graph.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ namespace pinocchio
8585
{
8686
return {joint, SE3::Identity()};
8787
}
88+
ReturnType operator()(const JointSpline & joint) const
89+
{
90+
return {joint, SE3::Identity()};
91+
}
8892
ReturnType operator()(const JointComposite & joint) const
8993
{
9094
JointComposite jReturn;

0 commit comments

Comments
 (0)