diff --git a/src/modules/simulation/simulator_sih/CMakeLists.txt b/src/modules/simulation/simulator_sih/CMakeLists.txt index 3dc290a775..9bbb190de3 100644 --- a/src/modules/simulation/simulator_sih/CMakeLists.txt +++ b/src/modules/simulation/simulator_sih/CMakeLists.txt @@ -40,6 +40,8 @@ px4_add_module( aero.hpp sih.cpp sih.hpp + MODULE_CONFIG + sih_params.yaml DEPENDS mathlib drivers_accelerometer diff --git a/src/modules/simulation/simulator_sih/sih_params.c b/src/modules/simulation/simulator_sih/sih_params.c deleted file mode 100644 index c4b592a753..0000000000 --- a/src/modules/simulation/simulator_sih/sih_params.c +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2013-2025 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file sih_params.c - * Parameters for simulator in hardware. - * - * @author Romain Chiappinelli - * February 2019 - */ - -/** - * Vehicle mass - * - * This value can be measured by weighting the quad on a scale. - * - * @unit kg - * @min 0.0 - * @decimal 2 - * @increment 0.1 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_MASS, 1.0f); - -/** - * Vehicle inertia about X axis - * - * The inertia is a 3 by 3 symmetric matrix. - * It represents the difficulty of the vehicle to modify its angular rate. - * - * @unit kg m^2 - * @min 0.0 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IXX, 0.025f); - -/** - * Vehicle inertia about Y axis - * - * The inertia is a 3 by 3 symmetric matrix. - * It represents the difficulty of the vehicle to modify its angular rate. - * - * @unit kg m^2 - * @min 0.0 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IYY, 0.025f); - -/** - * Vehicle inertia about Z axis - * - * The inertia is a 3 by 3 symmetric matrix. - * It represents the difficulty of the vehicle to modify its angular rate. - * - * @unit kg m^2 - * @min 0.0 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IZZ, 0.030f); - -/** - * Vehicle cross term inertia xy - * - * The inertia is a 3 by 3 symmetric matrix. - * This value can be set to 0 for a quad symmetric about its center of mass. - * - * @unit kg m^2 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IXY, 0.0f); - -/** - * Vehicle cross term inertia xz - * - * The inertia is a 3 by 3 symmetric matrix. - * This value can be set to 0 for a quad symmetric about its center of mass. - * - * @unit kg m^2 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IXZ, 0.0f); - -/** - * Vehicle cross term inertia yz - * - * The inertia is a 3 by 3 symmetric matrix. - * This value can be set to 0 for a quad symmetric about its center of mass. - * - * @unit kg m^2 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_IYZ, 0.0f); - -/** - * Max propeller thrust force - * - * This is the maximum force delivered by one propeller - * when the motor is running at full speed. - * - * This value is usually about 5 times the mass of the quadrotor. - * - * @unit N - * @min 0.0 - * @decimal 2 - * @increment 0.5 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_T_MAX, 5.0f); - -/** - * Max propeller torque - * - * This is the maximum torque delivered by one propeller - * when the motor is running at full speed. - * - * This value is usually about few percent of the maximum thrust force. - * - * @unit Nm - * @min 0.0 - * @decimal 3 - * @increment 0.05 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_Q_MAX, 0.1f); - -/** - * Roll arm length - * - * This is the arm length generating the rolling moment - * - * This value can be measured with a ruler. - * This corresponds to half the distance between the left and right motors. - * - * @unit m - * @min 0.0 - * @decimal 2 - * @increment 0.05 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_L_ROLL, 0.2f); - -/** - * Pitch arm length - * - * This is the arm length generating the pitching moment - * - * This value can be measured with a ruler. - * This corresponds to half the distance between the front and rear motors. - * - * @unit m - * @min 0.0 - * @decimal 2 - * @increment 0.05 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_L_PITCH, 0.2f); - -/** - * First order drag coefficient - * - * Physical coefficient representing the friction with air particules. - * The greater this value, the slower the quad will move. - * - * Drag force function of velocity: D=-KDV*V. - * The maximum freefall velocity can be computed as V=10*MASS/KDV [m/s] - * - * @unit N/(m/s) - * @min 0.0 - * @decimal 2 - * @increment 0.05 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_KDV, 1.0f); - -/** - * First order angular damper coefficient - * - * Physical coefficient representing the friction with air particules during rotations. - * The greater this value, the slower the quad will rotate. - * - * Aerodynamic moment function of body rate: Ma=-KDW*W_B. - * This value can be set to 0 if unknown. - * - * @unit Nm/(rad/s) - * @min 0.0 - * @decimal 3 - * @increment 0.005 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_KDW, 0.025f); - -/** - * Initial geodetic latitude - * - * This value represents the North-South location on Earth where the simulation begins. - * - * LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others - * to represent a physical ground location on Earth. - * - * @unit deg - * @min -90 - * @max 90 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_LOC_LAT0, 47.397742f); - -/** - * Initial geodetic longitude - * - * This value represents the East-West location on Earth where the simulation begins. - * - * LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others - * to represent a physical ground location on Earth. - * - * @unit deg - * @min -180 - * @max 180 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_LOC_LON0, 8.545594f); - -/** - * Initial AMSL ground altitude - * - * This value represents the Above Mean Sea Level (AMSL) altitude where the simulation begins. - * - * If using FlightGear as a visual animation, - * this value can be tweaked such that the vehicle lies on the ground at takeoff. - * - * LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others - * to represent a physical ground location on Earth. - * - * - * @unit m - * @min -420.0 - * @max 8848.0 - * @decimal 2 - * @increment 0.01 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_LOC_H0, 489.4f); - -/** - * distance sensor minimum range - * - * @unit m - * @min 0.0 - * @max 10.0 - * @decimal 4 - * @increment 0.01 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_DISTSNSR_MIN, 0.0f); - -/** - * distance sensor maximum range - * - * @unit m - * @min 0.0 - * @max 1000.0 - * @decimal 4 - * @increment 0.01 - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_DISTSNSR_MAX, 100.0f); - -/** - * if >= 0 the distance sensor measures will be overridden by this value - * - * Absolute value superior to 10000 will disable distance sensor - * - * @unit m - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_DISTSNSR_OVR, -1.0f); - -/** - * thruster time constant tau - * - * the time taken for the thruster to step from 0 to 100% should be about 4 times tau - * - * @unit s - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_T_TAU, 0.05f); - -/** - * Vehicle type - * - * @value 0 Quadcopter - * @value 1 Fixed-Wing - * @value 2 Tailsitter - * @value 3 Standard VTOL - * @value 4 Hexacopter - * @value 5 Rover Ackermann - * @reboot_required true - * @group Simulation In Hardware - */ -PARAM_DEFINE_INT32(SIH_VEHICLE_TYPE, 0); - -/** - * Wind velocity from north direction. - * - * @unit m/s - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_WIND_N, 0.0f); - -/** - * Wind velocity from east direction. - * - * @unit m/s - * @group Simulation In Hardware - */ -PARAM_DEFINE_FLOAT(SIH_WIND_E, 0.0f); diff --git a/src/modules/simulation/simulator_sih/sih_params.yaml b/src/modules/simulation/simulator_sih/sih_params.yaml new file mode 100644 index 0000000000..475e03e94b --- /dev/null +++ b/src/modules/simulation/simulator_sih/sih_params.yaml @@ -0,0 +1,273 @@ +module_name: simulator_sih +parameters: +- group: Simulation In Hardware + definitions: + SIH_MASS: + description: + short: Vehicle mass + long: This value can be measured by weighting the quad on a scale. + type: float + default: 1.0 + unit: kg + min: 0.0 + decimal: 2 + increment: 0.1 + SIH_IXX: + description: + short: Vehicle inertia about X axis + long: |- + The inertia is a 3 by 3 symmetric matrix. + It represents the difficulty of the vehicle to modify its angular rate. + type: float + default: 0.025 + unit: kg m^2 + min: 0.0 + decimal: 3 + increment: 0.005 + SIH_IYY: + description: + short: Vehicle inertia about Y axis + long: |- + The inertia is a 3 by 3 symmetric matrix. + It represents the difficulty of the vehicle to modify its angular rate. + type: float + default: 0.025 + unit: kg m^2 + min: 0.0 + decimal: 3 + increment: 0.005 + SIH_IZZ: + description: + short: Vehicle inertia about Z axis + long: |- + The inertia is a 3 by 3 symmetric matrix. + It represents the difficulty of the vehicle to modify its angular rate. + type: float + default: 0.03 + unit: kg m^2 + min: 0.0 + decimal: 3 + increment: 0.005 + SIH_IXY: + description: + short: Vehicle cross term inertia xy + long: |- + The inertia is a 3 by 3 symmetric matrix. + This value can be set to 0 for a quad symmetric about its center of mass. + type: float + default: 0.0 + unit: kg m^2 + decimal: 3 + increment: 0.005 + SIH_IXZ: + description: + short: Vehicle cross term inertia xz + long: |- + The inertia is a 3 by 3 symmetric matrix. + This value can be set to 0 for a quad symmetric about its center of mass. + type: float + default: 0.0 + unit: kg m^2 + decimal: 3 + increment: 0.005 + SIH_IYZ: + description: + short: Vehicle cross term inertia yz + long: |- + The inertia is a 3 by 3 symmetric matrix. + This value can be set to 0 for a quad symmetric about its center of mass. + type: float + default: 0.0 + unit: kg m^2 + decimal: 3 + increment: 0.005 + SIH_T_MAX: + description: + short: Max propeller thrust force + long: |- + This is the maximum force delivered by one propeller + when the motor is running at full speed. + + This value is usually about 5 times the mass of the quadrotor. + type: float + default: 5.0 + unit: N + min: 0.0 + decimal: 2 + increment: 0.5 + SIH_Q_MAX: + description: + short: Max propeller torque + long: |- + This is the maximum torque delivered by one propeller + when the motor is running at full speed. + + This value is usually about few percent of the maximum thrust force. + type: float + default: 0.1 + unit: Nm + min: 0.0 + decimal: 3 + increment: 0.05 + SIH_L_ROLL: + description: + short: Roll arm length + long: |- + This is the arm length generating the rolling moment + + This value can be measured with a ruler. + This corresponds to half the distance between the left and right motors. + type: float + default: 0.2 + unit: m + min: 0.0 + decimal: 2 + increment: 0.05 + SIH_L_PITCH: + description: + short: Pitch arm length + long: |- + This is the arm length generating the pitching moment + + This value can be measured with a ruler. + This corresponds to half the distance between the front and rear motors. + type: float + default: 0.2 + unit: m + min: 0.0 + decimal: 2 + increment: 0.05 + SIH_KDV: + description: + short: First order drag coefficient + long: |- + Physical coefficient representing the friction with air particules. + The greater this value, the slower the quad will move. + + Drag force function of velocity: D=-KDV*V. + The maximum freefall velocity can be computed as V=10*MASS/KDV [m/s] + type: float + default: 1.0 + unit: N/(m/s) + min: 0.0 + decimal: 2 + increment: 0.05 + SIH_KDW: + description: + short: First order angular damper coefficient + long: |- + Physical coefficient representing the friction with air particules during rotations. + The greater this value, the slower the quad will rotate. + + Aerodynamic moment function of body rate: Ma=-KDW*W_B. + This value can be set to 0 if unknown. + type: float + default: 0.025 + unit: Nm/(rad/s) + min: 0.0 + decimal: 3 + increment: 0.005 + SIH_LOC_LAT0: + description: + short: Initial geodetic latitude + long: |- + This value represents the North-South location on Earth where the simulation begins. + + LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others + to represent a physical ground location on Earth. + type: float + default: 47.397742 + unit: deg + min: -90 + max: 90 + SIH_LOC_LON0: + description: + short: Initial geodetic longitude + long: |- + This value represents the East-West location on Earth where the simulation begins. + + LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others + to represent a physical ground location on Earth. + type: float + default: 8.545594 + unit: deg + min: -180 + max: 180 + SIH_LOC_H0: + description: + short: Initial AMSL ground altitude + long: |- + This value represents the Above Mean Sea Level (AMSL) altitude where the simulation begins. + + If using FlightGear as a visual animation, + this value can be tweaked such that the vehicle lies on the ground at takeoff. + + LAT0, LON0, H0, MU_X, MU_Y, and MU_Z should ideally be consistent among each others + to represent a physical ground location on Earth. + type: float + default: 489.4 + unit: m + min: -420.0 + max: 8848.0 + decimal: 2 + increment: 0.01 + SIH_DISTSNSR_MIN: + description: + short: distance sensor minimum range + type: float + default: 0.0 + unit: m + min: 0.0 + max: 10.0 + decimal: 4 + increment: 0.01 + SIH_DISTSNSR_MAX: + description: + short: distance sensor maximum range + type: float + default: 100.0 + unit: m + min: 0.0 + max: 1000.0 + decimal: 4 + increment: 0.01 + SIH_DISTSNSR_OVR: + description: + short: if >= 0 the distance sensor measures will be overridden by this value + long: Absolute value superior to 10000 will disable distance sensor + type: float + default: -1.0 + unit: m + SIH_T_TAU: + description: + short: thruster time constant tau + long: the time taken for the thruster to step from 0 to 100% should be about + 4 times tau + type: float + default: 0.05 + unit: s + SIH_VEHICLE_TYPE: + description: + short: Vehicle type + type: enum + values: + 0: Quadcopter + 1: Fixed-Wing + 2: Tailsitter + 3: Standard VTOL + 4: Hexacopter + 5: Rover Ackermann + default: 0 + reboot_required: true + SIH_WIND_N: + description: + short: Wind velocity from north direction + type: float + default: 0.0 + unit: m/s + SIH_WIND_E: + description: + short: Wind velocity from east direction + type: float + default: 0.0 + unit: m/s