diff --git a/groundStation/src/cli/cli_setpid.h b/groundStation/src/cli/cli_setpid.h index 87fb0a4f40e91ed704972bd17e4859991d91641b..2ebdc9545e38f9f3d3697b02b22b8b1be2ef324e 100644 --- a/groundStation/src/cli/cli_setpid.h +++ b/groundStation/src/cli/cli_setpid.h @@ -1,5 +1,5 @@ -#ifndef _CLI_SETPID_H -#define _CLI_SETPID_H +#ifndef CLI_SETPID_H +#define CLI_SETPID_H #include "frontend_setpid.h" diff --git a/groundStation/src/cli/cli_setsetpoint.c b/groundStation/src/cli/cli_setsetpoint.c new file mode 100644 index 0000000000000000000000000000000000000000..f2ffcb15265361f58c01a25bab0007b6e9727f71 --- /dev/null +++ b/groundStation/src/cli/cli_setsetpoint.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <unistd.h> +#include <getopt.h> + +#include "cli_setsetpoint.h" +// #include "frontend_setpid.h" + +int cli_set(struct backend_conn * conn, int argc, char **argv) { + int c; + struct frontend_pid_data pid_data; + static int needHelp = 0; + static struct option long_options[] = { + /* These options don’t set a flag. We distinguish them by their indices. */ + {"help", no_argument, &needHelp, 1}, + {0, 0, 0, 0} + }; + + while (1) + { + /* getopt_long stores the option index here. */ + int option_index = 0; + + c = getopt_long(argc, argv, "", long_options, &option_index); + + /* Detect the end of the options. */ + if (c == -1) + break; + } + + if (needHelp) { + printf("Setsetpoint sets the x, y , or z set point values for the quad.\n"); + printf("Usage Syntax : \n\t./Cli setsetpoint [options...]\n"); + printf("Symlink Usage Syntax : \n\t./setsetpoint [options...]\n\n"); + printf("Available options include the following\n"); + printf("\t[-x] 'val' : Sets the x setpoint value to 'val'\n"); + printf("\t[-z] 'val' : Sets the y setpoint value to 'val'\n"); + printf("\t[-z] 'val' : Sets the z setpoint value to 'val'\n"); + return 0; + } + + if (argc < 2) { + printf("Incorrect Usage, run './cli setpid --help' for correct usage.\n"); + return 1; + } + + if (setRoll) { + pid_data.controller = PID_ROLL; + } else if (setYaw) { + pid_data.controller = PID_YAW; + } else if (setPitch) { + pid_data.controller = PID_PITCH; + } else if (setRollV) { + pid_data.controller = PID_ROLL_RATE; + } else if (setPitchV) { + pid_data.controller = PID_PITCH_RATE; + } else if (setYawV) { + pid_data.controller = PID_YAW_RATE; + } else if (setHeight) { + pid_data.controller = PID_HEIGHT; + } else if (setLong) { + pid_data.controller = PID_LAT; + } else if (setLat) { + pid_data.controller = PID_LONG; + } + + frontend_setpid(conn, &pid_data, mask); + return 0; +} diff --git a/groundStation/src/cli/cli_setsetpoint.h b/groundStation/src/cli/cli_setsetpoint.h new file mode 100644 index 0000000000000000000000000000000000000000..c379fdd9953c933947479cb197089a1abfa31b1e --- /dev/null +++ b/groundStation/src/cli/cli_setsetpoint.h @@ -0,0 +1,8 @@ +#ifndef CLI_SETSETPOINT_H +#define CLI_SETSETPOINT_H + +// #include "frontend_setpid.h" + +int cli_setsetpoint(struct backend_conn * conn, int argc, char ** argv); + +#endif