Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/simulink/arducopter/functions/ModeConfig.m
Views: 1799
% This class provides important setting information for the flight modes1% that have been chosen for the SID process.2%3% Fabian Bredemeier - IAV GmbH4% License: GPL v356classdef ModeConfig7properties8name = '';9mode_num;10thr_man;11filter_msgs = {};12end1314methods15% Constructor16function obj = ModeConfig(mode_num)17props = ModeConfig.getModeProps(mode_num);18obj.name = props.name;19obj.mode_num = mode_num;20obj.thr_man = props.thr_man;21obj.filter_msgs = props.filter_msgs;22end2324% Function that returns index of mode properties that corresponds to25% the mode number26function modeIndex = getIndexFromModeNum(obj, modeNum)27for i=1:length(obj.names)28if (obj.mode_num_list(i) == modeNum)29modeIndex = i;30break;31end32end33end3435function filter_msgs = get_filter_msgs(obj)36filter_msgs = obj.filter_msgs;37end3839function thr_man = get_thr_man(obj)40thr_man = obj.thr_man;41end4243function name = get_name(obj)44name = obj.name;45end4647% Function to compare properties to another ModeConfig object48function identical = compare_to(obj, obj2)49% Name50if strcmp(obj.name, obj2.get_name()) ~= 151identical = false;52return;53end54% Throttle Man55if obj.thr_man ~= obj2.get_thr_man56identical = false;57return;58end59% Filter message list60if numel(obj.filter_msgs) ~= numel(obj2.get_filter_msgs())61identical = false;62return;63end64for i=1:numel(obj.filter_msgs)65obj2_filter_msgs = obj2.get_filter_msgs();66if strcmp(obj.filter_msgs{i}, obj2_filter_msgs{i}) ~= 167identical = false;68return;69end70end71identical = true;72end73end7475methods (Static)7677% Function that stores all mode properties78function propsStruct = getModeProps(modeNum)79% Define basic filter message cell array which is necessary for80% only the inner loop or the part that is used in SYSID81% respectively. Used for modes whose relevant msgs are not yet82% clear.83filter_msgs_sysid = {'FMT', 'UNIT', 'FMTU', 'MULT', 'PARM', 'MODE', 'SIDD', ...84'SIDS', 'ATT', 'CTRL', 'RATE', 'PIDR', 'PIDP', 'PIDY', 'CTUN', ...85'IMU','BAT', 'BARO', 'MOTB'};86% Filter message cell array which is necessary to run simulation87% in loiter mode88filter_msgs_loiter = {'FMT', 'UNIT', 'FMTU', 'MULT', 'PARM', 'MODE', ...89'ATT', 'CTRL', 'RATE', 'PIDR', 'PIDP', 'PIDY', 'PIDA', 'CTUN', ...90'IMU', 'BAT', 'BARO', 'MOTB', 'PSCD', 'PSCE', 'PSCN', 'RCIN'};91% Stabilize92filter_msgs_stabilize = {'FMT', 'UNIT', 'FMTU', 'MULT', 'PARM', 'MODE', ...93'ATT', 'CTRL', 'RATE', 'PIDR', 'PIDP', 'PIDY', 'PIDA', 'CTUN', ...94'IMU', 'BAT', 'BARO', 'MOTB', 'GYR', 'ACC', 'RCIN'};95% Acro96filter_msgs_acro = {'FMT', 'UNIT', 'FMTU', 'MULT', 'PARM', 'MODE', ...97'ATT', 'CTRL', 'RATE', 'PIDR', 'PIDP', 'PIDY', 'PIDA', 'CTUN', ...98'IMU', 'BAT', 'BARO', 'MOTB', 'GYR', 'ACC'};99% AltHold100filter_msgs_althold = {'FMT', 'UNIT', 'FMTU', 'MULT', 'PARM', 'MODE', ...101'ATT', 'CTRL', 'RATE', 'PIDR', 'PIDP', 'PIDY', 'PIDA', 'CTUN', ...102'IMU', 'BAT', 'BARO', 'MOTB', 'PSCD', 'GYR', 'ACC', 'RCIN'};103switch modeNum104case 0 % Stabilize105propsStruct.name = 'Stabilize';106propsStruct.thr_man = true;107propsStruct.filter_msgs = filter_msgs_stabilize;108case 1 % Acro109propsStruct.name = 'Acro';110propsStruct.thr_man = true;111propsStruct.filter_msgs = filter_msgs_acro;112case 2 % Alt_Hold113propsStruct.name = 'Alt_Hold';114propsStruct.thr_man = false;115propsStruct.filter_msgs = filter_msgs_althold;116case 3 % Auto117propsStruct.name = 'Auto';118propsStruct.thr_man = false;119propsStruct.filter_msgs = filter_msgs_loiter;120case 4 % Guided121propsStruct.name = 'Guided';122propsStruct.thr_man = false;123propsStruct.filter_msgs = filter_msgs_loiter;124case 5 % Loiter125propsStruct.name = 'Loiter';126propsStruct.thr_man = false;127propsStruct.filter_msgs = filter_msgs_loiter;128case 6 % RTL129propsStruct.name = 'RTL';130propsStruct.thr_man = false;131propsStruct.filter_msgs = filter_msgs_sysid;132case 7 % Circle133propsStruct.name = 'Circle';134propsStruct.thr_man = false;135propsStruct.filter_msgs = filter_msgs_sysid;136case 9 % Land137propsStruct.name = 'Land';138propsStruct.thr_man = false;139propsStruct.filter_msgs = filter_msgs_sysid;140case 11 % Drift141propsStruct.name = 'Drift';142propsStruct.thr_man = false;143propsStruct.filter_msgs = filter_msgs_sysid;144case 13 % Sport145propsStruct.name = 'Sport';146propsStruct.thr_man = false;147propsStruct.filter_msgs = filter_msgs_sysid;148case 14 % Flip149propsStruct.name = 'Flip';150propsStruct.thr_man = false;151propsStruct.filter_msgs = filter_msgs_sysid;152case 15 % Autotune153propsStruct.name = 'Autotune';154propsStruct.thr_man = false;155propsStruct.filter_msgs = filter_msgs_stabilize;156case 16 % Poshold157propsStruct.name = 'Poshold';158propsStruct.thr_man = false;159propsStruct.filter_msgs = filter_msgs_sysid;160case 17 % Brake161propsStruct.name = 'Brake';162propsStruct.thr_man = false;163propsStruct.filter_msgs = filter_msgs_sysid;164case 18 % Throw165propsStruct.name = 'Throw';166propsStruct.thr_man = false;167propsStruct.filter_msgs = filter_msgs_sysid;168case 19 % Avoid_ADSB169propsStruct.name = 'Avoid_ADSB';170propsStruct.thr_man = false;171propsStruct.filter_msgs = filter_msgs_sysid;172case 20 % Guided_NoGPS173propsStruct.name = 'Guided_NoGPS';174propsStruct.thr_man = false;175propsStruct.filter_msgs = filter_msgs_sysid;176case 21 % SmartRTL177propsStruct.name = 'SmartRTL';178propsStruct.thr_man = false;179propsStruct.filter_msgs = filter_msgs_sysid;180case 22 % Flowhold181propsStruct.name = 'Flowhold';182propsStruct.thr_man = false;183propsStruct.filter_msgs = filter_msgs_sysid;184case 23 % Follow185propsStruct.name = 'Follow';186propsStruct.thr_man = false;187propsStruct.filter_msgs = filter_msgs_sysid;188case 24 % Zigzag189propsStruct.name = 'Zigzag';190propsStruct.thr_man = false;191propsStruct.filter_msgs = filter_msgs_sysid;192case 25 % Systemid193propsStruct.name = 'Systemid';194propsStruct.thr_man = true;195propsStruct.filter_msgs = filter_msgs_sysid;196case 26 % Autorotate197propsStruct.name = 'Autorotate';198propsStruct.thr_man = false;199propsStruct.filter_msgs = filter_msgs_sysid;200end201end202end203end204205