how can I display the sensor data, altitude, speed, flight control on a graph ?

2 visualizaciones (últimos 30 días)
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

Respuestas (1)

Vineeth Nair
Vineeth Nair el 19 de Mzo. de 2021
It plots data such as speed, orientation, and height against time.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by