Skip to content

Commit fcac14d

Browse files
author
Addisu Z. Taddese
committed
Add @rotation_format and @Degrees to //inertial/pose
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
1 parent 7b09f70 commit fcac14d

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

sdf/1.9/inertial.sdf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@
77
</element>
88

99
<element name="pose" type="pose" default="0 0 0 0 0 0" required="0">
10-
<description>This is the pose of the inertial reference frame. The origin of the inertial reference frame needs to be at the center of gravity. The axes of the inertial reference frame do not need to be aligned with the principal axes of the inertia.</description>
10+
<description>
11+
A pose (translation, rotation) expressed in the frame of the link. The first three components (x, y, z) represent the position of the element's origin (in the @relative_to frame). The rotation component represent the orientation of the element as either a sequence of Euler rotations (r, p, y), see http://sdformat.org/tutorials?tut=specify_pose, or as a quaternion (x, y, z, w), where w is the real component.
12+
</description>
13+
14+
<attribute name="rotation_format" type="string" default="euler_rpy" required="0">
15+
<description>'euler_rpy' by default. Supported rotation formats are
16+
'euler_rpy', Euler angles representation in roll, pitch, yaw. The pose is expected to have 6 values.
17+
'quat_xyzw', Quaternion representation in x, y, z, w. The pose is expected to have 7 values.
18+
</description>
19+
</attribute>
20+
21+
<attribute name="degrees" type="bool" default="false" required="0">
22+
<description>
23+
Whether or not the euler angles are in degrees, otherwise they will be interpreted as radians by default.
24+
</description>
25+
</attribute>
26+
1127
</element>
1228

1329
<element name="inertia" required="0">

test/integration/pose_1_9_sdf.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#include <ignition/math/Angle.hh>
2424
#include <ignition/math/Pose3.hh>
2525
#include <ignition/math/Vector3.hh>
26+
#include "sdf/Actor.hh"
2627
#include "sdf/Element.hh"
2728
#include "sdf/Error.hh"
29+
#include "sdf/Link.hh"
2830
#include "sdf/Model.hh"
2931
#include "sdf/Root.hh"
3032
#include "sdf/World.hh"
@@ -34,7 +36,7 @@
3436
#include "test_utils.hh"
3537

3638
//////////////////////////////////////////////////
37-
TEST(Pose1_9, ModelPose)
39+
TEST(Pose1_9, PoseExpressionFormats)
3840
{
3941
using Pose = ignition::math::Pose3d;
4042

@@ -136,6 +138,25 @@ TEST(Pose1_9, ModelPose)
136138
ASSERT_NE(nullptr, model);
137139
ASSERT_EQ("model_quat_xyzw_degrees_false", model->Name());
138140
EXPECT_EQ(Pose(1, 2, 3, 0.7071068, 0.7071068, 0, 0), model->RawPose());
141+
142+
// //inertial/pose
143+
model = world->ModelByIndex(17);
144+
ASSERT_NE(nullptr, model);
145+
ASSERT_EQ("model_with_inertia_pose", model->Name());
146+
{
147+
const auto link = model->LinkByIndex(0);
148+
ASSERT_NE(nullptr, link);
149+
ASSERT_EQ("link_euler_rpy_degrees_true", link->Name());
150+
EXPECT_EQ(Pose(1, 2, 3, IGN_DTOR(90), IGN_DTOR(180), IGN_DTOR(270)),
151+
link->Inertial().Pose());
152+
}
153+
{
154+
const auto link = model->LinkByIndex(1);
155+
ASSERT_NE(nullptr, link);
156+
ASSERT_EQ("link_quat_xyzw", link->Name());
157+
EXPECT_EQ(Pose(1, 2, 3, 0.7071068, 0.7071068, 0, 0),
158+
link->Inertial().Pose());
159+
}
139160
}
140161

141162
//////////////////////////////////////////////////

test/sdf/pose_1_9.sdf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,21 @@
101101
<link name="link"/>
102102
</model>
103103

104+
<model name="model_with_inertia_pose">
105+
<link name="link_euler_rpy_degrees_true">
106+
<inertial>
107+
<pose rotation_format="euler_rpy" degrees="true">1 2 3 90 180 270</pose>
108+
<mass>10</mass>
109+
</inertial>
110+
</link>
111+
<link name="link_quat_xyzw">
112+
<inertial>
113+
<pose rotation_format="quat_xyzw" degrees="false">
114+
1 2 3 0.7071068 0 0 0.7071068
115+
</pose>
116+
<mass>10</mass>
117+
</inertial>
118+
</link>
119+
</model>
104120
</world>
105121
</sdf>

0 commit comments

Comments
 (0)