Skip to content
Snippets Groups Projects
Commit bebbe835 authored by burneykb's avatar burneykb
Browse files

working with getpid.c

parent 69fe5f98
No related branches found
No related tags found
No related merge requests found
...@@ -16,10 +16,10 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -16,10 +16,10 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
{"roll", no_argument, &getRoll, 1}, {"roll", no_argument, &getRoll, 1},
{"pitch", no_argument, &getPitch, 1}, {"pitch", no_argument, &getPitch, 1},
{"yaw", no_argument, &getYaw, 1}, {"yaw", no_argument, &getYaw, 1},
{"rollv", no_argument, &getRollV, 1}, {"rollv", no_argument, &getYawV, 1},
{"pitchv", no_argument, &getPitchV, 1}, {"pitchv", no_argument, &getYawV, 1},
{"yawv", no_argument, &getYawV, 1}, {"yawv", no_argument, &getYawV, 1},
{"height", no_argument, &getHeight, 1}, {"height", no_argument, &getHeight, 1},
{"lat", no_argument, &getLat, 1}, {"lat", no_argument, &getLat, 1},
{"long", no_argument, &getLong, 1}, {"long", no_argument, &getLong, 1},
{"help", no_argument, &needHelp, 1}, {"help", no_argument, &needHelp, 1},
...@@ -64,11 +64,17 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -64,11 +64,17 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
int result; int result;
if(getAll) { if(getAll) {
for(int i = 0; i < PID_NUM_PIDS; ++i) { pid_data.controller = PID_ROLL;
pid_data.controller = i; if ((result = getValues(conn, &pid_data))) {
if ((result = getValues(conn, &pid_data))) { return result;
return result; }
} pid_data.controller = PID_PITCH;
if ((result = getValues(conn, &pid_data))) {
return result;
}
pid_data.controller = PID_YAW;
if ((result = getValues(conn, &pid_data))) {
return result;
} }
} else { } else {
if(getPitch) { if(getPitch) {
...@@ -89,43 +95,6 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -89,43 +95,6 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) {
return result; return result;
} }
} }
if(getPitchV) {
pid_data.controller = PID_PITCH_RATE;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getRollV) {
pid_data.controller = PID_ROLL_RATE;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getYawV) {
pid_data.controller = PID_YAW_RATE;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getHeight) {
pid_data.controller = PID_HEIGHT;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getLat) {
pid_data.controller = PID_LAT;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
if(getLong) {
pid_data.controller = PID_LONG;
if ((result = getValues(conn, &pid_data))) {
return result;
}
}
} }
return 0; return 0;
...@@ -136,6 +105,8 @@ int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) { ...@@ -136,6 +105,8 @@ int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) {
return 1; return 1;
} }
return 0;
switch(pid_data->controller) { switch(pid_data->controller) {
case PID_PITCH : case PID_PITCH :
printf("Pitch Constants: P = %f\tI = %f\tD = %f\n", printf("Pitch Constants: P = %f\tI = %f\tD = %f\n",
...@@ -149,30 +120,6 @@ int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) { ...@@ -149,30 +120,6 @@ int getValues(struct backend_conn * conn, struct frontend_pid_data * pid_data) {
printf("Yaw Constants: P = %f\tI = %f\tD = %f\n", printf("Yaw Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d); pid_data->p, pid_data->i, pid_data->d);
break; break;
case PID_PITCH_RATE :
printf("Pitch Rate Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case PID_ROLL_RATE :
printf("Roll Rate Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case PID_YAW_RATE :
printf("Yaw Rate Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case PID_HEIGHT :
printf("Height Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case PID_LAT :
printf("Latitude Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
case PID_LONG :
printf("Longitude Constants: P = %f\tI = %f\tD = %f\n",
pid_data->p, pid_data->i, pid_data->d);
break;
default : default :
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment