Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kierdavis committed Mar 13, 2017
1 parent bc5ea20 commit adbe2d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ void control_cycle(measured_state_t *measured_state,
// roll_factor = desired_state->roll*0.01;
// pitch_factor = desired_state->pitch*0.01;
// yaw_factor = desired_state->yaw_vel*0.1;
z_factor = 0.45;
z_factor = 0.5;
//roll_factor = 0.0;
//pitch_factor = 0.0;
yaw_factor = 0.0;
//t += 0.00001;

printf("LOG %f,%f,%f\n", dt_float, z_factor, measured_state->z_vel);
z_factor = 0.0;
roll_factor = 0.0;
pitch_factor = 0.0;
yaw_factor = 0.0;

// printf("LOG %f,%f,%f\n", dt_float, z_factor, measured_state->z_vel);

//printf("z_vel error=%f-%f zfactor=%f\n", desired_state->z_vel, measured_state->z_vel, z_factor);

Expand All @@ -85,7 +90,8 @@ void control_cycle(measured_state_t *measured_state,
rotor_speeds->a = 0.0 + z_factor + roll_factor - pitch_factor + yaw_factor;
rotor_speeds->b = 0.0 + z_factor - roll_factor - pitch_factor - yaw_factor;
rotor_speeds->c = 0.0 + z_factor - roll_factor + pitch_factor + yaw_factor - 0.02;
rotor_speeds->d = 0.0 + z_factor + roll_factor + pitch_factor - yaw_factor;
rotor_speeds->d = 0.0 + z_factor + roll_factor + pitch_factor - yaw_factor - 0.02;

//printf("r=%f p=%f zf=%f rf=%f pf=%f yf=%f a=%f b=%f c=%f d=%f\n", measured_state->roll, measured_state->pitch, z_factor, roll_factor, pitch_factor, yaw_factor, rotor_speeds->a, rotor_speeds->b, rotor_speeds->c, rotor_speeds->d);
// printf("r=%f p=%f a=%f b=%f c=%f d=%f\n", measured_state->roll, measured_state->pitch, rotor_speeds->a, rotor_speeds->b, rotor_speeds->c, rotor_speeds->d);
}
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main() {
imu_read(&measured_state);
convert_logg_packet(&measured_state);

//printf("%f,%f,%f,%f\n", desired_state.z_vel, desired_state.roll, desired_state.pitch, desired_state.yaw_vel);
printf("%f,%f,%f,%f\n", desired_state.z_vel, desired_state.roll, desired_state.pitch, desired_state.yaw_vel);

//printf("%f,%f,%f\n", measured_state.roll, measured_state.pitch, measured_state.yaw_vel);

Expand Down
8 changes: 4 additions & 4 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#define MAX_INTEGRAL_Z 1.0

// Roll-factor PID parameters.
#define PID_GAIN_ROLL_P 0.1
#define PID_GAIN_ROLL_P 0.02
#define PID_GAIN_ROLL_I 0.0
#define PID_GAIN_ROLL_D 0.02
#define PID_GAIN_ROLL_D 0.021
#define MIN_INTEGRAL_ROLL -1.0
#define MAX_INTEGRAL_ROLL 1.0

Expand All @@ -40,9 +40,9 @@
// Iteration 2: -0.4264/-2.777/-0.0006686
// Fixed axis
// Iteration 3: 4.82/545.7/0.0003971
#define PID_GAIN_PITCH_P 0.1
#define PID_GAIN_PITCH_P 0.02
#define PID_GAIN_PITCH_I 0.002
#define PID_GAIN_PITCH_D 0.015
#define PID_GAIN_PITCH_D 0.016
#define MIN_INTEGRAL_PITCH -1.0
#define MAX_INTEGRAL_PITCH 1.0

Expand Down

0 comments on commit adbe2d5

Please sign in to comment.