Skip to content

Commit 6cb88b2

Browse files
committed
test/frames: fix testing of getFrameJacobianTimeVariation
1 parent b2c996b commit 6cb88b2

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

unittest/frames.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2016-2020 CNRS INRIA
2+
// Copyright (c) 2016-2024 CNRS INRIA
33
//
44

55
#include "pinocchio/multibody/model.hpp"
@@ -569,14 +569,14 @@ BOOST_AUTO_TEST_CASE(test_frame_jacobian_time_variation)
569569
const Motion & v_ref_local = frame.placement.actInv(data_ref.v[parent_idx]);
570570
const Motion & v_ref = data_ref.oMf[idx].act(v_ref_local);
571571

572-
const SE3 & wMf = SE3(data_ref.oMf[idx].rotation(), SE3::Vector3::Zero());
573-
const Motion & v_ref_local_world_aligned = wMf.act(v_ref_local);
572+
const SE3 wMf = SE3(data_ref.oMf[idx].rotation(), SE3::Vector3::Zero());
573+
const Motion v_ref_local_world_aligned = wMf.act(v_ref_local);
574574
BOOST_CHECK(v_idx.isApprox(v_ref));
575575

576576
Motion a_idx(J * a + dJ * v);
577-
const Motion & a_ref_local = frame.placement.actInv(data_ref.a[parent_idx]);
578-
const Motion & a_ref = data_ref.oMf[idx].act(a_ref_local);
579-
const Motion & a_ref_local_world_aligned = wMf.act(a_ref_local);
577+
const Motion a_ref_local = frame.placement.actInv(data_ref.a[parent_idx]);
578+
const Motion a_ref = data_ref.oMf[idx].act(a_ref_local);
579+
const Motion a_ref_local_world_aligned = wMf.act(a_ref_local);
580580
BOOST_CHECK(a_idx.isApprox(a_ref));
581581

582582
J.fill(0.);
@@ -594,12 +594,15 @@ BOOST_AUTO_TEST_CASE(test_frame_jacobian_time_variation)
594594
// Regarding to the LOCAL_WORLD_ALIGNED frame
595595
getFrameJacobian(model, data, idx, LOCAL_WORLD_ALIGNED, J);
596596
getFrameJacobianTimeVariation(model, data, idx, LOCAL_WORLD_ALIGNED, dJ);
597+
Data::Motion world_v_frame = data.ov[parent_idx];
598+
world_v_frame.linear().setZero();
597599

598600
v_idx = (Motion::Vector6)(J * v);
599601
BOOST_CHECK(v_idx.isApprox(v_ref_local_world_aligned));
600602

601603
a_idx = (Motion::Vector6)(J * a + dJ * v);
602-
BOOST_CHECK(a_idx.isApprox(a_ref_local_world_aligned));
604+
BOOST_CHECK(
605+
a_idx.isApprox(world_v_frame.cross(wMf.act(v_ref_local)) + a_ref_local_world_aligned));
603606

604607
// compare to finite differencies
605608
{
@@ -617,7 +620,6 @@ BOOST_AUTO_TEST_CASE(test_frame_jacobian_time_variation)
617620
J_ref_local_world_aligned.fill(0.);
618621
computeJointJacobians(model, data_ref, q);
619622
updateFramePlacements(model, data_ref);
620-
const SE3 & oMf_q = data_ref.oMf[idx];
621623
getFrameJacobian(model, data_ref, idx, WORLD, J_ref_world);
622624
getFrameJacobian(model, data_ref, idx, LOCAL, J_ref_local);
623625
getFrameJacobian(model, data_ref, idx, LOCAL_WORLD_ALIGNED, J_ref_local_world_aligned);
@@ -630,21 +632,11 @@ BOOST_AUTO_TEST_CASE(test_frame_jacobian_time_variation)
630632
J_ref_plus_local_world_aligned.fill(0.);
631633
computeJointJacobians(model, data_ref_plus, q_plus);
632634
updateFramePlacements(model, data_ref_plus);
633-
const SE3 & oMf_q_plus = data_ref_plus.oMf[idx];
634635
getFrameJacobian(model, data_ref_plus, idx, WORLD, J_ref_plus_world);
635636
getFrameJacobian(model, data_ref_plus, idx, LOCAL, J_ref_plus_local);
636637
getFrameJacobian(
637638
model, data_ref_plus, idx, LOCAL_WORLD_ALIGNED, J_ref_plus_local_world_aligned);
638639

639-
// Move J_ref_plus_local to reference frame
640-
J_ref_plus_local = (oMf_q.inverse() * oMf_q_plus).toActionMatrix() * (J_ref_plus_local);
641-
642-
// Move J_ref_plus_local_world_aligned to reference frame
643-
SE3 oMf_translation = SE3::Identity();
644-
oMf_translation.translation() = oMf_q_plus.translation() - oMf_q.translation();
645-
J_ref_plus_local_world_aligned =
646-
oMf_translation.toActionMatrix() * (J_ref_plus_local_world_aligned);
647-
648640
Data::Matrix6x dJ_ref_world(6, model.nv), dJ_ref_local(6, model.nv),
649641
dJ_ref_local_world_aligned(6, model.nv);
650642
dJ_ref_world.fill(0.);

0 commit comments

Comments
 (0)