Skip to content

Commit

Permalink
mavlink: make param optional
Browse files Browse the repository at this point in the history
If the gimbal module is not built in we don't have the MNT_MODE_IN
param, so we need to deal with that.
  • Loading branch information
julianoes committed Oct 16, 2024
1 parent 899b984 commit 79ff33a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/modules/mavlink/mavlink_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,18 @@ Mavlink::send_autopilot_capabilities()
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_MISSION_FENCE;
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_MISSION_RALLY;

if (_param_mnt_mode_in.get() == 4) {
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_COMPONENT_IMPLEMENTS_GIMBAL_MANAGER;

{
param_t param_handle = param_find_no_notification("MNT_MODE_IN");
int32_t mnt_mode_in = 0;

if (mnt_mode_in != PARAM_INVALID) {
param_get(param_handle, &mnt_mode_in);

if (mnt_mode_in == 4) {
msg.capabilities |= MAV_PROTOCOL_CAPABILITY_COMPONENT_IMPLEMENTS_GIMBAL_MANAGER;
}
}
}

msg.flight_sw_version = px4_firmware_version();
Expand Down
3 changes: 1 addition & 2 deletions src/modules/mavlink/mavlink_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ class Mavlink final : public ModuleParams
(ParamBool<px4::params::MAV_HB_FORW_EN>) _param_mav_hb_forw_en,
(ParamInt<px4::params::MAV_RADIO_TOUT>) _param_mav_radio_timeout,
(ParamInt<px4::params::SYS_HITL>) _param_sys_hitl,
(ParamBool<px4::params::SYS_FAILURE_EN>) _param_sys_failure_injection_enabled,
(ParamInt<px4::params::MNT_MODE_IN>) _param_mnt_mode_in
(ParamBool<px4::params::SYS_FAILURE_EN>) _param_sys_failure_injection_enabled
)

perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": tx run elapsed")}; /**< loop performance counter */
Expand Down

0 comments on commit 79ff33a

Please sign in to comment.