|
| 1 | +/** |
| 2 | + * ,---------, ____ _ __ |
| 3 | + * | ,-^-, | / __ )(_) /_______________ _____ ___ |
| 4 | + * | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ |
| 5 | + * | / ,--' | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ |
| 6 | + * +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ |
| 7 | + * |
| 8 | + * Crazyflie control firmware |
| 9 | + * |
| 10 | + * Copyright (C) 2025 Bitcraze AB |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU General Public License as published by |
| 14 | + * the Free Software Foundation, in version 3. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License |
| 22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | + * |
| 24 | + */ |
| 25 | + |
| 26 | +#pragma once |
| 27 | + |
| 28 | +/** |
| 29 | + * @file kalman_core_params_defaults.h |
| 30 | + * @brief Single source of truth for Kalman core parameter default values |
| 31 | + * |
| 32 | + * This header defines default parameter values as a macro to avoid duplication. |
| 33 | + * The macro is used in two places: |
| 34 | + * 1. estimator_kalman.c - Static initializer for firmware (avoids overwriting persistent params) |
| 35 | + * 2. kalman_core.c - kalmanCoreDefaultParams() function for Python bindings |
| 36 | + */ |
| 37 | + |
| 38 | +// Process noise defaults depend on configuration |
| 39 | +#ifdef CONFIG_ESTIMATOR_KALMAN_GENERAL_PURPOSE |
| 40 | +#define KALMAN_CORE_PROC_NOISE_DEFAULTS \ |
| 41 | + .procNoiseAcc_xy = 0.5f, \ |
| 42 | + .procNoiseAcc_z = 0.5f |
| 43 | +#else |
| 44 | +#define KALMAN_CORE_PROC_NOISE_DEFAULTS \ |
| 45 | + .procNoiseAcc_xy = 0.5f, \ |
| 46 | + .procNoiseAcc_z = 1.0f |
| 47 | +#endif |
| 48 | + |
| 49 | +/** |
| 50 | + * @brief Macro containing default values for kalmanCoreParams_t |
| 51 | + * |
| 52 | + * Use as a designated initializer, e.g.: |
| 53 | + * kalmanCoreParams_t params = { KALMAN_CORE_DEFAULT_PARAMS_INIT }; |
| 54 | + */ |
| 55 | +#define KALMAN_CORE_DEFAULT_PARAMS_INIT \ |
| 56 | + /* Initial variances, uncertain of position, but know we're stationary and roughly flat */ \ |
| 57 | + .stdDevInitialPosition_xy = 100, \ |
| 58 | + .stdDevInitialPosition_z = 1, \ |
| 59 | + .stdDevInitialVelocity = 0.01, \ |
| 60 | + .stdDevInitialAttitude_rollpitch = 0.01, \ |
| 61 | + .stdDevInitialAttitude_yaw = 0.01, \ |
| 62 | + \ |
| 63 | + KALMAN_CORE_PROC_NOISE_DEFAULTS, \ |
| 64 | + .procNoiseVel = 0, \ |
| 65 | + .procNoisePos = 0, \ |
| 66 | + .procNoiseAtt = 0, \ |
| 67 | + .measNoiseBaro = 2.0f, /* meters */ \ |
| 68 | + .measNoiseGyro_rollpitch = 0.1f, /* radians per second */ \ |
| 69 | + .measNoiseGyro_yaw = 0.1f, /* radians per second */ \ |
| 70 | + \ |
| 71 | + .initialX = 0.0, \ |
| 72 | + .initialY = 0.0, \ |
| 73 | + .initialZ = 0.0, \ |
| 74 | + /* Initial yaw of the Crazyflie in radians. */ \ |
| 75 | + /* 0 --- facing positive X */ \ |
| 76 | + /* PI / 2 --- facing positive Y */ \ |
| 77 | + /* PI --- facing negative X */ \ |
| 78 | + /* 3 * PI / 2 --- facing negative Y */ \ |
| 79 | + .initialYaw = 0.0, \ |
| 80 | + \ |
| 81 | + /* Roll/pitch/yaw zero reversion is on by default. Will be overridden by estimatorKalmanInit() if requested by the deck. */ \ |
| 82 | + .attitudeReversion = 0.001f |
0 commit comments