Getting positional data of custom models

I’ve edited the default IRIS model so the original drone is now holding a swinging payload beneath it. I’ve been struggling with finding a way to get the position data of the payload - which will swing beneath the drone as it flies.

Currently, my approach is to use a plugin. I went into the Firmware/Tools/sitl_gazebo/src folder and created a plugin for my custom IRIS drone model.

I’m new to px4/gazebo, so I followed the Gazebo tutorial to create the plugin. How can I edit this to extract the position of the payload model?

My current plugin file looks like:

#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <ignition/math/Vector3.hh>

namespace gazebo
{
  class ModelPush : public ModelPlugin
  {
    public: ModelPush() : ModelPlugin()
            {
              printf("Model Plugin OKAY\n");
            }
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
    {
      // Store the pointer to the model
      this->model = _parent;

      // Listen to the update event. This event is broadcast every
      // simulation iteration.
      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          std::bind(&ModelPush::OnUpdate, this));
    }

    // Called by the world update start event
    public: void OnUpdate()
    {
      // Apply a small linear velocity to the model.
      this->model->SetLinearVel(ignition::math::Vector3d(.3, 0, 0));
    }

    // Pointer to the model
    private: physics::ModelPtr model;

    // Pointer to the update event connection
    private: event::ConnectionPtr updateConnection;
  };

  // Register this plugin with the simulator
  GZ_REGISTER_MODEL_PLUGIN(ModelPush)
}

Or alternatively, is this the wrong approach? Is there a better way to get the location of an added custom model?

Thanks a lot - any help would be hugely appreciated!