Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gimbal_controller: send attitude in Earth frame #1023

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading