mavros中实现东北天坐标系到北东地坐标系转换的代码

/mavros/mavros/include/mavros/frame_tf.hpp

/**
 * @brief Transform from attitude represented WRT NED frame to attitude
 *		  represented WRT ENU frame
 */
template<class T>
inline T transform_orientation_ned_enu(const T & in)
{
  return detail::transform_orientation(in, StaticTF::NED_TO_ENU);
}

/mavros/mavros/src/lib/ftf_frame_conversions.cpp

/**
 * @brief Static quaternion needed for rotating between ENU and NED frames
 * NED to ENU: +PI/2 rotation about Z (Down) followed by a +PI rotation around X (old North/new East)
 * ENU to NED: +PI/2 rotation about Z (Up) followed by a +PI rotation about X (old East/new North)
 */
static const auto NED_ENU_Q = quaternion_from_rpy(M_PI, 0.0, M_PI_2);

/mavros/mavros/src/lib/ftf_frame_conversions.cpp

Eigen::Quaterniond transform_orientation(const Eigen::Quaterniond & q, const StaticTF transform)
{
  // Transform the attitude representation from frame to frame.
  // The proof for this transform can be seen
  // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/
  switch (transform) {
    case StaticTF::NED_TO_ENU:
    case StaticTF::ENU_TO_NED:
      return NED_ENU_Q * q;

    case StaticTF::AIRCRAFT_TO_BASELINK:
    case StaticTF::BASELINK_TO_AIRCRAFT:
      return q * AIRCRAFT_BASELINK_Q;

    case StaticTF::ABSOLUTE_FRAME_AIRCRAFT_TO_BASELINK:
    case StaticTF::ABSOLUTE_FRAME_BASELINK_TO_AIRCRAFT:
      return AIRCRAFT_BASELINK_Q * q;

    default:
      rcpputils::require_true(false, "unsupported transform arg");
      return q;
  }
}

这篇博客可以参考

mavros坐标系转换与方向_mavros baselink坐标系向edu坐标系转换-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值