From 309e611b93fa8bef74bbae31a5ceae696bb245ba Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Mon, 2 Oct 2023 20:12:01 -0700 Subject: [PATCH] Add example joint_mimic_rack_pinion.urdf and test Signed-off-by: Steve Peters --- test/integration/joint_axis_dom.cc | 26 ++++++ test/sdf/joint_mimic_rack_pinion.urdf | 125 ++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 test/sdf/joint_mimic_rack_pinion.urdf diff --git a/test/integration/joint_axis_dom.cc b/test/integration/joint_axis_dom.cc index 4aea8879b..c6ae94635 100644 --- a/test/integration/joint_axis_dom.cc +++ b/test/integration/joint_axis_dom.cc @@ -559,3 +559,29 @@ TEST(DOMJointAxis, ParseMimicInvalidLeaderAxis) EXPECT_EQ(errors[2].Message(), errorMsg2) << errors[2]; EXPECT_EQ(errors[3].Message(), errorMsg3) << errors[3]; } + +///////////////////////////////////////////////// +TEST(DOMJointAxis, ParseMimicURDF) +{ + const std::string testFile = + sdf::testing::TestFile("sdf", "joint_mimic_rack_pinion.urdf"); + + sdf::Root root; + auto errors = root.Load(testFile); + EXPECT_TRUE(errors.empty()) << errors; + + auto model = root.Model(); + ASSERT_NE(nullptr, model); + auto followerJoint = model->JointByName("rack_joint"); + ASSERT_NE(nullptr, followerJoint); + auto followerJointAxis = followerJoint->Axis(); + ASSERT_NE(nullptr, followerJointAxis); + auto mimicJoint = followerJointAxis->Mimic(); + ASSERT_NE(std::nullopt, mimicJoint); + + EXPECT_EQ(mimicJoint->Joint(), "upper_joint"); + EXPECT_EQ(mimicJoint->Axis(), "axis"); + EXPECT_DOUBLE_EQ(mimicJoint->Multiplier(), 0.105); + EXPECT_DOUBLE_EQ(mimicJoint->Offset(), 0); + EXPECT_DOUBLE_EQ(mimicJoint->Reference(), 0); +} diff --git a/test/sdf/joint_mimic_rack_pinion.urdf b/test/sdf/joint_mimic_rack_pinion.urdf new file mode 100644 index 000000000..6adf32034 --- /dev/null +++ b/test/sdf/joint_mimic_rack_pinion.urdf @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +