-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add platform configuration for CF2.1 brushless
- Platform comes with modified defaults for PID tuning, idle thrust, platform mass, and battery limit compared to CF2.1. - The brushless defconfig enables manual arming and the DSHOT ESC protocol. - Moved idle thrust configuration out of kbuild.
- Loading branch information
Showing
11 changed files
with
228 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_PLATFORM_CF21BL=y | ||
|
||
CONFIG_MOTORS_REQUIRE_ARMING=y | ||
CONFIG_MOTORS_ESC_PROTOCOL_DSHOT=y |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/** | ||
* ,---------, ____ _ __ | ||
* | ,-^-, | / __ )(_) /_______________ _____ ___ | ||
* | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
* | / ,--´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
* +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie control firmware | ||
* | ||
* Copyright (C) 2024 Bitcraze AB | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
* platform_defaults_cf21bl.h - platform specific default values for the cf2.1 brushless platform | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifndef __INCLUDED_FROM_PLATFORM_DEFAULTS__ | ||
#pragma GCC error "Do not include this file directly, include platform_defaults.h instead." | ||
#endif | ||
|
||
// Defines for default values in the cf2 platform | ||
|
||
// Default values for battery limits | ||
#define DEFAULT_BAT_LOW_VOLTAGE 3.35f | ||
#define DEFAULT_BAT_CRITICAL_LOW_VOLTAGE 3.3f | ||
#define DEFAULT_BAT_LOW_DURATION_TO_TRIGGER_SEC 5 | ||
|
||
// Default value for system shutdown in minutes after radio silence. | ||
// Requires kbuild config ENABLE_AUTO_SHUTDOWN to be activated. | ||
#define DEFAULT_SYSTEM_SHUTDOWN_TIMEOUT_MIN 5 | ||
|
||
// Drone physical constants | ||
// m | ||
#define ARM_LENGTH 0.046f | ||
// kg | ||
#define CF_MASS 0.030f | ||
|
||
// Default PID gains | ||
#define PID_ROLL_RATE_KP 200.0 | ||
#define PID_ROLL_RATE_KI 400.0 | ||
#define PID_ROLL_RATE_KD 2.5 | ||
#define PID_ROLL_RATE_KFF 0.0 | ||
#define PID_ROLL_RATE_INTEGRATION_LIMIT 33.3 | ||
|
||
#define PID_PITCH_RATE_KP 200.0 | ||
#define PID_PITCH_RATE_KI 400.0 | ||
#define PID_PITCH_RATE_KD 2.5 | ||
#define PID_PITCH_RATE_KFF 0.0 | ||
#define PID_PITCH_RATE_INTEGRATION_LIMIT 33.3 | ||
|
||
#define PID_YAW_RATE_KP 120.0 | ||
#define PID_YAW_RATE_KI 16.7 | ||
#define PID_YAW_RATE_KD 0.0 | ||
#define PID_YAW_RATE_KFF 0.0 | ||
#define PID_YAW_RATE_INTEGRATION_LIMIT 166.7 | ||
|
||
#define PID_ROLL_KP 6.0 | ||
#define PID_ROLL_KI 3.0 | ||
#define PID_ROLL_KD 0.0 | ||
#define PID_ROLL_KFF 0.0 | ||
#define PID_ROLL_INTEGRATION_LIMIT 20.0 | ||
|
||
#define PID_PITCH_KP 6.0 | ||
#define PID_PITCH_KI 3.0 | ||
#define PID_PITCH_KD 0.0 | ||
#define PID_PITCH_KFF 0.0 | ||
#define PID_PITCH_INTEGRATION_LIMIT 20.0 | ||
|
||
#define PID_YAW_KP 6.0 | ||
#define PID_YAW_KI 1.0 | ||
#define PID_YAW_KD 0.35 | ||
#define PID_YAW_KFF 0.0 | ||
#define PID_YAW_INTEGRATION_LIMIT 360.0 | ||
|
||
#define PID_VEL_X_KP 25.0f | ||
#define PID_VEL_X_KI 1.0f | ||
#define PID_VEL_X_KD 0.0f | ||
#define PID_VEL_X_KFF 0.0f | ||
|
||
#define PID_VEL_Y_KP 25.0f | ||
#define PID_VEL_Y_KI 1.0f | ||
#define PID_VEL_Y_KD 0.0f | ||
#define PID_VEL_Y_KFF 0.0f | ||
|
||
#define PID_VEL_Z_KP 25.0f | ||
#define PID_VEL_Z_KI 15.0f | ||
#define PID_VEL_Z_KD 0.0f | ||
#define PID_VEL_Z_KFF 0.0f | ||
|
||
#define PID_VEL_Z_KP_BARO_Z_HOLD 3.0f | ||
#define PID_VEL_Z_KI_BARO_Z_HOLD 1.0f | ||
#define PID_VEL_Z_KD_BARO_Z_HOLD 1.5f | ||
#define PID_VEL_Z_KFF_BARO_Z_HOLD 0.0f | ||
|
||
#define PID_VEL_ROLL_MAX 20.0f | ||
#define PID_VEL_PITCH_MAX 20.0f | ||
#define PID_VEL_THRUST_BASE 30000.0f | ||
#define PID_VEL_THRUST_BASE_BARO_Z_HOLD 38000.0f | ||
#define PID_VEL_THRUST_MIN 20000.0f | ||
|
||
#define PID_POS_X_KP 2.0f | ||
#define PID_POS_X_KI 0.0f | ||
#define PID_POS_X_KD 0.0f | ||
#define PID_POS_X_KFF 0.0f | ||
|
||
#define PID_POS_Y_KP 2.0f | ||
#define PID_POS_Y_KI 0.0f | ||
#define PID_POS_Y_KD 0.0f | ||
#define PID_POS_Y_KFF 0.0f | ||
|
||
#define PID_POS_Z_KP 2.0f | ||
#define PID_POS_Z_KI 0.5f | ||
#define PID_POS_Z_KD 0.0f | ||
#define PID_POS_Z_KFF 0.0f | ||
|
||
#define PID_POS_VEL_X_MAX 1.0f | ||
#define PID_POS_VEL_Y_MAX 1.0f | ||
#define PID_POS_VEL_Z_MAX 1.0f | ||
|
||
// Manual arming, default idle thrust | ||
#define CONFIG_MOTORS_DEFAULT_IDLE_THRUST 7000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* || ____ _ __ | ||
* +------+ / __ )(_) /_______________ _____ ___ | ||
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
* | ||
* Crazyflie control firmware | ||
* | ||
* Copyright (C) 2024 Bitcraze AB | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Platform functionality for the CF2.1 brushless platform | ||
*/ | ||
|
||
#define DEBUG_MODULE "PLATFORM" | ||
|
||
#include <string.h> | ||
|
||
#include "platform.h" | ||
#include "exti.h" | ||
#include "nvic.h" | ||
#include "debug.h" | ||
|
||
static platformConfig_t configs[] = { | ||
#ifdef CONFIG_SENSORS_BMI088_BMP3XX | ||
{ | ||
.deviceType = "C21B", | ||
.deviceTypeName = "Crazyflie 2.1 Brushless", | ||
.sensorImplementation = SensorImplementation_bmi088_bmp3xx, | ||
.physicalLayoutAntennasAreClose = true, | ||
.motorMap = motorMapCF21Brushless, | ||
}, | ||
#endif | ||
}; | ||
|
||
const platformConfig_t* platformGetListOfConfigurations(int* nrOfConfigs) { | ||
*nrOfConfigs = sizeof(configs) / sizeof(platformConfig_t); | ||
return configs; | ||
} | ||
|
||
void platformInitHardware() { | ||
//Low level init: Clock and Interrupt controller | ||
nvicInit(); | ||
|
||
//EXTI interrupts | ||
extiInit(); | ||
} | ||
|
||
|
||
// Config functions ------------------------ | ||
|
||
const char* platformConfigGetPlatformName() { | ||
return "cf21bl"; | ||
} |