Question: Please help me debug this tello drone code to display pitch, yaw, roll altitude, speed, height . close all; clc; clear; r = ryze(); takeoff(r);
Please help me debug this tello drone code to display pitch, yaw, roll altitude, speed, height .
close all; clc; clear;
r = ryze(); takeoff(r);
fig2 = figure('pos',[800 550 800 450]); subplot(2,3,1) title('phi[deg]'); grid on; hold on; subplot(2,3,2) title('theta[deg]'); grid on; hold on; subplot(2,3,3) title('psi[deg]'); grid on; hold on; subplot(2,3,4) title('x[m]'); grid on; hold on; subplot(2,3,5) title('y[m]'); grid on; hold on; subplot(2,3,6) title('zdot[m/s]'); grid on; hold on;
function extractSensorData(obj, sensorData) % Function to extract individual sensor data from the packet % containing all drone sensor data
% Update battery level obj.BatteryLevel = str2double(extractBetween(sensorData,'bat:',';')); if(obj.BatteryLevel < 10) status = ryzeio.internal.Utility.validateAlertState(obj.LowBattery, obj.BatteryLevel); % Set the low battery flag if(status) obj.LowBattery = true; end end % Update Attitude/Orientation Values Pitch = str2double(extractBetween(sensorData,'pitch:',';')); Roll = str2double(extractBetween(sensorData,'roll:',';')); Yaw = str2double(extractBetween(sensorData,'yaw:',';')); obj.Attitude.Value = [Yaw Pitch Roll]; obj.Attitude.Time = datetime('now', 'TImeZone','local','Format','dd-MMM-uuuu HH:mm:ss.SS');
% Update the Altitude/height of the drone obj.Altitude.Value = str2double(extractBetween(sensorData,';h:',';')); obj.Altitude.Time = datetime('now', 'TImeZone','local','Format','dd-MMM-uuuu HH:mm:ss.SS');
% Update the speed of the drone vgx = str2double(extractBetween(sensorData,'vgx:',';')); vgy = str2double(extractBetween(sensorData,'vgy:',';')); vgz = str2double(extractBetween(sensorData,'vgz:',';')); obj.Speed.Value = [vgx vgy vgz]; obj.Speed.Time = datetime('now', 'TImeZone','local','Format','dd-MMM-uuuu HH:mm:ss.SS');
if(~obj.FirstPacketReceived) % Make the 'FirstPacketReceived' true to indicate % that the first packet of sensor data has arrived obj.FirstPacketReceived = true; end
end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
