Question
I m trying to write a matlab code for a tello drone to display speed, yaw, roll , pitch, acceleration, altitude, height but my code
I m trying to write a matlab code for a tello drone to display speed, yaw, roll , pitch, acceleration, altitude, height but my code below doesn t work.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started