Skip to content

Commit fe10bbf

Browse files
committedAug 21, 2020
Support gazebo9, 10, 11
Signed-off-by: Steve Peters <[email protected]>
1 parent f9f0c34 commit fe10bbf

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed
 

‎CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ enable_testing()
55
include(FindBoost)
66
find_package(Boost ${MIN_BOOST_VERSION} REQUIRED filesystem thread system)
77

8-
find_package(GAZEBO 9)
8+
find_package(GAZEBO 11)
99
if (NOT GAZEBO_FOUND)
10-
find_package(GAZEBO 8)
10+
find_package(GAZEBO 10)
1111
endif()
1212
if (NOT GAZEBO_FOUND)
13-
find_package(GAZEBO 7)
13+
find_package(GAZEBO 9)
1414
endif()
1515
if (NOT GAZEBO_FOUND)
1616
message (STATUS "Looking for gazebo - not found")
17-
message (FATAL_ERROR "Missing: Gazebo version 7, 8, or 9.")
17+
message (FATAL_ERROR "Missing: Gazebo version 9, 10, or 11.")
1818
endif()
1919
include_directories(${GAZEBO_INCLUDE_DIRS}
2020
${PROJECT_SOURCE_DIR}/gtest/include

‎boxes.cc

+33-29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
*/
1717
#include <string>
1818

19+
#include <ignition/math/Pose3.hh>
20+
#include <ignition/math/Quaternion.hh>
21+
#include <ignition/math/Vector3.hh>
22+
1923
#include "gazebo/msgs/msgs.hh"
2024
#include "gazebo/physics/physics.hh"
2125
#include "boxes.hh"
@@ -39,16 +43,16 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
3943
ASSERT_NE(world, nullptr);
4044

4145
// Verify physics engine type
42-
physics::PhysicsEnginePtr physics = world->GetPhysicsEngine();
46+
physics::PhysicsEnginePtr physics = world->Physics();
4347
ASSERT_NE(physics, nullptr);
4448
ASSERT_EQ(physics->GetType(), _physicsEngine);
4549

4650
// get gravity value
4751
if (!_complex)
4852
{
49-
physics->SetGravity(math::Vector3::Zero);
53+
world->SetGravity(ignition::math::Vector3d::Zero);
5054
}
51-
math::Vector3 g = physics->GetGravity();
55+
ignition::math::Vector3d g = world->Gravity();
5256

5357
// Box size
5458
const double dx = 0.1;
@@ -59,9 +63,9 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
5963
const double Ixx = 0.80833333;
6064
const double Iyy = 0.68333333;
6165
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);
6569

6670
// Create box with inertia based on box of uniform density
6771
msgs::Model msgModel;
@@ -79,10 +83,10 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
7983
physics::LinkPtr link;
8084

8185
// initial linear velocity in global frame
82-
math::Vector3 v0;
86+
ignition::math::Vector3d v0;
8387

8488
// initial angular velocity in global frame
85-
math::Vector3 w0;
89+
ignition::math::Vector3d w0;
8690

8791
// initial energy value
8892
double E0;
@@ -123,21 +127,21 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
123127
link->SetLinearVel(v0);
124128
link->SetAngularVel(w0);
125129
}
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());
129133
ASSERT_NEAR(link->GetWorldEnergy(), E0, 1e-6);
130134

131135
// initial time
132-
common::Time t0 = world->GetSimTime();
136+
common::Time t0 = world->SimTime();
133137

134138
// initial linear position in global frame
135-
math::Vector3 p0 = link->GetWorldInertialPose().pos;
139+
ignition::math::Vector3d p0 = link->WorldInertialPose().Pos();
136140

137141
// 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();
141145

142146
// change step size after setting initial conditions
143147
// since simbody requires a time step
@@ -146,11 +150,11 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
146150
int steps = ceil(simDuration / _dt);
147151

148152
// 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;
154158
{
155159
const std::string statNames = "maxAbs";
156160
EXPECT_TRUE(linearPositionError.InsertStatistics(statNames));
@@ -168,34 +172,34 @@ void BoxesTest::Boxes(const std::string &_physicsEngine
168172
world->Step(1);
169173

170174
// current time
171-
double t = (world->GetSimTime() - t0).Double();
175+
double t = (world->SimTime() - t0).Double();
172176

173177
// linear velocity error
174-
math::Vector3 v = link->GetWorldCoGLinearVel();
178+
ignition::math::Vector3d v = link->WorldCoGLinearVel();
175179
linearVelocityError.InsertData(v - (v0 + g*t));
176180

177181
// linear position error
178-
math::Vector3 p = link->GetWorldInertialPose().pos;
182+
ignition::math::Vector3d p = link->WorldInertialPose().Pos();
179183
linearPositionError.InsertData(p - (p0 + v0 * t + 0.5*g*t*t));
180184

181185
// angular momentum error
182-
math::Vector3 H = link->GetWorldAngularMomentum();
186+
ignition::math::Vector3d H = link->WorldAngularMomentum();
183187
angularMomentumError.InsertData((H - H0) / H0mag);
184188

185189
// angular position error
186190
if (!_complex)
187191
{
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());
191195
}
192196

193197
// energy error
194198
energyError.InsertData((link->GetWorldEnergy() - E0) / E0);
195199
}
196200
common::Time elapsedTime = common::Time::GetWallTime() - startTime;
197201
this->Record("wallTime", elapsedTime.Double());
198-
common::Time simTime = (world->GetSimTime() - t0).Double();
202+
common::Time simTime = (world->SimTime() - t0).Double();
199203
ASSERT_NEAR(simTime.Double(), simDuration, _dt*1.1);
200204
this->Record("simTime", simTime.Double());
201205
this->Record("timeRatio", elapsedTime.Double() / simTime.Double());

‎collide_spheres.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ void CollideTest::Spheres(const std::string &_physicsEngine
4444
ASSERT_NE(world, nullptr);
4545

4646
// Verify physics engine type
47-
physics::PhysicsEnginePtr physics = world->GetPhysicsEngine();
47+
physics::PhysicsEnginePtr physics = world->Physics();
4848
ASSERT_NE(physics, nullptr);
4949
ASSERT_EQ(physics->GetType(), _physicsEngine);
5050

5151
// Disable physics updates
52-
world->EnablePhysicsEngine(false);
52+
world->SetPhysicsEnabled(false);
5353

5454
// Models with 1mm and 100mm radius
55-
auto models = world->GetModels();
55+
auto models = world->Models();
5656
mapSeparatedModels mmRadius, dmRadius;
5757
for (const auto model : models)
5858
{
@@ -115,16 +115,16 @@ void CollideTest::Spheres(const std::string &_physicsEngine
115115
{
116116
auto modelA = mmPair.second.first;
117117
auto modelB = mmPair.second.second;
118-
auto positionDiff = modelA->GetWorldPose().Ign().Pos()
119-
- modelB->GetWorldPose().Ign().Pos();
118+
auto positionDiff = modelA->WorldPose().Pos()
119+
- modelB->WorldPose().Pos();
120120
EXPECT_DOUBLE_EQ(positionDiff.Length(), mmPair.first * 1e-3);
121121
}
122122
for (const auto dmPair : dmRadius)
123123
{
124124
auto modelA = dmPair.second.first;
125125
auto modelB = dmPair.second.second;
126-
auto positionDiff = modelA->GetWorldPose().Ign().Pos()
127-
- modelB->GetWorldPose().Ign().Pos();
126+
auto positionDiff = modelA->WorldPose().Pos()
127+
- modelB->WorldPose().Pos();
128128
EXPECT_DOUBLE_EQ(positionDiff.Length(), dmPair.first * 1e-1);
129129
}
130130

0 commit comments

Comments
 (0)
Please sign in to comment.