This repository contains the source code for the Dive Mode for fast descents of multicopters (see video).
-
MATLAB:
- You need MATLAB/Simulink 2023b or later.
- You also need the following MATLAB toolboxes:
- Curve Fitting Toolbox (purpose: propeller map interpolation; if you don't have it, you can replace the propeller map interpolation with the simple propeller model in Ref. [1])
- Simulink Coder, MATLAB Coder (purpose: only for code generation for flight tests; if you don't have it, you can still run the simulations)
-
This repository:
Clone this project including the submodules LADAC and LADAC-Example-Data:git clone --recursive https://github.com/iff-gsc/copter-dive-mode.git -
FlightGear (optional; for visualization):
You should install FlightGear for visualization. -
ArduPilot SITL (optional; for ArduPilot SITL and flight tests):
- Open and run init_quadcopter_S500_dive_mode located in init in MATLAB (if it is not on the MATLAB path already, click Change Folder or Add to Path).
- The Simulink model QuadcopterSimModel_DiveMode located in models should appear after step 1. Run this model.
- Run FlightGear visualization by executing runfg_IRIS.sh (Linux) or runfg_IRIS.bat (Windows) located in the FlightGear folder.
By default the quadrotor will be initialized in hover at 300 meters altitude and will enter the Dive Mode after 1 second.
You can plot the results after simulation by running plot_dive.
We use the ArduPilot custom controller interface.
- Open and run init_Arducopter_S500_dive_mode located in init in MATLAB.
- The Simulink model ArduCopter_DiveMode located in models should appear after step 1. Generate C++ Code: APPS → Embedded Coder → Generate Code.
- (optional) Define tunable parameters to be ArduPilot parameters by running
apParProcessCodeExport( 'apPar_copter_params_default' )in the MATLAB Command Window. - Clone the ArduPilot fork and checkout the branch
Copter-Dive-Mode:git clone -b Copter-Dive-Mode --recursive https://github.com/ybeyer/ardupilot.git - Copy and paste the generated code (
MatlabController.cpp,MatlabController.h,MatlabController_data.cpp,rtwtypes,MatlabControllerParams.cpp,MatlabControllerStructOverride.h) to the ArduPilot fork inardupilot/libraries/AC_MatlabController - Build ArduCopter (see next sections).
- Open and run init_quadcopter_S500_ArduPilot_SITL located in init in MATLAB (if it is not on the MATLAB path already, click Change Folder or Add to Path).
- The Simulink model QuadcopterSimModel_ArduCopter_SITL located in models should appear after step 1. Run this model.
- Run FlightGear as above.
- Run the ArduPilot SITL from terminal and specify the S500 copter parameters file (copy it to
ardupilot/Tools/autotest/default_params):Tools/autotest/sim_vehicle.py -v copter --add-param-file=Tools/autotest/default_params/S500-SITL.parm --model=gazebo -w - Take off in any ArduCopter flight mode.
- Switch to LindiCopter by entering
mode 29into the ArduPilot SITL terminal. - Activate the Dive Mode by setting the Channel 10 PWM to 2000 (1000 is Stabilize, 1500 is Loiter).
- Define your flight controller board (e.g. MatekH743) in terminal in the ArduPilot folder:
./waf configure --board=MatekH743 - Build ArduCopter for your flight controller board:
./waf configure --upload