Browse Source

Plane: send OPTICAL_FLOW msg to GCS

master
Randy Mackay 10 years ago
parent
commit
f4fc910fea
  1. 34
      ArduPlane/GCS_Mavlink.pde

34
ArduPlane/GCS_Mavlink.pde

@ -478,6 +478,32 @@ static void NOINLINE send_current_waypoint(mavlink_channel_t chan) @@ -478,6 +478,32 @@ static void NOINLINE send_current_waypoint(mavlink_channel_t chan)
mavlink_msg_mission_current_send(chan, mission.get_current_nav_index());
}
#if OPTFLOW == ENABLED
static void NOINLINE send_opticalflow(mavlink_channel_t chan)
{
// exit immediately if no optical flow sensor or not healthy
if (!optflow.healthy()) {
return;
}
// get rates from sensor
const Vector2f &flowRate = optflow.flowRate();
const Vector2f &bodyRate = optflow.bodyRate();
// populate and send message
mavlink_msg_optical_flow_send(
chan,
millis(),
0, // sensor id is zero
flowRate.x,
flowRate.y,
bodyRate.x,
bodyRate.y,
optflow.quality(),
0); // ground distance (in meters) set to zero
}
#endif // OPTFLOW == ENABLED
static void NOINLINE send_statustext(mavlink_channel_t chan)
{
mavlink_statustext_t *s = &gcs[chan-MAVLINK_COMM_0].pending_status;
@ -687,6 +713,13 @@ bool GCS_MAVLINK::try_send_message(enum ap_message id) @@ -687,6 +713,13 @@ bool GCS_MAVLINK::try_send_message(enum ap_message id)
#endif // MOUNT == ENABLED
break;
case MSG_OPTICAL_FLOW:
#if OPTFLOW == ENABLED
CHECK_PAYLOAD_SIZE(OPTICAL_FLOW);
send_opticalflow(chan);
#endif
break;
case MSG_RETRY_DEFERRED:
break; // just here to prevent a warning
@ -920,6 +953,7 @@ GCS_MAVLINK::data_stream_send(void) @@ -920,6 +953,7 @@ GCS_MAVLINK::data_stream_send(void)
#endif
send_message(MSG_BATTERY2);
send_message(MSG_MOUNT_STATUS);
send_message(MSG_OPTICAL_FLOW);
}
}

Loading…
Cancel
Save