Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indi controller #483

Merged
merged 100 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9853a2d
Adding new controller possibility
andre-paraense Jul 24, 2019
b3f6c76
Adding new controller possibility - INDI
andre-paraense Jul 24, 2019
99e1637
Second order Butterworth low pass filter
Jul 25, 2019
7bcf054
INDI possibility
andre-paraense Jul 26, 2019
5bacff1
Removing the integer implementation and the fourth order filter
andre-paraense Jul 29, 2019
92cefc2
correcting license
andre-paraense Jul 30, 2019
7ebafe8
First steps of the INDI controller
andre-paraense Jul 30, 2019
2ba93ef
Avoid macros for things that can be an inline function
andre-paraense Jul 31, 2019
1277e43
Calculate the desired angular acceleration
andre-paraense Jul 31, 2019
a2b6eca
INDI feedback
andre-paraense Aug 1, 2019
08bd3ca
INDI feedback
andre-paraense Aug 1, 2019
b5221f1
Frequency of the controller as the IMU fequency
andre-paraense Aug 2, 2019
58b1036
Adapting parameters to Crazyflie reality
andre-paraense Aug 2, 2019
9f2c36d
Increment after in the air
andre-paraense Aug 2, 2019
8a2445b
TODO to check if controller can be changed dynamically during flight
andre-paraense Aug 2, 2019
024fb8f
maximum and minimum allowable command as specified for Crazyflie
andre-paraense Aug 2, 2019
443586d
Skipping calls faster than ATTITUDE_RATE
andre-paraense Aug 5, 2019
c6543d0
Correcting parameters for ERR and RATE
andre-paraense Aug 5, 2019
0966e85
Correcting parameters for ERR and DYN
andre-paraense Aug 5, 2019
3a9a17d
Logging and adjusting thrust initial level
andre-paraense Aug 6, 2019
b56e931
logs and parameters
andre-paraense Aug 7, 2019
cd13558
shorten parms and log names
andre-paraense Aug 7, 2019
57b8ccf
logging and small bugs
andre-paraense Aug 8, 2019
df4dfb4
Adaptive INDI as a parameter
andre-paraense Aug 10, 2019
86bd7b9
Adaptive as default
andre-paraense Aug 10, 2019
20f3550
signal correction
andre-paraense Aug 10, 2019
6878a42
control effectiveness estimated
andre-paraense Aug 19, 2019
445a299
control effectiveness estimated
andre-paraense Aug 19, 2019
5b48e47
control effectiveness estimation for INDI controller
andre-paraense Aug 21, 2019
d97bf33
script for extracting signals from usd deck card data
andre-paraense Aug 22, 2019
4589a5b
Parameter estimation
andre-paraense Aug 23, 2019
9f153a5
inverting yaw signal, following other impl
andre-paraense Aug 23, 2019
227a870
taking out estimation for a while
andre-paraense Aug 23, 2019
7ead2ba
Parameter estimation
andre-paraense Aug 28, 2019
62c2842
Improving thrust threshold
andre-paraense Aug 28, 2019
0330774
Improving code
andre-paraense Aug 28, 2019
7b3862e
Improving parameters and logging
andre-paraense Aug 28, 2019
5601057
cleaning code
andre-paraense Aug 28, 2019
75821ab
cleaning unused lms estimation code
andre-paraense Aug 28, 2019
fc9d451
Cleaning adaptive part, exposing parameters
andre-paraense Aug 29, 2019
ea9ddcc
correcting first order actuator dynamics constant
andre-paraense Aug 29, 2019
47836ea
correcting g2 constant
andre-paraense Aug 29, 2019
ab212a7
Improved calculation of the desired angular acceleration
andre-paraense Aug 29, 2019
30b019d
Improving attitude error calculation
andre-paraense Aug 29, 2019
fecbf7d
improving cycle rates
andre-paraense Aug 29, 2019
b13e847
Parametizing actuator dynamics and filter cutoff
andre-paraense Aug 30, 2019
793a485
logging mellinger signals
andre-paraense Aug 30, 2019
4335357
Caculating attitude error simple way
andre-paraense Sep 3, 2019
81df0a7
logging variables
andre-paraense Sep 3, 2019
a89ed30
Adding new controller possibility
andre-paraense Jul 24, 2019
390d99f
Adding new controller possibility - INDI
andre-paraense Jul 24, 2019
6d0c5df
Second order Butterworth low pass filter
Jul 25, 2019
7a937f2
INDI possibility
andre-paraense Jul 26, 2019
cf6b0ba
Removing the integer implementation and the fourth order filter
andre-paraense Jul 29, 2019
59d2127
correcting license
andre-paraense Jul 30, 2019
6a4553f
First steps of the INDI controller
andre-paraense Jul 30, 2019
fa9ec93
Avoid macros for things that can be an inline function
andre-paraense Jul 31, 2019
0d28eb8
Calculate the desired angular acceleration
andre-paraense Jul 31, 2019
e6fa372
INDI feedback
andre-paraense Aug 1, 2019
f7896de
INDI feedback
andre-paraense Aug 1, 2019
23e7474
Frequency of the controller as the IMU fequency
andre-paraense Aug 2, 2019
58b0174
Adapting parameters to Crazyflie reality
andre-paraense Aug 2, 2019
ae622aa
Increment after in the air
andre-paraense Aug 2, 2019
5fef653
TODO to check if controller can be changed dynamically during flight
andre-paraense Aug 2, 2019
1f23888
maximum and minimum allowable command as specified for Crazyflie
andre-paraense Aug 2, 2019
c748f1d
Skipping calls faster than ATTITUDE_RATE
andre-paraense Aug 5, 2019
9424069
Correcting parameters for ERR and RATE
andre-paraense Aug 5, 2019
dfba044
Correcting parameters for ERR and DYN
andre-paraense Aug 5, 2019
0cc97bd
Logging and adjusting thrust initial level
andre-paraense Aug 6, 2019
ad0b51e
logs and parameters
andre-paraense Aug 7, 2019
f63bfcc
shorten parms and log names
andre-paraense Aug 7, 2019
27a9cbc
logging and small bugs
andre-paraense Aug 8, 2019
3abcf12
Adaptive INDI as a parameter
andre-paraense Aug 10, 2019
b0a239e
Adaptive as default
andre-paraense Aug 10, 2019
40e67db
signal correction
andre-paraense Aug 10, 2019
b832207
control effectiveness estimated
andre-paraense Aug 19, 2019
e07ddbc
control effectiveness estimated
andre-paraense Aug 19, 2019
c3e65aa
control effectiveness estimation for INDI controller
andre-paraense Aug 21, 2019
2611feb
script for extracting signals from usd deck card data
andre-paraense Aug 22, 2019
8e87c5e
Parameter estimation
andre-paraense Aug 23, 2019
43fce95
inverting yaw signal, following other impl
andre-paraense Aug 23, 2019
5c52bd7
taking out estimation for a while
andre-paraense Aug 23, 2019
1a9ba1e
Parameter estimation
andre-paraense Aug 28, 2019
4457e10
Improving thrust threshold
andre-paraense Aug 28, 2019
9a608a6
Improving code
andre-paraense Aug 28, 2019
0fb4514
Improving parameters and logging
andre-paraense Aug 28, 2019
d5c37d1
cleaning code
andre-paraense Aug 28, 2019
15e8b3e
cleaning unused lms estimation code
andre-paraense Aug 28, 2019
f726855
Cleaning adaptive part, exposing parameters
andre-paraense Aug 29, 2019
68230f8
correcting first order actuator dynamics constant
andre-paraense Aug 29, 2019
73bdb8f
correcting g2 constant
andre-paraense Aug 29, 2019
7a6afff
Improved calculation of the desired angular acceleration
andre-paraense Aug 29, 2019
3c94a1d
Improving attitude error calculation
andre-paraense Aug 29, 2019
16d1477
improving cycle rates
andre-paraense Aug 29, 2019
d06f82b
Parametizing actuator dynamics and filter cutoff
andre-paraense Aug 30, 2019
e60bbe9
logging mellinger signals
andre-paraense Aug 30, 2019
845d3ee
Caculating attitude error simple way
andre-paraense Sep 3, 2019
4c5d160
logging variables
andre-paraense Sep 3, 2019
edd02f9
Merge branch 'indi-controller' of github.com:amreelab/crazyflie-firmw…
andre-paraense Oct 4, 2019
1cb694c
cleaning log data
andre-paraense Oct 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CFLAGS += -DCRAZYFLIE_FW
######### Stabilizer configuration ##########
## These are set by the platform (see tools/make/platforms/*.mk), can be overwritten here
ESTIMATOR ?= any
CONTROLLER ?= Any # one of Any, PID, Mellinger
CONTROLLER ?= Any # one of Any, PID, Mellinger, INDI
POWER_DISTRIBUTION ?= stock

#OpenOCD conf
Expand Down Expand Up @@ -156,7 +156,7 @@ PROJ_OBJ += crtp_commander_generic.o crtp_localization_service.o
PROJ_OBJ += attitude_pid_controller.o sensfusion6.o stabilizer.o
PROJ_OBJ += position_estimator_altitude.o position_controller_pid.o
PROJ_OBJ += estimator.o estimator_complementary.o
PROJ_OBJ += controller.o controller_pid.o controller_mellinger.o
PROJ_OBJ += controller.o controller_pid.o controller_mellinger.o controller_indi.o
PROJ_OBJ += power_distribution_$(POWER_DISTRIBUTION).o
PROJ_OBJ += estimator_kalman.o kalman_core.o kalman_supervisor.o

Expand Down
1 change: 1 addition & 0 deletions src/modules/interface/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef enum {
ControllerTypeAny,
ControllerTypePID,
ControllerTypeMellinger,
ControllerTypeINDI,
ControllerType_COUNT,
} ControllerType;

Expand Down
106 changes: 106 additions & 0 deletions src/modules/interface/controller_indi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie control firmware
*
* Copyright (C) 2011-2016 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/>.
*
* controller_indi.h - INDI Controller Interface
*/
#ifndef __CONTROLLER_INDI_H__
#define __CONTROLLER_INDI_H__

#include "stabilizer_types.h"
#include "filter.h"
#include "math3d.h"
#include "log.h"
#include "param.h"
#include "position_controller.h"
#include "attitude_controller.h"

#define ATTITUDE_UPDATE_DT (float)(1.0f/ATTITUDE_RATE)

#define PI 3.14159265358979323846f

// these parameters are used in the filtering of the angular acceleration
#define STABILIZATION_INDI_FILT_CUTOFF 8.0f

// the yaw sometimes requires more filtering
#define STABILIZATION_INDI_FILT_CUTOFF_R STABILIZATION_INDI_FILT_CUTOFF

// these parameters are used in the filtering of the angular acceleration
#define STABILIZATION_INDI_G1_P 0.0034724f
#define STABILIZATION_INDI_G1_Q 0.0052575f
#define STABILIZATION_INDI_G1_R -0.0015942f
#define STABILIZATION_INDI_G2_R -0.11281f
#define STABILIZATION_INDI_REF_ERR_P 3.57f
#define STABILIZATION_INDI_REF_ERR_Q 3.57f
#define STABILIZATION_INDI_REF_ERR_R 3.57f
#define STABILIZATION_INDI_REF_RATE_P 14.0f
#define STABILIZATION_INDI_REF_RATE_Q 14.0f
#define STABILIZATION_INDI_REF_RATE_R 14.0f
#define STABILIZATION_INDI_ACT_DYN_P 0.03149f
#define STABILIZATION_INDI_ACT_DYN_Q 0.03149f
#define STABILIZATION_INDI_ACT_DYN_R 0.03149f

/**
* @brief angular rates
* @details Units: rad/s */
struct FloatRates {
float p; ///< in rad/s
float q; ///< in rad/s
float r; ///< in rad/s
};

struct ReferenceSystem {
float err_p;
float err_q;
float err_r;
float rate_p;
float rate_q;
float rate_r;
};

struct IndiVariables {
float thrust;
struct FloatRates angular_accel_ref;
struct FloatRates du;
struct FloatRates u_in;
struct FloatRates u_act_dyn;
float rate_d[3];

Butterworth2LowPass u[3];
Butterworth2LowPass rate[3];
struct FloatRates g1;
float g2;

struct ReferenceSystem reference_acceleration;
struct FloatRates act_dyn;
float filt_cutoff;
float filt_cutoff_r;
};

void controllerINDIInit(void);
bool controllerINDITest(void);
void controllerINDI(control_t *control, setpoint_t *setpoint,
const sensorData_t *sensors,
const state_t *state,
const uint32_t tick);

#endif //__CONTROLLER_INDI_H__
2 changes: 1 addition & 1 deletion src/modules/interface/controller_mellinger.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* controller_pid.h - Mellinger Controller Interface
* controller_mellinger.h - Mellinger Controller Interface
*/
#ifndef __CONTROLLER_MELLINGER_H__
#define __CONTROLLER_MELLINGER_H__
Expand Down
4 changes: 3 additions & 1 deletion src/modules/src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "controller.h"
#include "controller_pid.h"
#include "controller_mellinger.h"
#include "controller_indi.h"

#define DEFAULT_CONTROLLER ControllerTypePID
static ControllerType currentController = ControllerTypeAny;
Expand All @@ -22,6 +23,7 @@ static ControllerFcns controllerFunctions[] = {
{.init = 0, .test = 0, .update = 0, .name = "None"}, // Any
{.init = controllerPidInit, .test = controllerPidTest, .update = controllerPid, .name = "PID"},
{.init = controllerMellingerInit, .test = controllerMellingerTest, .update = controllerMellinger, .name = "Mellinger"},
{.init = controllerINDIInit, .test = controllerINDITest, .update = controllerINDI, .name = "INDI"},
};


Expand Down Expand Up @@ -65,4 +67,4 @@ void controller(control_t *control, setpoint_t *setpoint, const sensorData_t *se

const char* controllerGetName() {
return controllerFunctions[currentController].name;
}
}
Loading