Skip to content
Parker Lusk edited this page Oct 27, 2017 · 1 revision

The ROS tf Package

In simulation, we use a ROS/Gazebo plugin in the platform.xacro to link to truth. This plugin connects the position of the base of the platform (the topside of the base) to the NED inertial frame (world_ned). In platform_plugin.cpp we find:

math::Pose inertial = base_link_->GetWorldPose();

// Note the conversion from NWU to NED via the negative signs on y and z -- both on pos and rot.
tf::Vector3 origin_ned = tf::Vector3(inertial.pos.x, -inertial.pos.y, -inertial.pos.z);
tf::Quaternion quat_ned = tf::Quaternion(inertial.rot.x, -inertial.rot.y, -inertial.rot.z, inertial.rot.w);

// Publish the transform to get from the world_ned (parent) frame to the platform_base (child) frame
tf::StampedTransform transform;
transform.setOrigin(origin_ned);
transform.setRotation(quat_ned);
br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world_ned", "platform_base"));

The transform that is being published has world_ned as the parent frame and platform_base as the child frame. This means that the origin and rotation are expressed in the world_ned frame to get you from world_ned to platform_base.

Note that we use a pose measurement w.r.t the inertial NWU frame, but we transform it to be expressed in the inertial NED frame before using it as the rotation and translation to get from world_ned to platform_base.

To view this transform, we use rosrun tf tf_echo <source_frame> <target_frame>. This command can be confusing because here we are considering transforming the data, not coordinate frames. This displays the transform to get from data in the target_frame into the source_frame. Therefore, it you want to see the transform required to get from world_ned to platform_base, you would use the following command:

$ rosrun tf tf_echo world_ned platform_base

Resources

Clone this wiki locally