Skip to content

Commit c0949f1

Browse files
committed
slight controller tuning
1 parent 44f08dc commit c0949f1

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

lib/controller/ASTRAv2_Controller.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Vector4 ASTRAv2_Controller(Vector3 PosTarget, Vector16 X, constantsASTRA_t const
4040
Vector3 PosError = PosTarget - X.segment<3>(4);
4141

4242
// Velocity Command
43-
Vector3 K_P = (Vector3() << 0.58, 0.58, 0.65).finished();
43+
Vector3 K_P = (Vector3() << 0.7, 0.7, 0.65).finished();
4444
Vector3 VelTarget = K_P.cwiseProduct(PosError);
4545

4646
// Velocity Saturation Step
@@ -57,8 +57,8 @@ Vector4 ASTRAv2_Controller(Vector3 PosTarget, Vector16 X, constantsASTRA_t const
5757
Vector3 Clamp = (Vector3() << 5, 5, 5).finished();
5858

5959
// Normalize errors (0 to 1 scale)
60-
Vector3 MaxAttError = (Vector3() << 0.05, 0.05, 0.3).finished();
61-
Vector3 MaxVelError = (Vector3() << 0.3, 0.3, 0.3).finished();
60+
Vector3 MaxAttError = (Vector3() << 0.06, 0.06, 0.3).finished();
61+
Vector3 MaxVelError = (Vector3() << 0.3, 0.3, 0.6).finished();
6262
Vector3 NormAttErr = lastAttError.cwiseAbs().cwiseQuotient(MaxAttError);
6363
Vector3 NormVelErr = VelError.cwiseAbs().cwiseQuotient(MaxVelError);
6464

@@ -72,7 +72,7 @@ Vector4 ASTRAv2_Controller(Vector3 PosTarget, Vector16 X, constantsASTRA_t const
7272
K_I = K_I.cwiseProduct(Gate);
7373
VelErrorI = VelErrorI + K_I.cwiseProduct(VelError) * dT;
7474
VelErrorI = VelErrorI.cwiseMin(Clamp).cwiseMax(-Clamp);
75-
K_P = (Vector3() << 3.1, 3.1, 5).finished();
75+
K_P = (Vector3() << 2.4, 2.4, 5).finished();
7676

7777
// Acceleration Target
7878
Vector3 AccelTarget = K_P.cwiseProduct(VelError) + VelErrorI + (Vector3() << 0, 0, constantsASTRA.g).finished();
@@ -125,7 +125,6 @@ Vector4 ASTRAv2_Controller(Vector3 PosTarget, Vector16 X, constantsASTRA_t const
125125
Vector3 u_components = -constantsASTRA.K_Att * X_Err;
126126
U[0] = u_components[0];
127127
U[1] = u_components[1];
128-
// U[2] is set above
129128
U[3] = u_components[2];
130129

131130
// Controls Saturation

lib/controller/FlightEstimator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Vector19 FlightEstimator(Vector19 x_est, constantsASTRA_t constantsASTRA, Vector
5959
H.block<3, 3>(3, 6) = Matrix3_3::Identity();
6060

6161
// Measurement Covariance Matrix
62-
float gps_pos_covar = 1 * RTK + 100 * (1 - RTK);
63-
float gps_vel_covar = gps_pos_covar * 1;
62+
float gps_pos_covar = 0.2 * RTK + 10 * (1 - RTK);
63+
float gps_vel_covar = 0.75;
6464
Matrix6_6 R = (Vector6() << pow(gps_pos_covar, 2) * Vector3::Ones(), pow(gps_vel_covar, 2) * Vector3::Ones()).finished().asDiagonal();
6565

6666
// A priori covariance and Kalman gain

lib/controller/GroundEstimator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ Vector19 GroundEstimator(Vector19 x_est, constantsASTRA_t constantsASTRA, Vector
8484
H.block<3, 3>(3, 6) = Matrix3_3::Identity();
8585

8686
// Measurement Covariance Matrix
87-
float gps_pos_covar = 1 * RTK + 130 * (1 - RTK);
88-
float gps_vel_covar = gps_pos_covar * 0.1;
87+
float gps_pos_covar = 0.5 * RTK + 10 * (1 - RTK);
88+
float gps_vel_covar = 0.5;
8989
R = (Vector6() << pow(gps_pos_covar, 2) * Vector3::Ones(), pow(gps_vel_covar, 2) * Vector3::Ones()).finished().asDiagonal();
9090

9191
// A priori covariance and Kalman gain

lib/controller/matlab_funcs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include <ArduinoEigenDense.h>
33

4-
// Note - using matlab funcs based off of ASTRA simulation: e5e0557ebb837f220d9740cd96e1020724bceb48
4+
// Note - using matlab funcs based off of ASTRA simulation: 3a2af9e756f0981da411d93f59ee6b421d5fa234
55
// TODO - update matlab func commit
66

77
using Vector3 = Eigen::Matrix<float, 3, 1>;

0 commit comments

Comments
 (0)