16
16
*/
17
17
#include < string>
18
18
19
+ #include < ignition/math/Pose3.hh>
20
+ #include < ignition/math/Quaternion.hh>
21
+ #include < ignition/math/Vector3.hh>
22
+
19
23
#include " gazebo/msgs/msgs.hh"
20
24
#include " gazebo/physics/physics.hh"
21
25
#include " boxes.hh"
@@ -39,16 +43,16 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
39
43
ASSERT_NE (world, nullptr );
40
44
41
45
// Verify physics engine type
42
- physics::PhysicsEnginePtr physics = world->GetPhysicsEngine ();
46
+ physics::PhysicsEnginePtr physics = world->Physics ();
43
47
ASSERT_NE (physics, nullptr );
44
48
ASSERT_EQ (physics->GetType (), _physicsEngine);
45
49
46
50
// get gravity value
47
51
if (!_complex)
48
52
{
49
- physics ->SetGravity (math::Vector3 ::Zero);
53
+ world ->SetGravity (ignition:: math::Vector3d ::Zero);
50
54
}
51
- math::Vector3 g = physics-> GetGravity ();
55
+ ignition:: math::Vector3d g = world-> Gravity ();
52
56
53
57
// Box size
54
58
const double dx = 0.1 ;
@@ -59,9 +63,9 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
59
63
const double Ixx = 0.80833333 ;
60
64
const double Iyy = 0.68333333 ;
61
65
const double Izz = 0.14166667 ;
62
- const math::Matrix3 I0 (Ixx, 0.0 , 0.0
63
- , 0.0 , Iyy, 0.0
64
- , 0.0 , 0.0 , Izz);
66
+ const ignition:: math::Matrix3d I0 (Ixx, 0.0 , 0.0
67
+ , 0.0 , Iyy, 0.0
68
+ , 0.0 , 0.0 , Izz);
65
69
66
70
// Create box with inertia based on box of uniform density
67
71
msgs::Model msgModel;
@@ -79,10 +83,10 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
79
83
physics::LinkPtr link ;
80
84
81
85
// initial linear velocity in global frame
82
- math::Vector3 v0;
86
+ ignition:: math::Vector3d v0;
83
87
84
88
// initial angular velocity in global frame
85
- math::Vector3 w0;
89
+ ignition:: math::Vector3d w0;
86
90
87
91
// initial energy value
88
92
double E0 ;
@@ -123,21 +127,21 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
123
127
link ->SetLinearVel (v0);
124
128
link ->SetAngularVel (w0);
125
129
}
126
- ASSERT_EQ (v0, link ->GetWorldCoGLinearVel ());
127
- ASSERT_EQ (w0, link ->GetWorldAngularVel ());
128
- ASSERT_EQ (I0, link ->GetInertial ()->GetMOI ());
130
+ ASSERT_EQ (v0, link ->WorldCoGLinearVel ());
131
+ ASSERT_EQ (w0, link ->WorldAngularVel ());
132
+ ASSERT_EQ (I0, link ->GetInertial ()->MOI ());
129
133
ASSERT_NEAR (link ->GetWorldEnergy (), E0 , 1e-6 );
130
134
131
135
// initial time
132
- common::Time t0 = world->GetSimTime ();
136
+ common::Time t0 = world->SimTime ();
133
137
134
138
// initial linear position in global frame
135
- math::Vector3 p0 = link ->GetWorldInertialPose ().pos ;
139
+ ignition:: math::Vector3d p0 = link ->WorldInertialPose ().Pos () ;
136
140
137
141
// initial angular momentum in global frame
138
- math::Vector3 H0 = link ->GetWorldAngularMomentum ();
139
- ASSERT_EQ (H0, math::Vector3 (Ixx, Iyy, Izz) * w0);
140
- double H0mag = H0.GetLength ();
142
+ ignition:: math::Vector3d H0 = link ->WorldAngularMomentum ();
143
+ ASSERT_EQ (H0, ignition:: math::Vector3d (Ixx, Iyy, Izz) * w0);
144
+ double H0mag = H0.Length ();
141
145
142
146
// change step size after setting initial conditions
143
147
// since simbody requires a time step
@@ -146,11 +150,11 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
146
150
int steps = ceil (simDuration / _dt);
147
151
148
152
// variables to compute statistics on
149
- math::Vector3Stats linearPositionError;
150
- math::Vector3Stats linearVelocityError;
151
- math::Vector3Stats angularPositionError;
152
- math::Vector3Stats angularMomentumError;
153
- math::SignalStats energyError;
153
+ ignition:: math::Vector3Stats linearPositionError;
154
+ ignition:: math::Vector3Stats linearVelocityError;
155
+ ignition:: math::Vector3Stats angularPositionError;
156
+ ignition:: math::Vector3Stats angularMomentumError;
157
+ ignition:: math::SignalStats energyError;
154
158
{
155
159
const std::string statNames = " maxAbs" ;
156
160
EXPECT_TRUE (linearPositionError.InsertStatistics (statNames));
@@ -168,34 +172,34 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
168
172
world->Step (1 );
169
173
170
174
// current time
171
- double t = (world->GetSimTime () - t0).Double ();
175
+ double t = (world->SimTime () - t0).Double ();
172
176
173
177
// linear velocity error
174
- math::Vector3 v = link ->GetWorldCoGLinearVel ();
178
+ ignition:: math::Vector3d v = link ->WorldCoGLinearVel ();
175
179
linearVelocityError.InsertData (v - (v0 + g*t));
176
180
177
181
// linear position error
178
- math::Vector3 p = link ->GetWorldInertialPose ().pos ;
182
+ ignition:: math::Vector3d p = link ->WorldInertialPose ().Pos () ;
179
183
linearPositionError.InsertData (p - (p0 + v0 * t + 0.5 *g*t*t));
180
184
181
185
// angular momentum error
182
- math::Vector3 H = link ->GetWorldAngularMomentum ();
186
+ ignition:: math::Vector3d H = link ->WorldAngularMomentum ();
183
187
angularMomentumError.InsertData ((H - H0) / H0mag);
184
188
185
189
// angular position error
186
190
if (!_complex)
187
191
{
188
- math::Vector3 a = link ->GetWorldInertialPose ().rot . GetAsEuler ();
189
- math::Quaternion angleTrue (w0 * t);
190
- angularPositionError.InsertData (a - angleTrue.GetAsEuler ());
192
+ ignition:: math::Vector3d a = link ->WorldInertialPose ().Rot (). Euler ();
193
+ ignition:: math::Quaterniond angleTrue (w0 * t);
194
+ angularPositionError.InsertData (a - angleTrue.Euler ());
191
195
}
192
196
193
197
// energy error
194
198
energyError.InsertData ((link ->GetWorldEnergy () - E0 ) / E0 );
195
199
}
196
200
common::Time elapsedTime = common::Time::GetWallTime () - startTime;
197
201
this ->Record (" wallTime" , elapsedTime.Double ());
198
- common::Time simTime = (world->GetSimTime () - t0).Double ();
202
+ common::Time simTime = (world->SimTime () - t0).Double ();
199
203
ASSERT_NEAR (simTime.Double (), simDuration, _dt*1.1 );
200
204
this ->Record (" simTime" , simTime.Double ());
201
205
this ->Record (" timeRatio" , elapsedTime.Double () / simTime.Double ());
0 commit comments