mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-26 18:48:30 -04:00
GCS_MAVLINK: move sending of optical flow status up to base class
This commit is contained in:
parent
ebf038eb57
commit
38fdcb02a4
@ -183,7 +183,7 @@ public:
|
||||
void send_ahrs();
|
||||
void send_battery2();
|
||||
#if AP_AHRS_NAVEKF_AVAILABLE
|
||||
void send_opticalflow(const OpticalFlow &optflow);
|
||||
void send_opticalflow();
|
||||
#endif
|
||||
virtual void send_attitude() const;
|
||||
void send_autopilot_version() const;
|
||||
|
@ -1481,16 +1481,19 @@ MAV_RESULT GCS_MAVLINK::_set_mode_common(const MAV_MODE _base_mode, const uint32
|
||||
/*
|
||||
send OPTICAL_FLOW message
|
||||
*/
|
||||
void GCS_MAVLINK::send_opticalflow(const OpticalFlow &optflow)
|
||||
void GCS_MAVLINK::send_opticalflow()
|
||||
{
|
||||
const OpticalFlow *optflow = AP::opticalflow();
|
||||
|
||||
// exit immediately if no optical flow sensor or not healthy
|
||||
if (!optflow.healthy()) {
|
||||
if (optflow == nullptr ||
|
||||
!optflow->healthy()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get rates from sensor
|
||||
const Vector2f &flowRate = optflow.flowRate();
|
||||
const Vector2f &bodyRate = optflow.bodyRate();
|
||||
const Vector2f &flowRate = optflow->flowRate();
|
||||
const Vector2f &bodyRate = optflow->bodyRate();
|
||||
|
||||
const AP_AHRS &ahrs = AP::ahrs();
|
||||
float hagl = 0;
|
||||
@ -1509,7 +1512,7 @@ void GCS_MAVLINK::send_opticalflow(const OpticalFlow &optflow)
|
||||
flowRate.y,
|
||||
bodyRate.x,
|
||||
bodyRate.y,
|
||||
optflow.quality(),
|
||||
optflow->quality(),
|
||||
hagl, // ground distance (in meters) set to zero
|
||||
flowRate.x,
|
||||
flowRate.y);
|
||||
@ -3203,6 +3206,11 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id)
|
||||
send_mount_status();
|
||||
break;
|
||||
|
||||
case MSG_OPTICAL_FLOW:
|
||||
CHECK_PAYLOAD_SIZE(OPTICAL_FLOW);
|
||||
send_opticalflow();
|
||||
break;
|
||||
|
||||
case MSG_POSITION_TARGET_GLOBAL_INT:
|
||||
CHECK_PAYLOAD_SIZE(POSITION_TARGET_GLOBAL_INT);
|
||||
send_position_target_global_int();
|
||||
|
Loading…
Reference in New Issue
Block a user