Giter VIP home page Giter VIP logo

ladac-examples's Introduction

Examples for the Library for Aircraft Dynamics And Control (LADAC)

This repository contains multiple examples to demonstrate the usage of LADAC. There are multicopter, airplane and eVTOL flight dynamic models as well as flight controllers for the specific vehicles. The flight dynamic models and the flight controllers are based on LADAC and written in MATLAB/Simulink. Moreover, there are interfaces to external programs like FlightGear (for visualization) and ArduPilot (for software in the loop tests and flight tests).

Quadrotor Flight Path Control Demo

Quadrotor Flight Path Control Demo

Motivation

It is sometimes not clear how to get new aircraft configurations to fly with existing software such as ArduPilot or PX4. With such software, you usually have no insight into the dynamics of the open and closed loop of the aircraft and are limited to an empirical controller design through flight tests or simulations. This project provides the opportunity to design controllers specifically in MATLAB/Simulink. First, you can quickly parameterize existing aircraft models or easily create new aircraft models based on LADAC building blocks. Then you can analyze the dynamics of the aircraft and design controllers. Then it is possible to translate the created controller into C/C++ code (code generation) and implement it in software like ArduPilot. Finally, you can test your software in a software-in-the-loop simulation before running your code on a Pixhawk for flight testing.

Installation

  • MATLAB:

    1. You need MATLAB/Simulink 2018b or later (older versions may work but they are not supported).
    2. You may also need some MATLAB toolboxes like Curve Fitting Toolbox, Aerospace Blockset, Aerospace Toolbox, MATLAB Coder, MATLAB Compiler, Simulink Control Design, Simulink Coder depending on what you want to do.
  • Remote control:
    You can use a remote control via USB if you have one.

  • FlightGear:
    You also should install FlightGear for visualization. Normally, any version should work.

  • ArduPilot SITL:
    You might install ArduPilot SITL if you want to do software in the loop simulations.

  • Ground control station:
    You might install a ground control station like QGroundControl or MissionPlanner for communication with ArduPilot SITL.

  • LADAC-Examples:
    Clone this project including the submodules LADAC and LADAC-Example-Data:

    git clone --recursive https://github.com/iff-gsc/ladac-examples.git
    

Examples

  • Start a simulation of quadcopter Bebop2 with loiter controller (both quadcopter dynamics and controller run in MATLAB/Simulink):

    1. Open MATLAB/Simulink.
    2. Run the Bebop2 initialization file Copter/Bebop2/init_quadcopter_Bebop2_Loiter_INDI_simple.
      cd('Copter/Bebop2')
      init_quadcopter_Bebop2_Loiter_INDI_simple
      
    3. Plug in a remote control via USB.
      By default, the calibration settings of the Xbox-360 joystick are used as you can see in the init script init_quadcopter_Bebop2_Loiter_INDI_simple.
      This calibration settings may not be compatible with your joystick! Therefore, you should test and calibrate your joystick.
      If you do not have connected a remote control, set jystck.enable = 0 (else an error will occur).
    4. Run the Simulink file QuadcopterSimModel_INDI_Loiter_simple.slx (should open after step 2) to start the simulation. You can either control the system with the remote control (vertical velocity, yaw rate, pitch angle, roll angle) or dummy inputs will be performed.
      sim('QuadcopterSimModel_INDI_Loiter_simple')
      
    5. You can view the system outputs in the block visualization clicking on the scopes. However, this is not visually intuitive.
  • Visualize simulation with FlightGear:

    1. Run the start script of FlightGear by running runfg_IRIS.bat (Windows) or runfg_IRIS.sh (Linux):
      ./modules/ladac-examples-data/FlightGear/runfg_IRIS.sh
      
      This will open FlightGear and load an IRIS quadcopter animation (for visualization only, the computation is carried out by MATLAB).
  • Use the dynamics model of MATLAB/Simulink for software in the loop simulation of ArduPilot (controller runs in ArduPilot):

    1. Run a new MATLAB/Simulink simulation with Bebop2 quadcopter with the ArduPilot SITL interface:
      cd('Copter/Bebop2')
      init_quadcopter_Bebop2_ArduPilot_SITL
      sim('QuadcopterSimModel_ArduCopter_SITL')
      
    2. Run ArduPilot SITL in Gazebo mode from terminal (sim_vehicle.py must be on the path or you find it in the ArduPilot repository in Tools/autotest/). Make sure that you have a proper ArduPilot configuration file for the ArduPilot SITL where you have set the joystick inputs etc. correctly. You should use the provided ArduPilot parameters file of the Bebop2 as a basis for the configuration, since the sensor filter and control parameters are already correctly set here for the Bebop2 Simulink model. Finaly you can start the ArduPilot SITL with the --add-param-file option (here, our parameter file is used as an example):
      sim_vehicle.py -v ArduCopter --model=gazebo --add-param-file=<path-to-repository>/modules/ladac-examples-data/ArduPilot_params/Parrot_Bebop2_MATLAB_SITL.param
      
      The dynamics model in MATLAB/Simulink is tested with ArduCopter 4.2.0. If you run into any problems try checking out the older ArduCopter release in the ArduPilot repository with:
      git checkout Copter-4.2.0
      git submodule update --init --recursive
      
    3. Control the quadcopter from ArduPilot. Therefore, you should use a ground control station (read QGroundControl or MissionPlanner documentation) or the MAVProxy command prompt.

How to use?

General use of the MATLAB/Simulink files

There are initialization m-files in multiple subfolders (e.g. Copter/Bebop2/init_...) to initialize the parameters of the physical model as well as of the controller. There are simulation slx-file (e.g. Copter/models/QuadcoterSimModel_...) for different kinds of vehicles and different types of controllers.

General use of ArduPilot SITL

Standard ArduPilot flight modes will only work if you load appropriate parameters for you vehicle. The default parameters (e.g. -f gazebo-iris) only work for similar quadcopters (e.g. IRIS quadcopter). For other vehicles you have to load different parameters using the --add-param-file option. For some vehicles you find the parameters in modules/ladac-examples-data/ArduPilot_params. You can use these parameter files as a basis for your own configuration and add your joystick configuration, for example.

  • IRIS:
    You can load the ArduPilot IRIS parameters with the -f parameter: sim_vehicle.py -v ArduCopter -f gazebo-iris --model=gazebo

  • Muetze:
    Muetze is very similar to IRIS. That is why ArduCopter works with -f gazebo-iris option.

Use of LADAC

Please have a look at the LADAC readme.

Design INDI controller for quadrotor

Have a look at the LindiCopter autopilot.

Implement controllers in ArduPilot:

You can implement your controllers in ArduPilot to quickly proceed to flight tests, see ArduPilot Custom Controller.

Contribute

Fix or report bugs

Before reporting a bug, please try the following:

  • check git status
  • restart MATLAB/Simulink

Create an issue and provide the following information:

  • error message or discription of the problem
  • steps of how to reproduce the error/problem
  • utilized commit SHA-1 hash (e.g. 7d2e1a6c)

ladac-examples's People

Contributors

jwithelm avatar ybeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ladac-examples's Issues

Running the Bebop_Loiter_INDI_Simple

Hi, Hope you all are doing well.
thank you for all your efforts for this repository.

I cloned the LADAC and installed and test as the readme stated, and all items Passed in check_ladac, I also check the Joystick performance as mentioned in Test Joystick.

but for running the Bep2_loiter_INDI_Simple, got the below error in the simulation stage after compiling Simulink. could you please check whether I did something wrong?

it works in "model('QuadcopterSimModel_LindiCopter')" and connects to FG truly but for this "model('QuadcopterSimModel_INDI_Loiter_simple')" I got the attached error:
I changed the Simulation sample time but still not working.
Error
Passed

Thank you for considering.

Looking for some help

  1. When I watch the video in the YouTube, the simulink model has errors as following.
Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.

Function 'crossFast' not supported for code generation.
[More information](matlab:helpview('coder','msginfo_Coder_builtins_FunctionNotSupportedForCodeGeneration');)

Function 'velocityFromRot.m' ([#999.1561.1613](matlab:das_dv_hyperlink('DAS','id','999.1561.1613'))), line 40, column 41:
"crossFast( repmat(omega_xy_x,1,num_vectors), r_p_x )"
Launch diagnostic [report](matlab: sfprivate('eml_report_manager','open',542);).

Function call failed.

Function 'Velocity due to rotation' ([#543.69.113](matlab:das_dv_hyperlink('DAS','id','543.69.113'))), line 2, column 10:
"velocityFromRot( V_xy_x, omega_xy_x, r_p_x )"
Launch diagnostic [report](matlab: sfprivate('eml_report_manager','open',542);).

Errors occurred during parsing of MATLAB function ['QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation'](matlab:sfprivate('sfOpenObjectBySId','QuadcopterSimModel_LindiCopter:4227:66:65:259'))

Simulink cannot determine sizes and/or types of the outputs for block ['QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation'](matlab:sfprivate('sfOpenObjectBySId','QuadcopterSimModel_LindiCopter:4227:66:65:259')) due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.

Simulink cannot determine sizes and/or types of the outputs for block ['QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation'](matlab:sfprivate('sfOpenObjectBySId','QuadcopterSimModel_LindiCopter:4227:66:65:259')) due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.

Error in port widths or dimensions. '[output ports 1](matlab:slprivate('open_and_hilite_port_hyperlink', 'hilite', ['QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation/V_xy_x'], 'Outport', 1);)' of '[QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation/V_xy_x](matlab:open_and_hilite_hyperlink ('QuadcopterSimModel_LindiCopter/Quadcopter/Quadcopter Propulsion/Map-based propeller fixed to airframe/Velocity due to rotation/V_xy_x','error'))' is a one dimensional vector with 3 elements.
  1. The zip package I downloaded doesn't have plot_flight_path.m file

Issue Encountered While Implementing Guidance

Thank you sincerely for your contributions to this repository. I've encountered an issue while following your instructions. The error message is as follows:

Warning: No joystick with ID 1 connected! Running 'HebiJoystick Input' with dummy outputs!
Invalid setting in 'QuadcopterSimModel_LindiCopter/INDI Controller/Constant1' for parameter 'Value'.
Caused by:
Error evaluating parameter 'Value' in 'QuadcopterSimModel_LindiCopter/INDI Controller/Constant1'
Unrecognized field name "traj".
Component:Simulink | Category:Block error

Could you please provide some guidance on resolving this issue? Thank you for your assistance.

Remove dependency on Robotics System Toolbox

The EasyGlider/init_EasyGlider_Trajectory example only works with Robotics System Toolbox.
However, the functions used should also all be included in LADAC (e.g. rotm2quat -> dcm2Quat).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.