Ignition (Gazebo) Math Library

zqiu

Z. QIU

Posted on April 28, 2022

Ignition (Gazebo) Math Library

Gazebo plugin building

Today I tried to compile an Gazebo plugin I wrote in 2014 in latest ROS (noetic) environment, unsurprisingly, there are errors and the compilation failed:

fatal error: gazebo/math/gzmath.hh: No such file or directory
    7 | #include <gazebo/math/gzmath.hh>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Enter fullscreen mode Exit fullscreen mode

I check firstly the version of Gazebo simulator on my PC, it is Gazebo 11:

Image description

Then I find this page which presents the migrations required for each new Gazebo verison.

Gazebo vs Ignition

Interesting, I see that the namespace "gazebo" has been replaced by "ignition". But why?

I see answer in its official site:

We branded the new development effort Igntion in order to differentiate it from Gazebo that had come before, which is now referred to as Gazebo Classic. Those changes have gone very well, thanks in no small part to contributions and support from our worldwide community of users and other stakeholders.

In 2022 we encountered a trademark obstacle regarding the use of the name "Ignition". We used this as an opportunity to switch back the widely known name "Gazebo". Going forward, the modern robotics software collection formerly known as Ignition, is now branded Gazebo.

Roadmap of Gazebo project:
Image description

Ignition Math folder structure

Below are all the files in repository /usr/include/ignition/math6/ which should provide full math support for robot kinematics.

├── math6
│ └── ignition
│ ├── math
│ │ ├── Angle.hh
│ │ ├── AxisAlignedBox.hh
│ │ ├── Box.hh
│ │ ├── Capsule.hh
│ │ ├── Color.hh
│ │ ├── config.hh
│ │ ├── Cylinder.hh
│ │ ├── detail
│ │ │ ├── Box.hh
│ │ │ ├── Capsule.hh
│ │ │ ├── Cylinder.hh
│ │ │ ├── Ellipsoid.hh
│ │ │ ├── Export.hh
│ │ │ ├── Sphere.hh
│ │ │ └── WellOrderedVector.hh
│ │ ├── DiffDriveOdometry.hh
│ │ ├── Ellipsoid.hh
│ │ ├── Export.hh
│ │ ├── Filter.hh
│ │ ├── Frustum.hh
│ │ ├── GaussMarkovProcess.hh
│ │ ├── graph
│ │ │ ├── Edge.hh
│ │ │ ├── GraphAlgorithms.hh
│ │ │ ├── Graph.hh
│ │ │ └── Vertex.hh
│ │ ├── Helpers.hh
│ │ ├── Inertial.hh
│ │ ├── Kmeans.hh
│ │ ├── Line2.hh
│ │ ├── Line3.hh
│ │ ├── MassMatrix3.hh
│ │ ├── Material.hh
│ │ ├── MaterialType.hh
│ │ ├── Matrix3.hh
│ │ ├── Matrix4.hh
│ │ ├── MovingWindowFilter.hh
│ │ ├── OrientedBox.hh
│ │ ├── PID.hh
│ │ ├── Plane.hh
│ │ ├── Pose3.hh
│ │ ├── Quaternion.hh
│ │ ├── Rand.hh
│ │ ├── RollingMean.hh
│ │ ├── RotationSpline.hh
│ │ ├── SemanticVersion.hh
│ │ ├── SignalStats.hh
│ │ ├── SpeedLimiter.hh
│ │ ├── Sphere.hh
│ │ ├── SphericalCoordinates.hh
│ │ ├── Spline.hh
│ │ ├── Stopwatch.hh
│ │ ├── Temperature.hh
│ │ ├── Triangle3.hh
│ │ ├── Triangle.hh
│ │ ├── Vector2.hh
│ │ ├── Vector3.hh
│ │ ├── Vector3Stats.hh
│ │ └── Vector4.hh
│ └── math.hh

Improve the source code

With help of this documentaiton, I have updated some lines of my former source code. And I finally successfully built the plugin and got the .o file.

#include <ignition/math.hh>
    ...

// Load the controller
void WifibotControllerPlugin::Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
{
    ...
    ignition::math::Pose3d pose;
    ignition::math::Vector3d pos;

#if GAZEBO_MAJOR_VERSION >= 8
    pose = this->parent->WorldPose();
#else
    pose = this->parent->GetWorldPose().Ign();
#endif

    robotPose[0] = pose.Pos().X();
    robotPose[1] = pose.Pos().Y();
    tf::Quaternion qt( pose.Rot().X(), pose.Rot().Y(), pose.Rot().Z(), pose.Rot().W() );
    ...
}

    ... 

void WifibotControllerPlugin::write_position_data()
{

    ignition::math::Pose3d orig_pose;


#if GAZEBO_MAJOR_VERSION >= 8
    orig_pose = this->parent->WorldPose();
#else
    orig_pose = this->parent->GetWorldPose().Ign();
#endif


  this->parent->SetWorldPose(ignition::math::Pose3d (robotPose[0], robotPose[1],  0, 0, 0, robotPose[2]  )   );

}

Enter fullscreen mode Exit fullscreen mode

load the plugin

Now, the plugin is working properly and I can control my robot in the simulator:
Image description

💖 💪 🙅 🚩
zqiu
Z. QIU

Posted on April 28, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Ignition (Gazebo) Math Library
robotics Ignition (Gazebo) Math Library

April 28, 2022