Skip to content

Commit

Permalink
Update custom-airframe-config.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza787b authored Sep 2, 2024
1 parent e247b41 commit 0ae1db2
Showing 1 changed file with 46 additions and 42 deletions.
88 changes: 46 additions & 42 deletions docs/custom-airframe-config.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
# Defining Custom Airframes in PX4-XPlane

This guide will walk you through defining custom airframe configurations in PX4-XPlane using the `config.ini` file. We’ll cover everything from setting up the configuration file to mapping channels in PX4, ensuring you can successfully simulate and control your custom airframes.
This guide walks you through defining custom airframe configurations in PX4-XPlane using the `config.ini` file. We’ll cover key concepts, provide detailed examples, and guide you through the entire process—from configuring the file to testing your setup in X-Plane.

## Overview

To define a custom airframe configuration, follow these steps:
1. **Configure the `config.ini` File**: Map PX4 channels to X-Plane datarefs.
2. **Understand Datarefs and Their Types**: Learn how to choose and configure datarefs.
3. **Set Channel Numbers in PX4**: Define channel numbers in the PX4 SITL section via QGroundControl.
4. **Use or Create an Airframe in PX4**: Set up your airframe using dynamic mixing in QGroundControl or define it in the PX4 source code.
1. **Select or Build a Plane Model**: Choose an existing X-Plane model or create one from scratch using X-Plane’s Plane Maker.
2. **Select a Similar Airframe in PX4 or Start from Scratch**: Choose a pre-existing PX4 airframe that closely matches your custom setup, or define a new one from scratch. You can double-check channel numbers, servos, and functionalities in the dynamic mixing section of QGroundControl’s Actuator section under SITL.
3. **Configure the `config.ini` File**: Map PX4 channels to X-Plane datarefs.
4. **Understand Datarefs and Their Types**: Learn how to select and configure datarefs.
5. **Build and Test the Configuration**: Test your configuration in X-Plane and PX4.

## Step 1: Configuring the `config.ini` File
## Step 1: Select or Build a Plane Model

The `config.ini` file is where you define how PX4's outputs are mapped to X-Plane's inputs, such as motors and control surfaces.
### Using Existing Models

- **Pre-existing Models**: Use existing X-Plane models that closely match your custom airframe.
- **Modify Models**: Modify an existing X-Plane model to fit your requirements.

### Creating a New Model

- **Use Plane Maker**: Create a new aircraft using X-Plane’s Plane Maker tool if no existing model fits your needs.

## Step 2: Select a Similar Airframe in PX4 or Start from Scratch

### Using Pre-existing Airframes in PX4

- **Choose a Similar Airframe**: If your custom airframe is similar to an existing setup, use that as a starting point (e.g., `xplane_alia250`).
- **Dynamic Mixing in QGroundControl**: Verify and adjust channel mappings in the dynamic mixing section of the Actuator settings in QGroundControl’s SITL section.

### Starting from Scratch

- **Define in PX4 Source Code**: For complex airframes, you may prefer to define the aircraft directly in the PX4 source code and compile it.
- **Dynamic Mixing in QGroundControl**: Verify and adjust channel mappings in the dynamic mixing section of the Actuator settings in QGroundControl’s SITL section.

## Step 3: Configuring the `config.ini` File

The `config.ini` file defines how PX4’s outputs (e.g., motors, control surfaces) map to X-Plane’s inputs.

### Example Configuration for Alia 250 eVTOL

Expand Down Expand Up @@ -51,58 +74,39 @@ channel8 = sim/flightmodel/engine/ENGN_thro_use, floatArray, [4], [-1 1]
### Key Sections Explained

- **Configuration Name**: Displayed in the PX4-XPlane UI; this helps you identify the active configuration.
- **Auto-Prop Brakes**: Reduces drag by braking the propellers when they’re not needed. This is particularly useful for eVTOL configurations.
- **Channel Mappings**: Defines how each PX4 channel maps to X-Plane’s datarefs.
- **Auto-Prop Brakes**: Reduces drag by braking the propellers when they’re not needed, useful for eVTOL configurations.
- **Channel Mappings**: Defines how each PX4 channel maps to X-Plane’s datarefs. Each channel can control a motor, control surface, or other aircraft function.

## Step 2: Understanding Datarefs and Their Types
## Step 4: Understanding Datarefs and Their Types

### Dataref Types

- **`float`**: Single floating-point value, used for controls like throttle or rudder.
- **`floatArray`**: Array of floating-point values, often used for engines or multi-servo setups.
- **`int`**: Integer values, typically used for binary states like landing gear.
- **`intArray`**: Array of integers, similar to `floatArray` but for integers.
- **`float`**: Single floating-point value, typically used for control surfaces like ailerons or rudders.
- **`floatArray`**: An array of floating-point values, often used for multi-engine aircraft or multiple control surfaces.
- **`int`**: Integer values, typically used for binary states such as landing gear.
- **`intArray`**: An array of integers, similar to `floatArray` but used for integer data.

### Selecting Datarefs

Choose the appropriate dataref based on the control type:
Choosing the correct dataref ensures accurate simulation behavior:
- **Throttle and Motors**: Use `sim/flightmodel/engine/ENGN_thro_use` with `floatArray`.
- **Control Surfaces**: Use datarefs like `sim/flightmodel/controls/wing2l_ail1def` with `float` for ailerons, elevators, and rudders.
- **Auto-Prop Brakes**: If needed, define the motor indices that should have auto-prop brakes to reduce drag.

## Step 3: Setting Channel Numbers in PX4

### Defining Channels in PX4’s SITL Section

1. **Open QGroundControl**: Connect to your PX4 instance.
2. **Navigate to the SITL Actuator Section**: In QGroundControl, go to the "Setup" tab and find the "Actuators" section.
3. **Map Channels**: Ensure the channels you define in the `config.ini` file match the actuator outputs in the SITL section.

### Alternative: Define Aircraft in PX4 Source Code

If your airframe is complex, you may prefer to define the aircraft directly in the PX4 source code and compile it yourself. This involves creating or modifying an airframe definition file in the PX4 Firmware and recompiling PX4.

## Step 4: Building and Testing the Configuration

### Using Pre-existing Airframes

If your airframe closely matches an existing setup, such as `xplane_alia250`, you can use that configuration.
- **Control Surfaces**: For ailerons, elevators, and rudders, use datarefs like `sim/flightmodel/controls/wing2l_ail1def` with `float`.
- **Auto-Prop Brakes**: Define motor indices that should have auto-prop brakes to minimize drag during flight.

### Creating a Custom Airframe
Use the Dataref Tool plugin in X-Plane to find the correct dataref for your setup, or refer to the [X-Plane Dataref Documentation](https://developer.x-plane.com/datarefs/) for more details.

1. **Modify X-Plane Models**: Use or modify an existing X-Plane aircraft model to match your configuration.
2. **Create New Models in Plane Maker**: If necessary, design a new aircraft in X-Plane’s Plane Maker to match your custom configuration.
## Step 5: Building and Testing the Configuration

### Testing

1. **Load and Test in PX4-XPlane**: Load the configuration in X-Plane and test the controls.
2. **Adjust as Needed**: Make any necessary adjustments in the `config.ini` file or PX4 parameters to ensure proper control and simulation accuracy.
2. **Adjust as Needed**: Modify the `config.ini` file or PX4 parameters to fine-tune control and simulation accuracy.

## Final Notes: Custom Airframe Setup in PX4
### Final Notes: Custom Airframe Setup in PX4

Remember, the channel numbers should be defined in the SITL Actuator section of QGroundControl. You can either:
- **Use Dynamic Mixing**: Adjust the actuator outputs directly within QGroundControl for flexibility.
- **Use Dynamic Mixing**: Adjust actuator outputs directly within QGroundControl for flexibility.
- **Define in Source Code**: For more complex setups, define the airframe in the PX4 source code, build it, and then test.

This approach allows you to fine-tune your airframe's behavior within PX4, ensuring that it matches the corresponding X-Plane model.
By following these steps, you’ll ensure your custom airframe behaves correctly in both PX4 and X-Plane, allowing for realistic and accurate simulations.

0 comments on commit 0ae1db2

Please sign in to comment.