-
Notifications
You must be signed in to change notification settings - Fork 0
Drone Telemetry
Note that it is necessary to connect to the drone using the API before attempting to monitor drone telemetry.
The DroneStatusMonitor class reads the status from the drone, parses the raw status and presents those values to the calling application. It also provides an event subscription model for receiving updates to the drone status. Note that drone status will only be broadcast by the drone if it is in API mode.
To use it, first reference the required namespace:
using TelloCommander.Status;
The following code snippet will create an instance of the monitor, begin monitoring drone status in the background and register the "OnDroneStatusUpdate" method as the callback to handle updates to the drone status:
DroneStatusMonitor monitor = new DroneStatusMonitor();
monitor.Listen(DroneStatusMonitor.DefaultTelloStatusPort);
monitor.DroneStatusUpdated += OnDroneStatusUpdated;
The following illustrates a stub method for handling drone status update events:
private static void OnDroneStatusUpdated(object sender, DroneStatusEventArgs e)
{
if (string.IsNullOrEmpty(e.Status.Error) &&!string.IsNullOrEmpty(e.Status.Status))
{
}
}
Note that it's essential to check there has not been an error reading the status and that there is some data in the raw status value returned before attempting to access the parsed property values.
The DroneStatusEventArgs class has a "Status" member that is a concrete instance of the IDroneStatus interface. That interface requires implementation of the following fields:
Member | Type | Contains |
---|---|---|
Sequence | int | A sequence number that increments every time the status is retrieved |
Status | string | The raw status value returned by the drone |
Error | string | If an error occurred while reading the status, the error message |
RawValues | Dictionary<string, string> | The raw status parsed into a dictionary of values as strings |
Attitude | Attitude | The current pitch, roll and yaw of the drone |
Speed | Speed | The speed of the drone in X, Y and Z |
Temperature | Temperature | The temperature of the drone, Minimum and Maximum values |
TOF | decimal | Current TOF |
Height | decimal | Height in cm |
Battery | decimal | Remaining battery charge, % |
Barometer | decimal | Barometric pressure |
Time | decimal | Motor "on" time |
Acceleration | Acceleration | The current acceleration in X, Y, Z |
For example, the following could be used to output the current height to the console in the event handler for drone status updates:
Console.WriteLine(e.Status.Height);