1

I have a quadrotor, and I want to read its position in (x,y,z) using hector_gazebo_plugin and python. For now I am using libhector_gazebo_ros_gps.so file to get the latitude and longitude of the quadrotor.

But I would like to have the position of the quadrotor.

How do I do that?

Monojit Sarkar
  • 657
  • 1
  • 5
  • 15
  • What do you mean by wanting to get the (x,y,z) position? (lat, lon, alt) is the same thing just in a different frame. What frame_id do you want? – BTables Sep 24 '21 at 03:56
  • @BTables I want the cartesian coordinates (x,y,z). I am new to ROS. Would you tell me what are the frame_id avalaible? – Monojit Sarkar Sep 24 '21 at 04:55
  • frame ids are totally arbitrary in name. Here you can say (lat, lon) would be the `gps` frame since all gps coordinates will be consistent relative to each other. Cartesian only defines coordinates relative to some origin. In this context you have to define what that origin is; i.e. an initial pose that's relative, or an absolute pose such as GPS. In ROS what you're asking about is typically referred to as the `odom` frame. – BTables Sep 24 '21 at 05:04

1 Answers1

0

In ros, there are several different frames, as BTables was trying to get to. If you're trying to get a position estimation from sensor data, using the robot_localization package, familiarize yourself with the different kinds of frames and ros message types / data that go in & out of that process.

Normally in ros, there are 3 main frames: map -> odom -> base_link. The base_link is the point on the robot that represents it. The odom frame tracks integrated velocity/acceleration sensor updates to have a continuous position; it's origin is usually wherever the robot boots up. The map frame is the "real world" location of the robot. It does require an origin position and yaw, because otherwise it's arbitrary.

In your case, it seems like you want to anchor the robot within the longitude/latitude coordinate frame. My recommendation is still to pick an origin in your environment, if you can, otherwise you can use the boot-up location as your origin.

So to do that, I'm assuming your odom->base_link transform is an EKF or UKF node (from robot_localization), using the IMU data from your quadcopter. Then your map->odom transform is another EKF or UKF that also takes in an absolute position in your map frame as an update. (See example launch file (navsat notes) and yaml config file (navsat notes) and more from the github). You can then use your fix topic (sensor_msgs/NavSatFix) from hector gazebo gps plugin with the navsat_transform_node to get a position update for your estimator above and map transforms to the global or utm coordinate system.

If you don't care about your position with respect to the world coming out, this gets a bit simpler, otherwise this also has the features to report your position back out to lat/long.

JWCS
  • 1,120
  • 1
  • 7
  • 17