RflyExpCode Instructional Package

repository·master·Indexed 42 days ago

https://github.com/rflysim/rflyexpcode

An instructional package for the 'Multicopter Design and Control Practice' course. It provides code, experimental structures, and Simulink models for multicopter design, modeling, and control using the RflySim platform, covering topics from dynamic modeling and sensor calibration to attitude and set-point controller design.

Tokens
3.7K
Snippets
1
Records
28
Agent score
52%

What's inside RflyExpCode

  1. Overview of Semi-Autonomous Control (SAC) in e7

    master

    The e7 instruction package provides Semi-Autonomous Control (SAC) capabilities. The SAC implementation is a hybrid system that builds upon the attitude controller from the e5 package and the position control from the e6 package.

    SAC supports three distinct operational modes:

    1. Stabilize Mode: Basic attitude control.
    2. Altitude Hold Mode: Maintains a constant altitude.
    3. Loiter Mode: Maintains a fixed position in space.

    The package is structured into sub-modules for Simulink simulation and flight testing to analyze these modes and the transitions between them.

  2. Overview of the e8 Failsafe Logic Design Experiment

    master
    The e8 instruction package is designed for experimenting with failsafe logic in multicopters. It focuses specifically on handling the loss of Radio Control (RC) as a form of communication breakdown. The package is structured into progressive stages of complexity, moving from manual mode switching to fully automated failsafe logic for both Simulation/HIL (Hardware-in-the-Loop) and flight test models.
  3. Overview of RflyExpCode instructional packages

    master

    RflyExpCode provides instructional packages for the 'Multicopter Design and Control Practice' course. The packages are organized into folders (e0 through e8) that correspond to specific chapters and experiments in the textbook.

    Each experiment folder typically contains three sub-files representing different levels of practical application:

    1. Basic experiment
    2. Analysis experiment
    3. Design experiment

    Note: The analysis experiment for Chapter 2 (e2/e2.2) does not have a source file package as it focuses on theoretical calculation and analysis.

  4. Explore experiment models in e5

    master

    The e5 directory contains various models for different stages of quadcopter experimentation and control analysis:

    • e5\e5.1\Sim: Used for Simulink simulation of a quadcopter to analyze control allocation functions.
    • e5\e5.1\tune: Used for analyzing control system performance.
    • e5\e5.1\HIL: Used for Hardware-in-the-Loop (HIL) simulation.
    • e5\e5.2: Contains Simulink models similar to the tune model, used for adjusting and analyzing control system performance.
    • e5\e5.3: Contains the attitude control model designed during analysis experiments.
    • e5\e5.4: Contains files for flight testing and flight data analysis.
  5. Understand the RflyExpCode experiment structure

    master

    The instructional package is organized into folders named e0 through e8, corresponding to specific chapters and experiments in the 'Multicopter Design and Control Practice' curriculum.

    Each experiment folder typically contains three sub-files representing different levels of the experiment:

    1. Basic experiment
    2. Analysis experiment
    3. Design experiment

    Note: The e2/e2.2 (Analysis experiment for Chapter 2) does not have a source file package because it focuses on theoretical calculation and analysis.

  6. Use or extend the quadcopter dynamic model in e2.3

    master

    The project provides a quadcopter dynamic model located at e2/e2.3/dynamics.slx.

    • Custom Models: You can design your own multicopter dynamic model by following the existing design style used in dynamics.slx.
    • Parameters: The quadcopter parameters used in e2/e2.3/Init.m are derived via system identification methods for real aircraft and are used across subsequent models.
    • Simple Quadcopter Model: The e2/e2.3/myownUAV directory contains a simple quadcopter model including a 3D model and two XML configuration files.
  7. Conduct flight tests and data analysis in e6\e6.4

    master

    The e6\e6.4 directory contains files for flight testing and flight data analysis.

    Important: Before opening the Simulink file e6\e6.4\PosControl_FLY.slx, you should add custom logger data to ensure proper data capture and analysis.

  8. Update PX4 parameters using QGC and Simulink

    master

    To update parameters that appear in QGroundControl (QGC), use the px4demo_ParameterUpdate_CSC_example.slx Simulink model.

    1. Define New Parameters

    Define the new parameters you wish to expose in QGC within the px4_simulink_app_params.c file. The changes made in this file determine which parameters will be visible in the QGC interface.

    2. Refresh Parameter List

    If the updated parameters do not appear in QGC, you may need to delete the existing parameters.xml file to force a proper update of the parameter list.

    The file is typically located at: C:\px4_firmware_test\Firmware\build_<firmware_variant>\parameters.xml

    Replace <firmware_variant> with your specific build target, such as px4fmu-v3_default or px4fmu-v2_default.

  9. Add custom logger data for flight test analysis

    master

    Before opening the flight test file e5\e5.4\AttitudeControl_FLY.slx, you must configure the firmware to log custom messages. Follow these steps to integrate the costom_attctrl_e5.msg message:

    1. Prepare the Message File

    Place the customized message file costom_attctrl_e5.msg into the Firmware/msg/ directory.

    Note for PX4 v1.9 and above: You must add a uint64 timestamp to the top of the .msg file. Refer to the demo file PSPfile/PX4_1.9andAbove/costom_attctrl_e5.msg for the correct format.

    2. Update CMake Configuration

    Modify Firmware/msg/CMakeLists.txt. Locate the set(msg_files section and add the new message:

    # Inside Firmware/msg/CMakeLists.txt
    set(msg_files
        ...
        costom_attctrl_e5.msg
    )```
    
    ### 3. Register the Topic in Logger
    Register the new topic in the firmware source code to enable logging:
    - **For PX4 < 1.11**: Modify `Firmware/src/modules/logger/logger.cpp`.
    - **For PX4 >= 1.11**: Modify `Firmware/src/modules/logger/logged_topics.cpp`.
    
    Inside the `add_default_topics()` function, add the following line:
    ```cpp
    add_topic("costom_attctrl_e5", 4);

    Note: The second parameter (4) defines the logging period in milliseconds (e.g., 4 results in a 250Hz sampling rate).

    4. Configure SD Logging in QGroundControl (QGC)

    1. Connect your Pixhawk to your computer and open QGC.
    2. Navigate to Setting -> Parameters -> SD_Logging -> SDLOG_MODE.
    3. Change SDLOG_MODE to from boot until shutdown and save the settings.
  10. Implement automated failsafe logic for RC loss in e8.3 and e8.4

    master

    The final stage of the experiment involves designing logic that enables a multicopter to automatically return and land when the connection to the Radio Control transmitter becomes abnormal. This is implemented for two different environments:

    • Simulation & HIL (Hardware-in-the-Loop) models: Located in e8\e8.3.
    • Flight test models: Located in e8\e8.4.