[Gazebo + SITL] How do I get the pose of the UAV in relation to gazebo origin?

Hello everyone,

I am running a gazebo simulation with multiple UAVs, using mavros, and I want to get the pose of the UAV in relation to gazebo origin, how can I do this?

For example, I am spawning one of the UAVs at gazebo coordinates x=2.5, y=-5, z=0, if I subscribe to the topic /mavros/local_pition/pose I get the following msg:

header: 
  seq: 518
  stamp: 
    secs: 19
    nsecs: 472000000
  frame_id: "map"
pose: 
  position: 
    x: 0.00669627590105
    y: 0.0170770008117
    z: -0.0405758097768
  orientation: 
    x: 0.0108658369501
    y: -0.00837003212551
    z: 0.0162885346909
    w: -0.999773274988

Instead of geting ~(0,0,0) I want to get (2.5, -5, 0), is it possible to do something like this? If I could get the offset of the spawn location I could just calculate the difference myself.

Thank you

You can use gazebo_ros to subscribe to link states

1 Like

Thank you, this solved my problem.