Skip to content

Commit 02a54e9

Browse files
committed
Unittest - update joint unittests to include spline joints
1 parent 27aa09f commit 02a54e9

File tree

6 files changed

+92
-11
lines changed

6 files changed

+92
-11
lines changed

unittest/all-joints.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ struct init<pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options>>
167167
}
168168
};
169169

170+
template<typename Scalar, int Options>
171+
struct init<pinocchio::JointModelSplineTpl<Scalar, Options>>
172+
{
173+
typedef pinocchio::JointModelSplineTpl<Scalar, Options> JointModel;
174+
175+
static JointModel run()
176+
{
177+
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) ctrlFrames;
178+
ctrlFrames.push_back(SE3::Identity());
179+
ctrlFrames.push_back(SE3(Eigen::Matrix3d::Identity(), Eigen::Vector3d(0., 0., 1.)));
180+
JointModel jmodel(ctrlFrames, 1);
181+
182+
jmodel.setIndexes(0, 0, 0);
183+
return jmodel;
184+
}
185+
};
186+
170187
BOOST_AUTO_TEST_SUITE(joint_model_base_test)
171188

172189
template<typename TestDerived>

unittest/finite-differences.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,23 @@ struct init<pinocchio::JointModelMimicTpl<Scalar, Options, JointCollection>>
212212
}
213213
};
214214

215+
template<typename Scalar, int Options>
216+
struct init<pinocchio::JointModelSplineTpl<Scalar, Options>>
217+
{
218+
typedef pinocchio::JointModelSplineTpl<Scalar, Options> JointModel;
219+
220+
static JointModel run()
221+
{
222+
PINOCCHIO_ALIGNED_STD_VECTOR(pinocchio::SE3) ctrlFrames;
223+
ctrlFrames.push_back(pinocchio::SE3::Identity());
224+
ctrlFrames.push_back(pinocchio::SE3(Eigen::Matrix3d::Identity(), Eigen::Vector3d(0., 0., 1.)));
225+
JointModel jmodel(ctrlFrames, 1);
226+
227+
jmodel.setIndexes(0, 0, 0);
228+
return jmodel;
229+
}
230+
};
231+
215232
struct FiniteDiffJoint
216233
{
217234
void operator()(JointModelComposite & /*jmodel*/) const

unittest/joint-generic.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,23 @@ struct init<pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options>>
279279
}
280280
};
281281

282+
template<typename Scalar, int Options>
283+
struct init<pinocchio::JointModelSplineTpl<Scalar, Options>>
284+
{
285+
typedef pinocchio::JointModelSplineTpl<Scalar, Options> JointModel;
286+
287+
static JointModel run()
288+
{
289+
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) ctrlFrames;
290+
ctrlFrames.push_back(SE3::Identity());
291+
ctrlFrames.push_back(SE3(Eigen::Matrix3d::Identity(), Eigen::Vector3d(0., 0., 1.)));
292+
JointModel jmodel(ctrlFrames, 1);
293+
294+
jmodel.setIndexes(0, 0, 0);
295+
return jmodel;
296+
}
297+
};
298+
282299
struct TestJoint
283300
{
284301

unittest/joint-motion-subspace.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,23 @@ struct init<pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options>>
418418
}
419419
};
420420

421+
template<typename Scalar, int Options>
422+
struct init<pinocchio::JointModelSplineTpl<Scalar, Options>>
423+
{
424+
typedef pinocchio::JointModelSplineTpl<Scalar, Options> JointModel;
425+
426+
static JointModel run()
427+
{
428+
PINOCCHIO_ALIGNED_STD_VECTOR(pinocchio::SE3) ctrlFrames;
429+
ctrlFrames.push_back(pinocchio::SE3::Identity());
430+
ctrlFrames.push_back(pinocchio::SE3(Eigen::Matrix3d::Identity(), Eigen::Vector3d(0., 0., 1.)));
431+
JointModel jmodel(ctrlFrames, 1);
432+
433+
jmodel.setIndexes(0, 0, 0);
434+
return jmodel;
435+
}
436+
};
437+
421438
struct TestJointConstraint
422439
{
423440

unittest/joint-spline.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ BOOST_AUTO_TEST_CASE(vsPrismatic)
5050

5151
JointModelSpline jmodel(ctrlFrames, 1);
5252
JointDataSpline jdata = jmodel.createData();
53-
53+
5454
jmodel.setIndexes(0, 0, 0);
5555

5656
Eigen::VectorXd q(Eigen::VectorXd::Zero(1));
5757

5858
// -------
5959
q << 0.2;
60-
60+
6161
jmodel.calc(jdata, q);
6262

6363
BOOST_CHECK(expected_configuration.rotation().isApprox(jdata.M.rotation(), 1e-12));
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(vsPrismatic)
7373

7474
expected_configuration.translation() << 0, 0, 0.3;
7575
expected_v_J.linear() << 0., 0., 0.4;
76-
76+
7777
BOOST_CHECK(expected_configuration.rotation().isApprox(jdata.M.rotation(), 1e-12));
7878
BOOST_CHECK(expected_configuration.translation().isApprox(jdata.M.translation(), 1e-12));
7979
BOOST_CHECK(expected_v_J.toVector().isApprox(((Motion)jdata.v).toVector(), 1e-12));
@@ -89,7 +89,6 @@ BOOST_AUTO_TEST_CASE(vsPrismatic)
8989

9090
// Inertia inertia(1., Vector3(0.5, 0., 0.0), Matrix3::Identity());
9191

92-
9392
// PINOCCHIO_ALIGNED_STD_VECTOR(SE3) ctrlFrames;
9493
// ctrlFrames.push_back(SE3::Identity());
9594

@@ -132,16 +131,16 @@ BOOST_AUTO_TEST_CASE(vsPrismatic)
132131
// ctrlFrames.push_back(SE3(R4, Eigen::Vector3d::Zero()));
133132

134133
// Model modelSpline;
135-
// addJointAndBody(modelSpline, JointModelSpline(ctrlFrames), 0, SE3::Identity(), "spline_joint", inertia);
136-
// Data dataSpline(modelSpline);
134+
// addJointAndBody(modelSpline, JointModelSpline(ctrlFrames), 0, SE3::Identity(), "spline_joint",
135+
// inertia); Data dataSpline(modelSpline);
137136

138137
// Model modelSph;
139138
// addJointAndBody(modelSph, JointModelSphericalZYX(), 0, SE3::Identity(), "sph_joint", inertia);
140139
// Data dataSph(modelSph);
141140

142141
// Eigen::VectorXd qSpline(Eigen::VectorXd::Zero(1));
143142
// qSpline << 0.5;
144-
143+
145144
// Eigen::Vector3d qSph;
146145
// qSph << 0, M_PI / 3, 0;
147146

@@ -153,7 +152,4 @@ BOOST_AUTO_TEST_CASE(vsPrismatic)
153152
// std::cout << dataSph.oMi[1] << std::endl;
154153
// }
155154

156-
157-
158-
159-
BOOST_AUTO_TEST_SUITE_END()
155+
BOOST_AUTO_TEST_SUITE_END()

unittest/serialization.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,23 @@ struct init<pinocchio::JointModelMimicTpl<Scalar, Options, JointCollection>>
412412
}
413413
};
414414

415+
template<typename Scalar, int Options>
416+
struct init<pinocchio::JointModelSplineTpl<Scalar, Options>>
417+
{
418+
typedef pinocchio::JointModelSplineTpl<Scalar, Options> JointModel;
419+
420+
static JointModel run()
421+
{
422+
PINOCCHIO_ALIGNED_STD_VECTOR(pinocchio::SE3) ctrlFrames;
423+
ctrlFrames.push_back(pinocchio::SE3::Identity());
424+
ctrlFrames.push_back(pinocchio::SE3(Eigen::Matrix3d::Identity(), Eigen::Vector3d(0., 0., 1.)));
425+
JointModel jmodel(ctrlFrames, 1);
426+
427+
jmodel.setIndexes(0, 0, 0);
428+
return jmodel;
429+
}
430+
};
431+
415432
struct TestJointModel
416433
{
417434
template<typename JointModel>

0 commit comments

Comments
 (0)