Skip to content

Commit

Permalink
Merge branch 'bitcraze:master' into relative-yaw-traj
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnwallace authored May 18, 2024
2 parents 1688981 + a25e8fb commit 8ee6ea4
Show file tree
Hide file tree
Showing 47 changed files with 819 additions and 196 deletions.
22 changes: 11 additions & 11 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ choice

config PLATFORM_CF2
bool "Build for CF2"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_MPU9250_LPS25H

config PLATFORM_BOLT
bool "Build for Bolt"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_BMI088_SPI

config PLATFORM_TAG
bool "Build for the roadrunner"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX

config PLATFORM_FLAPPER
bool "Build for Flapper Nimble+"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_BMI088_SPI

endchoice
Expand Down Expand Up @@ -125,15 +125,15 @@ config SENSORS_MPU9250_LPS25H
bool "Support for mpu9250 and lps25h sensors"
default n
help
Include support for the Bosch bmi088 inertial and bmp388
Include support for the Bosch bmi088 inertial and bmp3xx
barometric sensors

config SENSORS_BMI088_BMP388
bool "Support for bmi088 and bmp388 sensors"
config SENSORS_BMI088_BMP3XX
bool "Support for bmi088 and bmp3xx sensors"
default n
select SENSORS_BMI088_I2C
help
Include support for the Bosch bmi088 inertial and bmp388
Include support for the Bosch bmi088 inertial and bmp3xx
barometric sensors

config SENSORS_BOSCH
Expand All @@ -142,19 +142,19 @@ config SENSORS_BOSCH

config SENSORS_IGNORE_BAROMETER_FAIL
bool "Ignore failure from barometer"
depends on SENSORS_BMI088_BMP388
depends on SENSORS_BMI088_BMP3XX
default n

config SENSORS_BMI088_SPI
bool "Support for SPI communincation with the bmi088 sensor"
depends on SENSORS_BMI088_BMP388
depends on SENSORS_BMI088_BMP3XX
default n
help
Include support using SPI with the Bosch bmi088 inertial sensor

config SENSORS_BMI088_I2C
bool "Support for I2C communincation with the bmi088 sensor"
depends on SENSORS_BMI088_BMP388
depends on SENSORS_BMI088_BMP3XX
default n
help
Include support using I2C with the Bosch bmi088 inertial sensor
Expand Down
2 changes: 2 additions & 0 deletions bindings/cffirmware.i
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "num.h"
#include "controller_mellinger.h"
#include "controller_brescianini.h"
#include "controller_lee.h"
#include "power_distribution.h"
#include "axis3fSubSampler.h"
#include "outlierFilterTdoa.h"
Expand All @@ -35,6 +36,7 @@
%include "imu_types.h"
%include "controller_mellinger.h"
%include "controller_brescianini.h"
%include "controller_lee.h"
%include "power_distribution.h"
%include "axis3fSubSampler.h"
%include "outlierFilterTdoa.h"
Expand Down
1 change: 1 addition & 0 deletions bindings/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"src/modules/src/controller/attitude_pid_controller.c",
"src/modules/src/controller/controller_mellinger.c",
"src/modules/src/controller/controller_brescianini.c",
"src/modules/src/controller/controller_lee.c",
"src/utils/src/pid.c",
"src/utils/src/filter.c",
"src/utils/src/num.c",
Expand Down
16 changes: 8 additions & 8 deletions docs/development/create_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ choice
config PLATFORM_CF2
bool "Build for CF2"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_MPU9250_LPS25H
config PLATFORM_BOLT
bool "Build for Bolt"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_BMI088_SPI
config PLATFORM_TAG
bool "Build for the roadrunner"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
endchoice
```
Expand All @@ -53,21 +53,21 @@ choice
config PLATFORM_CF2
bool "Build for CF2"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_MPU9250_LPS25H
config PLATFORM_BOLT
bool "Build for Bolt"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_BMI088_SPI
config PLATFORM_TAG
bool "Build for the roadrunner"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
config PLATFORM_RINCEWIND
bool "Build for the Rincewind platform"
select SENSORS_BMI088_BMP388
select SENSORS_BMI088_BMP3XX
select SENSORS_BMI088_SPI
endchoice
Expand Down Expand Up @@ -116,7 +116,7 @@ static platformConfig_t configs[] = {
{
.deviceType = "CB10",
.deviceTypeName = "Rincewind",
.sensorImplementation = SensorImplementation_bmi088_spi_bmp388,
.sensorImplementation = SensorImplementation_bmi088_spi_bmp3xx,
.physicalLayoutAntennasAreClose = false,
.motorMap = motorMapBoltBrushless,
}
Expand Down
2 changes: 1 addition & 1 deletion docs/development/kbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CONFIG_PLATFORM_CF2=y
# Sensor configuration
#
CONFIG_SENSORS_MPU9250_LPS25H=y
CONFIG_SENSORS_BMI088_BMP388=y
CONFIG_SENSORS_BMI088_BMP3XX=y
[...]
```

Expand Down
6 changes: 1 addition & 5 deletions docs/development/openocd_gdb_debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Inside of the file, replace everything with the following:
"request": "launch",
"type": "cortex-debug",
"device": "STM32F405",
"svdFile": "STM32F405.svd",
"svdFile": "${workspaceRoot}/tools/debug/STM32F405.svd",
"servertype": "openocd",
"configFiles": ["interface/stlink-v2.cfg", "target/stm32f4x.cfg"],
"runToMain": true,
Expand Down Expand Up @@ -210,10 +210,6 @@ Inside of the file, replace everything with the following:
> **Note: Debugging thread aware**
> To debug thread aware you need to add ```"rtos": "FreeRTOS"``` to your configuration in the launch.json file - however, while this can be very handy we also occasionally experienced some issues with setting breakpoints while using this configuration.
#### Installing the SVD file

Now for the SVD file: just download it from [here](STM32F405.svd) and into the firmware root dir, or download it from the ST website (search for `svd stm32f4`). Make sure it has the exact name of ```STM32F405.svd``` !

### Debug!

After setup, go to the 'Run and Debug' tab of VS Code (on the left sidebar, the icon with the little bug next to the play button), select the chip you want to debug from the drop-down menu at the top of the pane, and hit the play button!
Expand Down
10 changes: 10 additions & 0 deletions docs/development/unit_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ used in the unit tests as well. In some cases unit tests must be disabled based
if a particular file is not included in the build. A unit test file can be disabled based on configuration by using
an annotation like this:

## AddressSanitizer
If you are facing issues running the unit tests locally and ending up in an endless loop of

Addressanitizer:DEADLY SIGNAL

This is due to a incompatibility between TSan vesion and the high number of entropy bits used for randomization in recent Ubuntu versions.
Solutions for this (until a fix is in place) is to run the tests with the toolbelt or temporarily bump your systems entropy bits down to 28 using;

`sudo sysctl vm.mmap_rnd_bits=28`

``` c
// @IGNORE_IF_NOT CONFIG_DECK_LIGHTHOUSE
```
58 changes: 54 additions & 4 deletions docs/functional-areas/sensor-to-control/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ page_id: controllers

Once the [state estimator](/docs/functional-areas/sensor-to-control/state_estimators.md) have outputed the current (estimated) situation of the crazyflie in position velocity and attitude, it is time for the controllers to keep it that way or to move the crazyflie into a new position based on a setpoint. This is an important part of the stabilization system in the crazyflie.

* [Overview of Control](#overview-of-control)
* [Cascaded PID controller](#cascaded-pid-controller)
* Mellinger Controller (TO DO)
* INDI Controller (TO DO)
- [Overview of control](#overview-of-control)
- [Cascaded PID controller](#cascaded-pid-controller)
- [Mellinger Controller](#mellinger-controller)
- [INDI Controller](#indi-controller)
- [Brescianini Controller](#brescianini-controller)
- [Lee Controller](#lee-controller)

## Overview of control
There are four levels to control in the Crazyflie:
Expand Down Expand Up @@ -55,3 +57,51 @@ Check the implementation details in `attitude_pid_controller.c` in `attitudeCont
The most outer-loop of the cascaded PID controller is the position and velocity controller. It receives position or velocity input from a commander which are handled, since it is possible to set in the variable `setpoint_t` which stabilization mode to use `stab_mode_t` (either position: `modeAbs` or `modeVelocity`). These can be found in `stabilizer_types.h`. The control loop runs at 100 Hz.

Check the implementation details in `position_controller_pid.c` in `positionController()` and `velocityController()`.

## Mellinger Controller

Conceptually the Mellinger controller is similar to the cascaded PID controller, i.e. there is an attitude controller (running at 250 Hz) and a position controller (running at 100 Hz). The main difference to the cascaded PID controller is how errors are defined and how the position error is translated into desired attitude setpoints. Like the cascaded PID, this is a reactive geometric controller that uses the mathematical property of differential flatness. Details are given in the following scientific publication:

```
Daniel Mellinger, and Vijay Kumar
Minimum snap trajectory generation and control for quadrotors
IEEE International Conference on Robotics and Automation (ICRA), 2011
https://doi.org/10.1109/ICRA.2011.5980409
```

The implementation follows the paper, also for the names of the variables. The main difference is the addition of I-gains and a D-term for the angular velocity.

## INDI Controller

This control algorithm is the Incremental Nonlinear Dynamic Inversion (INDI) controller. Details are given in the following scientific publication:

```
Ewoud J. J. Smeur, Qiping Chu, and Guido C. H. E. de Croon
Adaptive Incremental Nonlinear Dynamic Inversion for Attitude Control of Micro Air Vehicles
JCGD 2015
https://doi.org/10.2514/1.G001490
```

## Brescianini Controller

Details of this controller are in the following scientific publication:

```
Dario Brescianini, Markus Hehn, and Raffaello D'Andrea
Nonlinear quadrocopter attitude control
Technical Report ETHZ, 2013
https://doi.org/10.3929/ethz-a-009970340
```

## Lee Controller

Conceptually the Lee controller is similar to the cascaded PID controller, i.e. there is an attitude controller (running at 250 Hz) and a position controller (running at 100 Hz). The main difference to the cascaded PID controller is how errors are defined and how the position error is translated into desired attitude setpoints. Like the cascaded PID, this is a reactive geometric controller that uses the mathematical property of differential flatness. Compared to the Mellinger controller, a different angular velocity error and higher-order terms in the attitude controller are used. Details including a stability proof are given in the following scientific publication:

```
Taeyoung Lee, Melvin Leok, and N. Harris McClamroch
Geometric Tracking Control of a Quadrotor UAV on SE(3)
CDC 2010
https://doi.org/10.1109/CDC.2010.5717652
```

The implementation follows the paper, also for the names of the variables. The main difference is the addition of I-gains, which are not needed for the theoretical proof, but helpful on the practical system.
5 changes: 0 additions & 5 deletions src/deck/drivers/interface/lpsTwrTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
#define LPS_TWR_LPP_PAYLOAD 4

#define LPS_TWR_SEND_LPP_PAYLOAD 1

#ifdef LOCODECK_NR_OF_ANCHORS
#define LOCODECK_NR_OF_TWR_ANCHORS LOCODECK_NR_OF_ANCHORS
#else
#define LOCODECK_NR_OF_TWR_ANCHORS 8
#endif

extern uwbAlgorithm_t uwbTwrTagAlgorithm;

Expand Down
64 changes: 24 additions & 40 deletions src/deck/drivers/src/lpsTwrTag.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,84 +619,68 @@ LOG_GROUP_STOP(twr)
* Log group for distances (ranges) to anchors aquired by Two Way Ranging (TWR)
*/
LOG_GROUP_START(ranging)
#if (LOCODECK_NR_OF_TWR_ANCHORS > 0)
/**
* @brief Distance to anchor 0 [m]
*/
LOG_ADD(LOG_FLOAT, distance0, &state.distance[0])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 1)
/**
* @brief Distance to anchor 1 [m]
*/
LOG_ADD(LOG_FLOAT, distance1, &state.distance[1])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 2)
/**
* @brief Distance to anchor 2 [m]
*/
LOG_ADD(LOG_FLOAT, distance2, &state.distance[2])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 3)
/**
* @brief Distance to anchor 3 [m]
*/
LOG_ADD(LOG_FLOAT, distance3, &state.distance[3])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 4)
/**
* @brief Distance to anchor 4 [m]
*/
LOG_ADD(LOG_FLOAT, distance4, &state.distance[4])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 5)
/**
* @brief Distance to anchor 5 [m]
*/
LOG_ADD(LOG_FLOAT, distance5, &state.distance[5])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 6)
/**
* @brief Distance to anchor 6 [m]
*/
LOG_ADD(LOG_FLOAT, distance6, &state.distance[6])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 7)
/**
* @brief Distance to anchor 7 [m]
*/
LOG_ADD(LOG_FLOAT, distance7, &state.distance[7])
#endif

#if (LOCODECK_NR_OF_TWR_ANCHORS > 0)
/**
* @brief ASL of anchor 0 [m]
*/
LOG_ADD(LOG_FLOAT, pressure0, &state.pressures[0])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 1)
/**
* @brief ASL of anchor 1 [m]
*/
LOG_ADD(LOG_FLOAT, pressure1, &state.pressures[1])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 2)
/**
* @brief ASL of anchor 2 [m]
*/
LOG_ADD(LOG_FLOAT, pressure2, &state.pressures[2])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 3)
/**
* @brief ASL of anchor 3 [m]
*/
LOG_ADD(LOG_FLOAT, pressure3, &state.pressures[3])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 4)
/**
* @brief ASL of anchor 4 [m]
*/
LOG_ADD(LOG_FLOAT, pressure4, &state.pressures[4])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 5)
/**
* @brief ASL of anchor 5 [m]
*/
LOG_ADD(LOG_FLOAT, pressure5, &state.pressures[5])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 6)
/**
* @brief ASL of anchor 6 [m]
*/
LOG_ADD(LOG_FLOAT, pressure6, &state.pressures[6])
#endif
#if (LOCODECK_NR_OF_TWR_ANCHORS > 7)
/**
* @brief ASL of anchor 7 [m]
*/
LOG_ADD(LOG_FLOAT, pressure7, &state.pressures[7])
#endif
LOG_GROUP_STOP(ranging)
1 change: 1 addition & 0 deletions src/drivers/bosch/interface/bmp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
/* Header includes */
#include "bmp3_defs.h"

extern uint8_t bmp3_chip_id;

/*!
* @brief This API is the entry point.
Expand Down
Loading

0 comments on commit 8ee6ea4

Please sign in to comment.