diff --git a/quad/Makefile b/quad/Makefile index d04ffe0e3d8af5a9842809be690f7ab85d30e134..01dfc58321c31b86e93d0d50386fba1eccc6ca45 100644 --- a/quad/Makefile +++ b/quad/Makefile @@ -24,6 +24,11 @@ bins: zybo: bash scripts/build_zybo.sh +# For creating an image of the control network. +gen_diagram: + $(MAKE) -C src/gen_diagram + bash src/gen_diagram/create_png.sh + boot: $(BOOT) test: diff --git a/quad/src/gen_diagram/Makefile b/quad/src/gen_diagram/Makefile index cf33639c89282e9d326a0120b4f0d47fbbb26827..302077f0c7aa1fe819be10487b269eb3f478fd8f 100644 --- a/quad/src/gen_diagram/Makefile +++ b/quad/src/gen_diagram/Makefile @@ -1,9 +1,6 @@ +TOP=../.. -QUAD_BLOCKS = ../src/graph_blocks +NAME = gen_diagram +REQLIBS = -lquad_app, -lgraph_blocks, -lcomputation_graph -gen_diagram: generate.c ../src/control_algorithm.c ../src/computation_graph.c - gcc -o gen_diagram -I. -I../src/ generate.c ../src/computation_graph.c ../src/control_algorithm.c ../src/graph_blocks/*.c -Dread_flap=freadflap -Dget_last_loop_time=fgettime - -.PHONY: clean -clean: - rm gen_diagram +include $(TOP)/library.mk \ No newline at end of file diff --git a/quad/src/gen_diagram/README.md b/quad/src/gen_diagram/README.md index 87b45825befd9e43f373eab8b973ba098e9cd147..3d2d7db362692e39303670476d120f22d51d6543 100644 --- a/quad/src/gen_diagram/README.md +++ b/quad/src/gen_diagram/README.md @@ -1,9 +1,4 @@ -The gen_diagram project can create an image of the controller network. Below outlines the process of how to use it. +The gen_diagram project can create an image of the controller network. -Within the `quad/sw/modular_quad_pid` directory: - -1. Within the `gen_diagram` folder, run `make` to build the new code. -2. Now execute the program with `./gen_diagram` -3. If you have graphviz installed, you can run `dot -Tpng network.dot -o network.png` to generate a PNG file of the graph. - -Enjoy your new diagram! +To make a new diagram, from the top-level quad directory, run "make gen_diagram". +The new network.png file show up in this folder. \ No newline at end of file diff --git a/quad/src/gen_diagram/create_png.sh b/quad/src/gen_diagram/create_png.sh index 3389781bf0d69d913c2b8d10e055ff2945bc3846..dae08313279d6dcc2c9f10d544f2308ace38d931 100755 --- a/quad/src/gen_diagram/create_png.sh +++ b/quad/src/gen_diagram/create_png.sh @@ -1,7 +1,4 @@ #/bin/bash -make -./gen_diagram - -dot -Tpng network.dot -o network.png +dot -Tpng "$(dirname $0)/network.dot" -o "$(dirname $0)/network.png" diff --git a/quad/src/gen_diagram/gen_diagram b/quad/src/gen_diagram/gen_diagram deleted file mode 100755 index 8413df5adf030804107bf812502da5249bf17b24..0000000000000000000000000000000000000000 Binary files a/quad/src/gen_diagram/gen_diagram and /dev/null differ diff --git a/quad/src/gen_diagram/generate.c b/quad/src/gen_diagram/generate.c index da5f3c3835bba723c55999d257a935ddf340aa6c..9b7b323729b2673330350513b2bec89a7142ac6e 100644 --- a/quad/src/gen_diagram/generate.c +++ b/quad/src/gen_diagram/generate.c @@ -1,21 +1,8 @@ #include <stdio.h> - -#include "computation_graph.h" -#include "node_pid.h" -#include "node_bounds.h" -#include "node_constant.h" -#include "node_mixer.h" -#include "PID.h" #include "control_algorithm.h" -#define ROLL_PITCH_MAX_ANGLE 0.3490 // 20 degrees -parameter_t ps; - -//int control_algorithm_init(parameter_t * ps); -int freadflap(int i) {return i;} -float fgettime() {return 0.0;} - int main() { + parameter_t ps; control_algorithm_init(&ps); FILE* dot_fp; dot_fp = fopen("network.dot", "w"); diff --git a/quad/src/gen_diagram/network.dot b/quad/src/gen_diagram/network.dot index 6c7ff17339d512cd4468ece1ac8c74a7e7b86183..bd697cf68bc407933c1fb0899382e20387b768ed 100644 --- a/quad/src/gen_diagram/network.dot +++ b/quad/src/gen_diagram/network.dot @@ -1,47 +1,47 @@ 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]"] -"VRPN Roll" -> "Roll PID":f1 [label="Constant"] -"Y pos PID" -> "Roll PID":f2 [label="Correction"] -"Ts_VRPN" -> "Roll PID":f3 [label="Constant"] +label="<f0>Roll PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=15.000] |<f5> [Ki=0.000] |<f6> [Kd=0.200] |<f7> [alpha=0.000]"] +"Roll" -> "Roll PID":f1 [label="Constant"] +"RC Roll" -> "Roll PID":f2 [label="Constant"] +"Ts_IMU" -> "Roll PID":f3 [label="Constant"] "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]"] -"VRPN Pitch" -> "Pitch PID":f1 [label="Constant"] -"X pos PID" -> "Pitch PID":f2 [label="Correction"] -"Ts_VRPN" -> "Pitch PID":f3 [label="Constant"] +label="<f0>Pitch PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=15.000] |<f5> [Ki=0.000] |<f6> [Kd=0.200] |<f7> [alpha=0.000]"] +"Pitch" -> "Pitch PID":f1 [label="Constant"] +"RC Pitch" -> "Pitch PID":f2 [label="Constant"] +"Ts_IMU" -> "Pitch PID":f3 [label="Constant"] "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]"] +label="<f0>Yaw PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=2.600] |<f5> [Ki=0.000] |<f6> [Kd=0.000] |<f7> [alpha=0.000]"] "Yaw" -> "Yaw PID":f1 [label="Constant"] "Yaw Setpoint" -> "Yaw PID":f2 [label="Constant"] "Ts_VRPN" -> "Yaw PID":f3 [label="Constant"] "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]"] +label="<f0>Roll Rate PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=4600.000] |<f5> [Ki=0.000] |<f6> [Kd=550.000] |<f7> [alpha=0.000]"] "dPhi" -> "Roll Rate PID":f1 [label="Constant"] "Roll PID" -> "Roll Rate PID":f2 [label="Correction"] "Ts_IMU" -> "Roll Rate PID":f3 [label="Constant"] "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]"] +label="<f0>Pitch Rate PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=4600.000] |<f5> [Ki=0.000] |<f6> [Kd=550.000] |<f7> [alpha=0.000]"] "dTheta" -> "Pitch Rate PID":f1 [label="Constant"] "Pitch PID" -> "Pitch Rate PID":f2 [label="Correction"] "Ts_IMU" -> "Pitch Rate PID":f3 [label="Constant"] "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]"] +label="<f0>Yaw Rate PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=435480.000] |<f5> [Ki=0.000] |<f6> [Kd=0.000] |<f7> [alpha=0.000]"] "dPsi" -> "Yaw Rate PID":f1 [label="Constant"] -"Yaw PID" -> "Yaw Rate PID":f2 [label="Correction"] +"RC Yaw" -> "Yaw Rate PID":f2 [label="Constant"] "Ts_IMU" -> "Yaw Rate PID":f3 [label="Constant"] "X pos PID"[shape=record -label="<f0>X pos PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=-0.015] |<f5> [Ki=-0.005] |<f6> [Kd=-0.030]"] +label="<f0>X pos PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=-0.015] |<f5> [Ki=-0.005] |<f6> [Kd=-0.030] |<f7> [alpha=0.000]"] "VRPN X" -> "X pos PID":f1 [label="Constant"] "X Setpoint" -> "X pos PID":f2 [label="Constant"] "Ts_VRPN" -> "X pos PID":f3 [label="Constant"] "Y pos PID"[shape=record -label="<f0>Y pos PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=0.015] |<f5> [Ki=0.005] |<f6> [Kd=0.030]"] +label="<f0>Y pos PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=0.015] |<f5> [Ki=0.005] |<f6> [Kd=0.030] |<f7> [alpha=0.000]"] "VRPN Y" -> "Y pos PID":f1 [label="Constant"] "Y Setpoint" -> "Y pos PID":f2 [label="Constant"] "Ts_VRPN" -> "Y pos PID":f3 [label="Constant"] "Altitude PID"[shape=record -label="<f0>Altitude PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=9804.000] |<f5> [Ki=817.000] |<f6> [Kd=7353.000]"] +label="<f0>Altitude PID |<f1> --\>Cur point |<f2> --\>Setpoint |<f3> --\>dt |<f4> [Kp=9804.000] |<f5> [Ki=817.000] |<f6> [Kd=7353.000] |<f7> [alpha=0.000]"] "VRPN Alt" -> "Altitude PID":f1 [label="Constant"] "Alt Setpoint" -> "Altitude PID":f2 [label="Constant"] "Ts_VRPN" -> "Altitude PID":f3 [label="Constant"] @@ -100,11 +100,12 @@ label="<f0>RC Yaw |<f1> [Constant=0.000]"] 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 [label="Constant"] "P PWM Clamp" -> "Signal Mixer":f2 [label="Bounded"] "R PWM Clamp" -> "Signal Mixer":f3 [label="Bounded"] "Y PWM Clamp" -> "Signal Mixer":f4 [label="Bounded"] "Ts_IMU"[shape=record -label="<f0>Ts_IMU |<f1> [Constant=0.000]"] +label="<f0>Ts_IMU |<f1> [Constant=0.005]"] "Ts_VRPN"[shape=record -label="<f0>Ts_VRPN |<f1> [Constant=0.000]"] +label="<f0>Ts_VRPN |<f1> [Constant=0.040]"] } \ No newline at end of file diff --git a/quad/src/gen_diagram/network.png b/quad/src/gen_diagram/network.png index 6734445acec05b986f97fb83855e62a39ee27463..3152aa2cf13de32d5cab578f0a029869757c325c 100644 Binary files a/quad/src/gen_diagram/network.png and b/quad/src/gen_diagram/network.png differ