diff --git a/quad/sw/modular_quad_pid/gen_diagram/.gitignore b/quad/sw/modular_quad_pid/gen_diagram/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3309c19da797a4bb0267176e58ce348e67656baf --- /dev/null +++ b/quad/sw/modular_quad_pid/gen_diagram/.gitignore @@ -0,0 +1 @@ +gen_diagram diff --git a/quad/sw/modular_quad_pid/gen_diagram/Makefile b/quad/sw/modular_quad_pid/gen_diagram/Makefile index 610e289a0430678f42d41648f6c8f98143450b6a..8b917561ca32082fa5a372a882c1e53726da8692 100644 --- a/quad/sw/modular_quad_pid/gen_diagram/Makefile +++ b/quad/sw/modular_quad_pid/gen_diagram/Makefile @@ -1,9 +1,8 @@ -COMP_GRAPH = ../../../computation_graph QUAD_BLOCKS = ../src/graph_blocks gen_diagram: generate.c - gcc -o gen_diagram -I. -I$(COMP_GRAPH)/src generate.c $(COMP_GRAPH)/src/computation_graph.c $(QUAD_BLOCKS)/node_bounds.c $(QUAD_BLOCKS)/node_pid.c $(QUAD_BLOCKS)/node_mixer.c + gcc -o gen_diagram -I. -I../src/ generate.c ../src/computation_graph.c ../src/graph_blocks/*.c .PHONY: clean clean: diff --git a/quad/sw/modular_quad_pid/gen_diagram/gen_diagram b/quad/sw/modular_quad_pid/gen_diagram/gen_diagram old mode 100644 new mode 100755 index ae1620225638cc42929390bc1646225a8b1cbbf3..5d50c13396d1172f12984958207f5e271945d385 Binary files a/quad/sw/modular_quad_pid/gen_diagram/gen_diagram and b/quad/sw/modular_quad_pid/gen_diagram/gen_diagram differ diff --git a/quad/sw/modular_quad_pid/gen_diagram/generate.c b/quad/sw/modular_quad_pid/gen_diagram/generate.c index b7cc7966c71e37df5759f62aa0c6c6a938b94358..3563ede331394d76ec537d1292420a19e8175d0e 100644 --- a/quad/sw/modular_quad_pid/gen_diagram/generate.c +++ b/quad/sw/modular_quad_pid/gen_diagram/generate.c @@ -1,9 +1,10 @@ #include <stdio.h> + #include "computation_graph.h" -#include "../src/graph_blocks/node_pid.h" -#include "../src/graph_blocks/node_bounds.h" +#include "graph_blocks/node_pid.h" +#include "graph_blocks/node_bounds.h" #include "graph_blocks/node_constant.h" -#include "../src/graph_blocks/node_mixer.h" +#include "graph_blocks/node_mixer.h" #include "local_PID.h" #define ROLL_PITCH_MAX_ANGLE 0.3490 // 20 degrees @@ -49,137 +50,140 @@ parameter_t ps; int control_algorithm_init(parameter_t * ps); int main() { - + control_algorithm_init(&ps); FILE* dot_fp; - dot_fp = fopen(".\\network.dot", "w"); - export_dot(ps.graph, dot_fp); + dot_fp = fopen("network.dot", "w"); + export_dot(ps.graph, dot_fp, 0); fclose(dot_fp); } - - int control_algorithm_init(parameter_t * ps) - { - struct computation_graph* graph = create_graph(); - ps->graph = graph; - - // Create all the PID blocks - ps->roll_pid = graph_add_node_pid(graph, "Roll PID"); - ps->pitch_pid = graph_add_node_pid(graph, "Pitch PID"); - ps->yaw_pid = graph_add_node_pid(graph, "Yaw PID"); - ps->roll_r_pid = graph_add_node_pid(graph, "Roll Rate PID"); - ps->pitch_r_pid = graph_add_node_pid(graph, "Pitch Rate PID"); - ps->yaw_r_pid = graph_add_node_pid(graph, "Yaw Rate PID"); - ps->x_pos_pid = graph_add_node_pid(graph, "X pos PID PID"); - ps->y_pos_pid = graph_add_node_pid(graph, "Y pos PID"); - ps->alt_pid = graph_add_node_pid(graph, "Altitude"); - - // Create blocks for bounds checking - ps->clamp_d_pwmP = graph_add_node_bounds(graph, "P PWM Clamp"); - ps->clamp_d_pwmR = graph_add_node_bounds(graph, "R PWM Clamp"); - ps->clamp_d_pwmY = graph_add_node_bounds(graph, "Y PWM Clamp"); - ps->clamp_pitch = graph_add_node_bounds(graph, "Pitch Clamp"); - ps->clamp_roll= graph_add_node_bounds(graph, "Roll Clamp"); - - // Create blocks for sensor inputs - ps->cur_pitch = graph_add_node_const(graph, "Pitch"); - ps->cur_roll = graph_add_node_const(graph, "Roll"); - ps->cur_yaw = graph_add_node_const(graph, "Yaw"); - // Yaw angular velocity PID - // theta_dot is the angular velocity about the y-axis - // phi_dot is the angular velocity about the x-axis - // psi_dot is the angular velocity about the z-axis - // These are calculated from using the gimbal equations - ps->theta_dot = graph_add_node_const(graph, "dTheta"); - ps->phi_dot = graph_add_node_const(graph, "dPhi"); - ps->psi_dot = graph_add_node_const(graph, "dPsi"); - - // Create blocks for RC controller - ps->rc_pitch = graph_add_node_const(graph, "RC Pitch"); - ps->rc_roll = graph_add_node_const(graph, "RC Roll"); - ps->rc_yaw = graph_add_node_const(graph, "RC Yaw"); - ps->rc_throttle = graph_add_node_const(graph, "RC Throttle"); - - ps->mixer = graph_add_node_mixer(graph, "Signal Mixer"); - - ps->dt = graph_add_node_const(graph, "dT"); - - // Connect pitch PID chain - graph_set_source(graph, ps->pitch_r_pid, PID_SETPOINT, ps->pitch_pid, PID_CORRECTION); - graph_set_source(graph, ps->pitch_r_pid, PID_CUR_POINT, ps->theta_dot, CONST_VAL); - graph_set_source(graph, ps->pitch_r_pid, PID_DT, ps->dt, CONST_VAL); - graph_set_source(graph, ps->pitch_pid, PID_SETPOINT, ps->rc_pitch, CONST_VAL); - graph_set_source(graph, ps->pitch_pid, PID_CUR_POINT, ps->cur_pitch, CONST_VAL); - graph_set_source(graph, ps->pitch_pid, PID_DT, ps->dt, CONST_VAL); - - // Connect roll PID chain - graph_set_source(graph, ps->roll_r_pid, PID_SETPOINT, ps->roll_pid, PID_CORRECTION); - graph_set_source(graph, ps->roll_r_pid, PID_CUR_POINT, ps->phi_dot, CONST_VAL); - graph_set_source(graph, ps->roll_r_pid, PID_DT, ps->dt, CONST_VAL); - graph_set_source(graph, ps->roll_pid, PID_SETPOINT, ps->rc_roll, CONST_VAL); - graph_set_source(graph, ps->roll_pid, PID_CUR_POINT, ps->cur_roll, CONST_VAL); - graph_set_source(graph, ps->roll_pid, PID_DT, ps->dt, CONST_VAL); - - // Connect yaw PID chain - graph_set_source(graph, ps->yaw_r_pid, PID_SETPOINT, ps->rc_yaw, PID_CORRECTION); - graph_set_source(graph, ps->yaw_r_pid, PID_CUR_POINT, ps->psi_dot, CONST_VAL); - graph_set_source(graph, ps->yaw_r_pid, PID_DT, ps->dt, CONST_VAL); - /* - graph_set_source(graph, ps->yaw_pid, PID_SETPOINT, ps->rc_yaw, CONST_VAL); - graph_set_source(graph, ps->yaw_pid, PID_CUR_POINT, ps->yaw, CONST_VAL); - graph_set_source(graph, ps->yaw_pid, PID_DT, ps->dt, CONST_VAL); - */ - - // Connect PWM clamping blocks - graph_set_source(graph, ps->clamp_d_pwmP, BOUNDS_IN, ps->pitch_r_pid, PID_CORRECTION); - graph_set_source(graph, ps->clamp_d_pwmR, BOUNDS_IN, ps->roll_r_pid, PID_CORRECTION); - graph_set_source(graph, ps->clamp_d_pwmY, BOUNDS_IN, ps->yaw_r_pid, PID_CORRECTION); - - // Connect signal mixer - graph_set_source(graph, ps->mixer, MIXER_THROTTLE, ps->rc_throttle, CONST_VAL); - graph_set_source(graph, ps->mixer, MIXER_PITCH, ps->clamp_d_pwmP, BOUNDS_OUT); - graph_set_source(graph, ps->mixer, MIXER_ROLL, ps->clamp_d_pwmR, BOUNDS_OUT); - graph_set_source(graph, ps->mixer, MIXER_YAW, ps->clamp_d_pwmY, BOUNDS_OUT); - - // Set pitch PID constants - graph_set_param_val(graph, ps->pitch_pid, PID_KP, PITCH_ANGLE_KP); - graph_set_param_val(graph, ps->pitch_pid, PID_KI, PITCH_ANGLE_KI); - graph_set_param_val(graph, ps->pitch_pid, PID_KD, PITCH_ANGLE_KD); - graph_set_param_val(graph, ps->pitch_r_pid, PID_KP, PITCH_ANGULAR_VELOCITY_KP); - graph_set_param_val(graph, ps->pitch_r_pid, PID_KI, PITCH_ANGULAR_VELOCITY_KI); - graph_set_param_val(graph, ps->pitch_r_pid, PID_KD, PITCH_ANGULAR_VELOCITY_KD); - - // Set roll PID constants - graph_set_param_val(graph, ps->roll_pid, PID_KP, ROLL_ANGLE_KP); - graph_set_param_val(graph, ps->roll_pid, PID_KI, ROLL_ANGLE_KI); - graph_set_param_val(graph, ps->roll_pid, PID_KD, ROLL_ANGLE_KD); - graph_set_param_val(graph, ps->roll_r_pid, PID_KP, ROLL_ANGULAR_VELOCITY_KP); - graph_set_param_val(graph, ps->roll_r_pid, PID_KI, ROLL_ANGULAR_VELOCITY_KI); - graph_set_param_val(graph, ps->roll_r_pid, PID_KD, ROLL_ANGULAR_VELOCITY_KD); - - // Set yaw PID constants - graph_set_param_val(graph, ps->yaw_pid, PID_KP, YAW_ANGLE_KP); - graph_set_param_val(graph, ps->yaw_pid, PID_KI, YAW_ANGLE_KI); - graph_set_param_val(graph, ps->yaw_pid, PID_KD, YAW_ANGLE_KD); - graph_set_param_val(graph, ps->yaw_r_pid, PID_KP, YAW_ANGULAR_VELOCITY_KP); - graph_set_param_val(graph, ps->yaw_r_pid, PID_KI, YAW_ANGULAR_VELOCITY_KI); - graph_set_param_val(graph, ps->yaw_r_pid, PID_KD, YAW_ANGULAR_VELOCITY_KD); - - // Set angle clamping limits - graph_set_param_val(graph, ps->clamp_pitch, BOUNDS_MIN, -ROLL_PITCH_MAX_ANGLE); - graph_set_param_val(graph, ps->clamp_pitch, BOUNDS_MAX, ROLL_PITCH_MAX_ANGLE); - graph_set_param_val(graph, ps->clamp_roll, BOUNDS_MIN, -ROLL_PITCH_MAX_ANGLE); - graph_set_param_val(graph, ps->clamp_roll, BOUNDS_MAX, ROLL_PITCH_MAX_ANGLE); - - // Set PWM difference clamping limits - graph_set_param_val(graph, ps->clamp_d_pwmP, BOUNDS_MIN, -20000); - graph_set_param_val(graph, ps->clamp_d_pwmP, BOUNDS_MAX, 20000); - graph_set_param_val(graph, ps->clamp_d_pwmR, BOUNDS_MIN, -20000); - graph_set_param_val(graph, ps->clamp_d_pwmR, BOUNDS_MAX, 20000); - graph_set_param_val(graph, ps->clamp_d_pwmY, BOUNDS_MIN, -20000); - graph_set_param_val(graph, ps->clamp_d_pwmY, BOUNDS_MAX, 20000); - - // TODO: Change this to use LOOP_TIME - graph_set_param_val(graph, ps->dt, CONST_SET, 0.005); - - return 0; - } +int control_algorithm_init(parameter_t * ps) +{ + struct computation_graph* graph = create_graph(); + ps->graph = graph; + + // Create all the PID blocks + ps->roll_pid = graph_add_node_pid(graph, "Roll PID"); + ps->pitch_pid = graph_add_node_pid(graph, "Pitch PID"); + ps->yaw_pid = graph_add_node_pid(graph, "Yaw PID"); + ps->roll_r_pid = graph_add_node_pid(graph, "Roll Rate PID"); + ps->pitch_r_pid = graph_add_node_pid(graph, "Pitch Rate PID"); + ps->yaw_r_pid = graph_add_node_pid(graph, "Yaw Rate PID"); + ps->x_pos_pid = graph_add_node_pid(graph, "X pos PID PID"); + ps->y_pos_pid = graph_add_node_pid(graph, "Y pos PID"); + ps->alt_pid = graph_add_node_pid(graph, "Altitude"); + + // Create blocks for bounds checking + ps->clamp_d_pwmP = graph_add_node_bounds(graph, "P PWM Clamp"); + ps->clamp_d_pwmR = graph_add_node_bounds(graph, "R PWM Clamp"); + ps->clamp_d_pwmY = graph_add_node_bounds(graph, "Y PWM Clamp"); + ps->clamp_pitch = graph_add_node_bounds(graph, "Pitch Clamp"); + ps->clamp_roll= graph_add_node_bounds(graph, "Roll Clamp"); + + // Create blocks for sensor inputs + ps->cur_pitch = graph_add_node_const(graph, "Pitch"); + ps->cur_roll = graph_add_node_const(graph, "Roll"); + ps->cur_yaw = graph_add_node_const(graph, "Yaw"); + // Yaw angular velocity PID + // theta_dot is the angular velocity about the y-axis + // phi_dot is the angular velocity about the x-axis + // psi_dot is the angular velocity about the z-axis + // These are calculated from using the gimbal equations + ps->theta_dot = graph_add_node_const(graph, "dTheta"); + ps->phi_dot = graph_add_node_const(graph, "dPhi"); + ps->psi_dot = graph_add_node_const(graph, "dPsi"); + + // Create blocks for RC controller + ps->rc_pitch = graph_add_node_const(graph, "RC Pitch"); + ps->rc_roll = graph_add_node_const(graph, "RC Roll"); + ps->rc_yaw = graph_add_node_const(graph, "RC Yaw"); + ps->rc_throttle = graph_add_node_const(graph, "RC Throttle"); + + ps->mixer = graph_add_node_mixer(graph, "Signal Mixer"); + + ps->dt = graph_add_node_const(graph, "dT"); + + // Connect pitch PID chain + graph_set_source(graph, ps->pitch_r_pid, PID_SETPOINT, ps->pitch_pid, PID_CORRECTION); + graph_set_source(graph, ps->pitch_r_pid, PID_CUR_POINT, ps->theta_dot, CONST_VAL); + graph_set_source(graph, ps->pitch_r_pid, PID_DT, ps->dt, CONST_VAL); + graph_set_source(graph, ps->pitch_pid, PID_SETPOINT, ps->rc_pitch, CONST_VAL); + graph_set_source(graph, ps->pitch_pid, PID_CUR_POINT, ps->cur_pitch, CONST_VAL); + graph_set_source(graph, ps->pitch_pid, PID_DT, ps->dt, CONST_VAL); + + // Connect roll PID chain + graph_set_source(graph, ps->roll_r_pid, PID_SETPOINT, ps->roll_pid, PID_CORRECTION); + graph_set_source(graph, ps->roll_r_pid, PID_CUR_POINT, ps->phi_dot, CONST_VAL); + graph_set_source(graph, ps->roll_r_pid, PID_DT, ps->dt, CONST_VAL); + graph_set_source(graph, ps->roll_pid, PID_SETPOINT, ps->rc_roll, CONST_VAL); + graph_set_source(graph, ps->roll_pid, PID_CUR_POINT, ps->cur_roll, CONST_VAL); + graph_set_source(graph, ps->roll_pid, PID_DT, ps->dt, CONST_VAL); + + // Connect yaw PID chain + graph_set_source(graph, ps->yaw_r_pid, PID_SETPOINT, ps->rc_yaw, PID_CORRECTION); + graph_set_source(graph, ps->yaw_r_pid, PID_CUR_POINT, ps->psi_dot, CONST_VAL); + graph_set_source(graph, ps->yaw_r_pid, PID_DT, ps->dt, CONST_VAL); + /* + graph_set_source(graph, ps->yaw_pid, PID_SETPOINT, ps->rc_yaw, CONST_VAL); + graph_set_source(graph, ps->yaw_pid, PID_CUR_POINT, ps->yaw, CONST_VAL); + graph_set_source(graph, ps->yaw_pid, PID_DT, ps->dt, CONST_VAL); + */ + + // Connect angle clamping blocks + graph_set_source(graph, ps->clamp_pitch, BOUNDS_IN, ps->y_pos_pid, PID_CORRECTION); + graph_set_source(graph, ps->clamp_roll, BOUNDS_IN, ps->x_pos_pid, PID_CORRECTION); + + // Connect PWM clamping blocks + graph_set_source(graph, ps->clamp_d_pwmP, BOUNDS_IN, ps->pitch_r_pid, PID_CORRECTION); + graph_set_source(graph, ps->clamp_d_pwmR, BOUNDS_IN, ps->roll_r_pid, PID_CORRECTION); + graph_set_source(graph, ps->clamp_d_pwmY, BOUNDS_IN, ps->yaw_r_pid, PID_CORRECTION); + + // Connect signal mixer + graph_set_source(graph, ps->mixer, MIXER_THROTTLE, ps->rc_throttle, CONST_VAL); + graph_set_source(graph, ps->mixer, MIXER_PITCH, ps->clamp_d_pwmP, BOUNDS_OUT); + graph_set_source(graph, ps->mixer, MIXER_ROLL, ps->clamp_d_pwmR, BOUNDS_OUT); + graph_set_source(graph, ps->mixer, MIXER_YAW, ps->clamp_d_pwmY, BOUNDS_OUT); + + // Set pitch PID constants + graph_set_param_val(graph, ps->pitch_pid, PID_KP, PITCH_ANGLE_KP); + graph_set_param_val(graph, ps->pitch_pid, PID_KI, PITCH_ANGLE_KI); + graph_set_param_val(graph, ps->pitch_pid, PID_KD, PITCH_ANGLE_KD); + graph_set_param_val(graph, ps->pitch_r_pid, PID_KP, PITCH_ANGULAR_VELOCITY_KP); + graph_set_param_val(graph, ps->pitch_r_pid, PID_KI, PITCH_ANGULAR_VELOCITY_KI); + graph_set_param_val(graph, ps->pitch_r_pid, PID_KD, PITCH_ANGULAR_VELOCITY_KD); + + // Set roll PID constants + graph_set_param_val(graph, ps->roll_pid, PID_KP, ROLL_ANGLE_KP); + graph_set_param_val(graph, ps->roll_pid, PID_KI, ROLL_ANGLE_KI); + graph_set_param_val(graph, ps->roll_pid, PID_KD, ROLL_ANGLE_KD); + graph_set_param_val(graph, ps->roll_r_pid, PID_KP, ROLL_ANGULAR_VELOCITY_KP); + graph_set_param_val(graph, ps->roll_r_pid, PID_KI, ROLL_ANGULAR_VELOCITY_KI); + graph_set_param_val(graph, ps->roll_r_pid, PID_KD, ROLL_ANGULAR_VELOCITY_KD); + + // Set yaw PID constants + graph_set_param_val(graph, ps->yaw_pid, PID_KP, YAW_ANGLE_KP); + graph_set_param_val(graph, ps->yaw_pid, PID_KI, YAW_ANGLE_KI); + graph_set_param_val(graph, ps->yaw_pid, PID_KD, YAW_ANGLE_KD); + graph_set_param_val(graph, ps->yaw_r_pid, PID_KP, YAW_ANGULAR_VELOCITY_KP); + graph_set_param_val(graph, ps->yaw_r_pid, PID_KI, YAW_ANGULAR_VELOCITY_KI); + graph_set_param_val(graph, ps->yaw_r_pid, PID_KD, YAW_ANGULAR_VELOCITY_KD); + + // Set angle clamping limits + graph_set_param_val(graph, ps->clamp_pitch, BOUNDS_MIN, -ROLL_PITCH_MAX_ANGLE); + graph_set_param_val(graph, ps->clamp_pitch, BOUNDS_MAX, ROLL_PITCH_MAX_ANGLE); + graph_set_param_val(graph, ps->clamp_roll, BOUNDS_MIN, -ROLL_PITCH_MAX_ANGLE); + graph_set_param_val(graph, ps->clamp_roll, BOUNDS_MAX, ROLL_PITCH_MAX_ANGLE); + + // Set PWM difference clamping limits + graph_set_param_val(graph, ps->clamp_d_pwmP, BOUNDS_MIN, -20000); + graph_set_param_val(graph, ps->clamp_d_pwmP, BOUNDS_MAX, 20000); + graph_set_param_val(graph, ps->clamp_d_pwmR, BOUNDS_MIN, -20000); + graph_set_param_val(graph, ps->clamp_d_pwmR, BOUNDS_MAX, 20000); + graph_set_param_val(graph, ps->clamp_d_pwmY, BOUNDS_MIN, -20000); + graph_set_param_val(graph, ps->clamp_d_pwmY, BOUNDS_MAX, 20000); + + // TODO: Change this to use LOOP_TIME + graph_set_param_val(graph, ps->dt, CONST_SET, 0.005); + + return 0; +} diff --git a/quad/sw/modular_quad_pid/gen_diagram/local_PID.h b/quad/sw/modular_quad_pid/gen_diagram/local_PID.h index 376b1f1b921d8aceab6da3120aa58abccdb8a103..d0ff70e210bcfb8833d123808049291174bf1d01 100644 --- a/quad/sw/modular_quad_pid/gen_diagram/local_PID.h +++ b/quad/sw/modular_quad_pid/gen_diagram/local_PID.h @@ -79,7 +79,5 @@ #define ALT_ZPOS_KI 817.0f #define ALT_ZPOS_KD 7353.0f -// Computes control error and correction -PID_values pid_computation(PID_t *pid); #endif /* PID_H_ */ diff --git a/quad/sw/modular_quad_pid/gen_diagram/network.dot b/quad/sw/modular_quad_pid/gen_diagram/network.dot new file mode 100644 index 0000000000000000000000000000000000000000..7e628deb20a80511b4d5f0c6529d3336bfa9bf21 --- /dev/null +++ b/quad/sw/modular_quad_pid/gen_diagram/network.dot @@ -0,0 +1,215 @@ +digraph G { +rankdir="LR" +"Roll PID"[shape=record +label=" +<f0> Roll PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=15.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.200] +"] +"Roll" -> "Roll PID":f1 +"RC Roll" -> "Roll PID":f2 +"dT" -> "Roll PID":f3 +"Pitch PID"[shape=record +label=" +<f0> Pitch PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=15.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.200] +"] +"Pitch" -> "Pitch PID":f1 +"RC Pitch" -> "Pitch PID":f2 +"dT" -> "Pitch PID":f3 +"Yaw PID"[shape=record +label=" +<f0> Yaw PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=2.600] +|<f5> [Ki=0.000] +|<f6> [Kd=0.000] +"] +"Roll Rate PID"[shape=record +label=" +<f0> Roll Rate PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=4600.000] +|<f5> [Ki=0.000] +|<f6> [Kd=550.000] +"] +"dPhi" -> "Roll Rate PID":f1 +"Roll PID" -> "Roll Rate PID":f2 +"dT" -> "Roll Rate PID":f3 +"Pitch Rate PID"[shape=record +label=" +<f0> Pitch Rate PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=4600.000] +|<f5> [Ki=0.000] +|<f6> [Kd=550.000] +"] +"dTheta" -> "Pitch Rate PID":f1 +"Pitch PID" -> "Pitch Rate PID":f2 +"dT" -> "Pitch Rate PID":f3 +"Yaw Rate PID"[shape=record +label=" +<f0> Yaw Rate PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=435480.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.000] +"] +"dPsi" -> "Yaw Rate PID":f1 +"RC Yaw" -> "Yaw Rate PID":f2 +"dT" -> "Yaw Rate PID":f3 +"X pos PID PID"[shape=record +label=" +<f0> X pos PID PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=0.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.000] +"] +"Y pos PID"[shape=record +label=" +<f0> Y pos PID +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=0.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.000] +"] +"Altitude"[shape=record +label=" +<f0> Altitude +|<f1> --\>Cur point +|<f2> --\>Setpoint +|<f3> --\>dt +|<f4> [Kp=0.000] +|<f5> [Ki=0.000] +|<f6> [Kd=0.000] +"] +"P PWM Clamp"[shape=record +label=" +<f0> P PWM Clamp +|<f1> --\>Bounds in +|<f2> [Min=-20000.000] +|<f3> [Max=20000.000] +"] +"Pitch Rate PID" -> "P PWM Clamp":f1 +"R PWM Clamp"[shape=record +label=" +<f0> R PWM Clamp +|<f1> --\>Bounds in +|<f2> [Min=-20000.000] +|<f3> [Max=20000.000] +"] +"Roll Rate PID" -> "R PWM Clamp":f1 +"Y PWM Clamp"[shape=record +label=" +<f0> Y PWM Clamp +|<f1> --\>Bounds in +|<f2> [Min=-20000.000] +|<f3> [Max=20000.000] +"] +"Yaw Rate PID" -> "Y PWM Clamp":f1 +"Pitch Clamp"[shape=record +label=" +<f0> Pitch Clamp +|<f1> --\>Bounds in +|<f2> [Min=-0.349] +|<f3> [Max=0.349] +"] +"Y pos PID" -> "Pitch Clamp":f1 +"Roll Clamp"[shape=record +label=" +<f0> Roll Clamp +|<f1> --\>Bounds in +|<f2> [Min=-0.349] +|<f3> [Max=0.349] +"] +"X pos PID PID" -> "Roll Clamp":f1 +"Pitch"[shape=record +label=" +<f0> Pitch +|<f1> [Constant=0.000] +"] +"Roll"[shape=record +label=" +<f0> Roll +|<f1> [Constant=0.000] +"] +"Yaw"[shape=record +label=" +<f0> Yaw +|<f1> [Constant=0.000] +"] +"dTheta"[shape=record +label=" +<f0> dTheta +|<f1> [Constant=0.000] +"] +"dPhi"[shape=record +label=" +<f0> dPhi +|<f1> [Constant=0.000] +"] +"dPsi"[shape=record +label=" +<f0> dPsi +|<f1> [Constant=0.000] +"] +"RC Pitch"[shape=record +label=" +<f0> RC Pitch +|<f1> [Constant=0.000] +"] +"RC Roll"[shape=record +label=" +<f0> RC Roll +|<f1> [Constant=0.000] +"] +"RC Yaw"[shape=record +label=" +<f0> RC Yaw +|<f1> [Constant=0.000] +"] +"RC Throttle"[shape=record +label=" +<f0> RC Throttle +|<f1> [Constant=0.000] +"] +"Signal Mixer"[shape=record +label=" +<f0> Signal Mixer +|<f1> --\>Throttle +|<f2> --\>Pitch +|<f3> --\>Roll +|<f4> --\>Yaw +"] +"RC Throttle" -> "Signal Mixer":f1 +"P PWM Clamp" -> "Signal Mixer":f2 +"R PWM Clamp" -> "Signal Mixer":f3 +"Y PWM Clamp" -> "Signal Mixer":f4 +"dT"[shape=record +label=" +<f0> dT +|<f1> [Constant=0.005] +"] +} \ No newline at end of file diff --git a/quad/sw/modular_quad_pid/gen_diagram/network.png b/quad/sw/modular_quad_pid/gen_diagram/network.png new file mode 100644 index 0000000000000000000000000000000000000000..b17a2837cfebf655d4aebc4dad810521c943b052 Binary files /dev/null and b/quad/sw/modular_quad_pid/gen_diagram/network.png differ diff --git a/quad/sw/modular_quad_pid/src/computation_graph.c b/quad/sw/modular_quad_pid/src/computation_graph.c index df690a41c9b95ed05623ea8b90e813e09e387026..c9f4c52019cf7cf8763b84aa9954a943f37ba2a1 120000 --- a/quad/sw/modular_quad_pid/src/computation_graph.c +++ b/quad/sw/modular_quad_pid/src/computation_graph.c @@ -1 +1 @@ -/local/ucart/MicroCART_17-18/quad/computation_graph/src/computation_graph.c \ No newline at end of file +../../../computation_graph/src/computation_graph.c \ No newline at end of file diff --git a/quad/sw/modular_quad_pid/src/computation_graph.h b/quad/sw/modular_quad_pid/src/computation_graph.h index aa22c46fb4337487b08179c2369006b41cff9be8..eb8fe7bfea6e123f35220c668690d99d290daa72 120000 --- a/quad/sw/modular_quad_pid/src/computation_graph.h +++ b/quad/sw/modular_quad_pid/src/computation_graph.h @@ -1 +1 @@ -/local/ucart/MicroCART_17-18/quad/computation_graph/src/computation_graph.h \ No newline at end of file +../../../computation_graph/src/computation_graph.h \ No newline at end of file diff --git a/quad/sw/modular_quad_pid/src/control_algorithm.c b/quad/sw/modular_quad_pid/src/control_algorithm.c index 8a37ad01ac28e90a7cf1101f374f37e22e63d0cc..d9d216b73825916b424044c4360f00fcea0bcceb 100644 --- a/quad/sw/modular_quad_pid/src/control_algorithm.c +++ b/quad/sw/modular_quad_pid/src/control_algorithm.c @@ -88,6 +88,10 @@ graph_set_source(graph, ps->yaw_pid, PID_DT, ps->dt, CONST_VAL); */ + // Connect angle clamping blocks + graph_set_source(graph, ps->clamp_pitch, BOUNDS_IN, ps->y_pos_pid, PID_CORRECTION); + graph_set_source(graph, ps->clamp_roll, BOUNDS_IN, ps->x_pos_pid, PID_CORRECTION); + // Connect PWM clamping blocks graph_set_source(graph, ps->clamp_d_pwmP, BOUNDS_IN, ps->pitch_r_pid, PID_CORRECTION); graph_set_source(graph, ps->clamp_d_pwmR, BOUNDS_IN, ps->roll_r_pid, PID_CORRECTION); diff --git a/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.c b/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.c index eb451afca21555a21a07e3345b2d1072c4e1059b..5091326ebef1cc7c79bc07820f2069960704809d 120000 --- a/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.c +++ b/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.c @@ -1 +1 @@ -/local/ucart/MicroCART_17-18/quad/computation_graph/src/graph_blocks/node_constant.c \ No newline at end of file +../../../../computation_graph/src/graph_blocks/node_constant.c \ No newline at end of file diff --git a/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.h b/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.h index a47be0f2022de91f37f9f1d5d33147d42fc9fb2d..d751234bdd8d5b88435e8c5f49c35bc15e55bbf0 120000 --- a/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.h +++ b/quad/sw/modular_quad_pid/src/graph_blocks/node_constant.h @@ -1 +1 @@ -/local/ucart/MicroCART_17-18/quad/computation_graph/src/graph_blocks/node_constant.h \ No newline at end of file +../../../../computation_graph/src/graph_blocks/node_constant.h \ No newline at end of file