Skip to content
Snippets Groups Projects
Commit a7ebecca authored by Jennifer Buehler's avatar Jennifer Buehler
Browse files

Add compatibility for gazebo 11

parent baf0f033
No related branches found
No related tags found
No related merge requests found
......@@ -157,7 +157,7 @@ shape_msgs::SolidPrimitive * GazeboObjectInfo::getSolidPrimitive(physics::Collis
else
{
ROS_WARN("shape type %i of collision %s not supported. Using bounding box instead. ", c->GetShapeType(),c->GetName().c_str());
gz_math::Box box = GetBoundingBox(*c);
GzBox box = GetBoundingBox(*c);
GzVector3 bb = GetBoundingBoxDimensions(box);
if ((GetX(bb) < 1e-05) || (GetY(bb) < 1e-05) || (GetZ(bb) < 1e-05)){
ROS_WARN_ONCE("Skipping coll %s because its bounding box is flat",c->GetName().c_str());
......
......@@ -7,13 +7,22 @@ namespace gazebo
{
// typedefs
#if GAZEBO_MAJOR_VERSION >= 8
#if GAZEBO_MAJOR_VERSION >= 11
namespace gz_math = ignition::math;
typedef gz_math::Pose3d GzPose3;
typedef gz_math::Vector3d GzVector3;
typedef gz_math::Quaterniond GzQuaternion;
typedef gz_math::Matrix4d GzMatrix4;
typedef gz_math::Matrix3d GzMatrix3;
typedef gz_math::AxisAlignedBox GzBox;
#elif GAZEBO_MAJOR_VERSION >= 8
namespace gz_math = ignition::math;
typedef gz_math::Pose3d GzPose3;
typedef gz_math::Vector3d GzVector3;
typedef gz_math::Quaterniond GzQuaternion;
typedef gz_math::Matrix4d GzMatrix4;
typedef gz_math::Matrix3d GzMatrix3;
typedef gz_math::Box GzBox;
#else
namespace gz_math = gazebo::math;
typedef gz_math::Pose GzPose3;
......@@ -21,8 +30,10 @@ typedef gz_math::Vector3 GzVector3;
typedef gz_math::Quaternion GzQuaternion;
typedef gz_math::Matrix4 GzMatrix4;
typedef gz_math::Matrix3 GzMatrix3;
typedef gz_math::Box GzBox;
#endif
// Helper functions
// //////////////////////////
......@@ -116,7 +127,7 @@ std::string GetName(const T& t)
///////////////////////////////////////////////////////////////////////////////
template<typename T>
gz_math::Box GetBoundingBox(const T &t)
GzBox GetBoundingBox(const T &t)
{
#if GAZEBO_MAJOR_VERSION >= 8
return t.BoundingBox();
......@@ -126,7 +137,7 @@ gz_math::Box GetBoundingBox(const T &t)
}
///////////////////////////////////////////////////////////////////////////////
GzVector3 GetBoundingBoxDimensions(const gz_math::Box &box);
GzVector3 GetBoundingBoxDimensions(const GzBox &box);
///////////////////////////////////////////////////////////////////////////////
template<typename T>
......
......@@ -314,9 +314,12 @@ gazebo::physics::Model_V gazebo::GetModels(
}
///////////////////////////////////////////////////////////////////////////////
gazebo::GzVector3 gazebo::GetBoundingBoxDimensions(const gz_math::Box &box)
gazebo::GzVector3 gazebo::GetBoundingBoxDimensions(const GzBox &box)
{
#if GAZEBO_MAJOR_VERSION >= 8
#if GAZEBO_MAJOR_VERSION >= 11
auto const size = box.Size();
GzVector3 bb(size.X(), size.Y(), size.Z());
#elif GAZEBO_MAJOR_VERSION >= 8
GzVector3 bb(box.XLength(), box.YLength(), box.ZLength());
#else
GzVector3 bb(box.GetXLength(), box.GetYLength(), box.GetZLength());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment