Skip to content

Commit

Permalink
gimbal: fix one based gimbal_id
Browse files Browse the repository at this point in the history
The gimbal_id is one based because 0 means "all gimbals".
  • Loading branch information
julianoes committed Aug 4, 2024
1 parent 875c7e9 commit bb4128d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mavsdk/plugins/gimbal/gimbal_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ void GimbalImpl::process_gimbal_manager_status(const mavlink_message_t& message)
auto& gimbal = *maybe_gimbal;

// We need to populate the MAVSDK gimbal ID, so the user knows which is which.
// +1 because 0 means all, so it's one-based.
gimbal.control_status.gimbal_id =
static_cast<int32_t>(std::distance(_gimbals.begin(), maybe_gimbal));
static_cast<int32_t>(std::distance(_gimbals.begin(), maybe_gimbal)) + 1;

if (status.primary_control_sysid == static_cast<int>(_system_impl->get_own_system_id()) &&
status.primary_control_compid == static_cast<int>(_system_impl->get_own_component_id())) {
Expand Down Expand Up @@ -315,7 +316,9 @@ void GimbalImpl::process_gimbal_device_attitude_status(const mavlink_message_t&
// Reset to defaults (e.g. NaN) first.
gimbal.attitude = {};
// We need to populate the MAVSDK gimbal ID, so the user knows which is which.
gimbal.attitude.gimbal_id = static_cast<int32_t>(std::distance(_gimbals.begin(), maybe_gimbal));
// +1 because 0 means all, so it's one-based.
gimbal.attitude.gimbal_id =
static_cast<int32_t>(std::distance(_gimbals.begin(), maybe_gimbal)) + 1;

if (is_in_forward_frame) {
gimbal.attitude.quaternion_forward.w = attitude_status.q[0];
Expand Down

0 comments on commit bb4128d

Please sign in to comment.