Nicholas Pfaff
Nicholas Pfaff

Reputation: 711

How to get the inertial frame from Drake?

I want to obtain the RigidTransform from a body frame to the associated inertial frame. This should correspond to the SDFormat inertial/pose (example). I couldn't find an API for that. Is it possible to obtain this somehow?

My use case is that I want to compute the bounding ellipsoid for a body and then express it with respect to the inertial/ center-of-mass frame.

Edit: Maybe I'm overthinking this. Reading the SDFormat documentation, I think inertia is about the CoM and expressed in the frame indicated by pose.This would mean that pose corresponds to the frame E in Drake's SpatialInertia description. However, it might be that inertia is about the CoM but is still expressed in the body frame. In this case, my desired transform simply corresponds to the body frame.

Upvotes: 0

Views: 71

Answers (2)

Mitiguy
Mitiguy

Reputation: 191

Here are various ways to access the world frame from within C++ If you have the world body, try const Frame& frame_W = bodyObject.body_frame();

From within MultibodyPlant const Frame& frame_W = plant().world_frame(); or const Frame& frame_W = plant().world_body().body_frame();

From within the Frame class const Frame& frame_W = this->get_parent_tree().world_frame();

Upvotes: 0

Mitiguy
Mitiguy

Reputation: 191

You may want to take a look at the functions in the Drake frame class, in the file: Drake/multibody/plant/frame.h

For example, this C++ Frame method calculates and returns the rotation matrix R_WF that relates the world frame W to this frame F, as a function of the state stored in context.

  math::RotationMatrix<T>  Frame<T>::CalcRotationMatrixInWorld(
      const systems::Context<T>& context) const;

Upvotes: 0

Related Questions