Skip to content

Commit

Permalink
gimbal_controller: send attitude in Earth frame
Browse files Browse the repository at this point in the history
We no longer need to swap this based on the yaw lock with the recent
flags that have been added to the spec.

Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes committed Nov 28, 2023
1 parent 33ac87a commit c5a31a7
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/gazebo_gimbal_controller_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,18 +695,11 @@ void GimbalControllerPlugin::SendGimbalDeviceAttitudeStatus()
const uint16_t flags =
GIMBAL_DEVICE_FLAGS_ROLL_LOCK |
GIMBAL_DEVICE_FLAGS_PITCH_LOCK |
(this->yawLock ? GIMBAL_DEVICE_FLAGS_YAW_LOCK : 0);
(this->yawLock ? GIMBAL_DEVICE_FLAGS_YAW_LOCK : 0) |
GIMBAL_DEVICE_FLAGS_YAW_IN_EARTH_FRAME;

auto q = q_ENU_to_NED * this->cameraImuSensor->Orientation() * q_FLU_to_FRD.Inverse();

if (!this->yawLock) {
// In follow mode we need to transform the absolute camera orientation to an orientation
// relative to the vehicle because that's what the gimbal protocol suggests.
const auto q_vehicle = q_ENU_to_NED * ignition::math::Quaterniond(0.0, 0.0, this->vehicleYawRad) * q_FLU_to_FRD.Inverse();
const auto e = q.Euler();
q.Euler(e[0], e[1], e[2] - q_vehicle.Euler()[2]);
}

const float qArr[4] = {
static_cast<float>(q.W()),
static_cast<float>(q.X()),
Expand Down

0 comments on commit c5a31a7

Please sign in to comment.