Skip to content

Commit eb8d615

Browse files
committed
Move functions to Base.hh
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com> Generated-by: Claude Opus 4.5
1 parent 8fb7096 commit eb8d615

8 files changed

Lines changed: 25 additions & 17 deletions

File tree

bullet-featherstone/src/Base.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#include <gz/common/Console.hh>
4949
#include <gz/math/eigen3/Conversions.hh>
50+
#include <gz/math/SemanticVersion.hh>
5051
#include <gz/physics/Implements.hh>
5152

5253
namespace gz {
@@ -360,6 +361,10 @@ class Base : public Implements3d<FeatureList<Feature>>
360361
// Note: Entity ID 0 is reserved for the "engine"
361362
public: std::size_t entityCount = 1;
362363

364+
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
365+
public: const gz::math::SemanticVersion engineVersion{
366+
BT_BULLET_VERSION / 100, BT_BULLET_VERSION % 100};
367+
363368
public: inline std::size_t GetNextEntity()
364369
{
365370
return entityCount++;

bullet-featherstone/src/EntityManagementFeatures.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,7 @@ const std::string &EntityManagementFeatures::GetEngineName(
308308
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
309309
const Identity &) const
310310
{
311-
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
312-
int ver = BT_BULLET_VERSION;
313-
static const gz::math::SemanticVersion version(ver / 100, ver % 100);
314-
return version;
311+
return this->engineVersion;
315312
}
316313

317314
/////////////////////////////////////////////////

bullet/src/Base.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <map>
3030

3131
#include <gz/common/Console.hh>
32+
#include <gz/math/SemanticVersion.hh>
3233
#include <gz/physics/Implements.hh>
3334
#include <gz/math/eigen3/Conversions.hh>
3435

@@ -174,6 +175,10 @@ inline math::Pose3d convertToGz(const btTransform &_pose)
174175

175176
class Base : public Implements3d<FeatureList<Feature>>
176177
{
178+
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
179+
public: const gz::math::SemanticVersion engineVersion{
180+
BT_BULLET_VERSION / 100, BT_BULLET_VERSION % 100};
181+
177182
public: std::size_t entityCount = 0;
178183

179184
public: inline std::size_t GetNextEntity()

bullet/src/EntityManagementFeatures.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ const std::string &EntityManagementFeatures::GetEngineName(
122122
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
123123
const Identity &) const
124124
{
125-
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
126-
int ver = BT_BULLET_VERSION;
127-
static const gz::math::SemanticVersion version(ver / 100, ver % 100);
128-
return version;
125+
return this->engineVersion;
129126
}
130127

131128
std::size_t EntityManagementFeatures::GetEngineIndex(const Identity &) const

dartsim/src/Base.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <gz/common/Console.hh>
3838
#include <gz/math/eigen3/Conversions.hh>
3939
#include <gz/math/Inertial.hh>
40+
#include <gz/math/SemanticVersion.hh>
4041
#include <gz/physics/Implements.hh>
4142

4243
#include <sdf/Types.hh>
@@ -261,6 +262,12 @@ struct EntityStorage
261262

262263
class Base : public Implements3d<FeatureList<Feature>>
263264
{
265+
public: const gz::math::SemanticVersion engineVersion = [](){
266+
gz::math::SemanticVersion v;
267+
v.Parse(DART_VERSION);
268+
return v;
269+
}();
270+
264271
public: using DartWorld = dart::simulation::World;
265272
public: using DartWorldPtr = dart::simulation::WorldPtr;
266273
public: using DartSkeletonPtr = dart::dynamics::SkeletonPtr;

dartsim/src/EntityManagementFeatures.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,7 @@ const std::string &EntityManagementFeatures::GetEngineName(
140140
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
141141
const Identity &/*_engineID*/) const
142142
{
143-
static const gz::math::SemanticVersion version = [](){
144-
gz::math::SemanticVersion v;
145-
v.Parse(DART_VERSION);
146-
return v;
147-
}();
148-
return version;
143+
return this->engineVersion;
149144
}
150145

151146
/////////////////////////////////////////////////

tpe/plugin/src/Base.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef GZ_PHYSICS_TPE_PLUGIN_SRC_BASE_HH_
1919
#define GZ_PHYSICS_TPE_PLUGIN_SRC_BASE_HH_
2020

21+
#include <gz/math/SemanticVersion.hh>
2122
#include <gz/physics/Implements.hh>
2223

2324
#include <map>
@@ -61,6 +62,9 @@ struct CollisionInfo
6162

6263
class Base : public Implements3d<FeatureList<Feature>>
6364
{
65+
// TPE versioning is internal to gz-physics
66+
public: const gz::math::SemanticVersion engineVersion{1, 0};
67+
6468
public: inline Identity InitiateEngine(std::size_t /*_engineID*/) override
6569
{
6670
return this->GenerateIdentity(0);

tpe/plugin/src/EntityManagementFeatures.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ const std::string &EntityManagementFeatures::GetEngineName(
3535
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
3636
const Identity &) const
3737
{
38-
// TPE versioning is internal to gz-physics, set the version here
39-
static const gz::math::SemanticVersion version(1, 0);
40-
return version;
38+
return this->engineVersion;
4139
}
4240

4341
/////////////////////////////////////////////////

0 commit comments

Comments
 (0)