Skip to content
Snippets Groups Projects
Unverified Commit 0975fc8c authored by Jake Drahos's avatar Jake Drahos
Browse files

Merge branch 'update-commands' into temp-master

parents e6ab8f52 c3434452
No related branches found
No related tags found
No related merge requests found
...@@ -44,29 +44,29 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -44,29 +44,29 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Message Type ID // Message Type ID
0x01, 0x01,
// Calibration Subtypes // Calibration Subtypes (PID coefficients)
{ {
// yaw setpoint subtype // yaw p constant subtype
{ {
// ID // ID
0x00, 0x00,
// Command text // Command text
"setyaw", "setyawp",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setyaw NULL
}, },
// yaw p constant subtype // yaw i constant subtype
{ {
// ID // ID
0x01, 0x01,
// Command text // Command text
"setyawp", "setyawi",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setyawp NULL
}, },
// yaw d constant subtype // yaw d constant subtype
{ {
...@@ -77,29 +77,29 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -77,29 +77,29 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setyawd NULL
}, },
// roll setpoint subtype // roll p constant subtype
{ {
// ID // ID
0x03, 0x03,
// Command text // Command text
"setroll", "setrollp",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setroll NULL
}, },
// roll p constant subtype // roll i constant subtype
{ {
// ID // ID
0x04, 0x04,
// Command text // Command text
"setrollp", "setrolli",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setrollp NULL
}, },
// roll d constant subtype // roll d constant subtype
{ {
...@@ -110,29 +110,29 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -110,29 +110,29 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setrolld NULL
}, },
// pitch setpoint subtype // pitch p constant subtype
{ {
// ID // ID
0x06, 0x06,
// Command text // Command text
"setpitch", "setpitchp",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setpitch NULL
}, },
// pitch p constant subtype // pitch i constant subtype
{ {
// ID // ID
0x07, 0x07,
// Command text // Command text
"setpitchp", "setpitchi",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setpitchp NULL
}, },
// pitch d constant subtype // pitch d constant subtype
{ {
...@@ -143,51 +143,205 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -143,51 +143,205 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setpitchd NULL
}, },
// throttle setpoint subtype // yawrate p constant subtype
{ {
// ID // ID
0x09, 0x09,
// Command text // Command text
"setthrottle", "setyawratep",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setthrottle NULL
}, },
// throttle p constant subtype // yawrate i constant subtype
{ {
// ID // ID
0x0A, 0x0A,
// Command text // Command text
"setthrottlep", "setyawratei",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setthrottlep NULL
}, },
// throttle i constant subtype // yawrate d constant subtype
{ {
// ID // ID
0x0B, 0x0B,
// Command text // Command text
"setthrottlei", "setyawrated",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&setthrottlei NULL
}, },
// throttle d constant subtype // rollrate p constant subtype
{ {
// ID // ID
0x0C, 0x0C,
// Command text // Command text
"setthrottled", "setrollratep",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&getthrottled NULL
},
// rollrate i constant subtype
{
// ID
0x0D,
// Command text
"setrollratei",
// Type of the command data
floatType,
// Function pointer
NULL
},
// rollrate d constant subtype
{
// ID
0x0E,
// Command text
"setrollrated",
// Type of the command data
floatType,
// Function pointer
NULL
},
// pitchrate p constant subtype
{
// ID
0x0F,
// Command text
"setpitchratep",
// Type of the command data
floatType,
// Function pointer
NULL
},
// pitchrate i constant subtype
{
// ID
0x10,
// Command text
"setpitchratei",
// Type of the command data
floatType,
// Function pointer
NULL
},
// pitchrate d constant subtype
{
// ID
0x11,
// Command text
"setpitchrated",
// Type of the command data
floatType,
// Function pointer
NULL
},
// height p constant subtype
{
// ID
0x12,
// Command text
"setheightp",
// Type of the command data
floatType,
// Function pointer
NULL
},
// height i constant subtype
{
// ID
0x13,
// Command text
"setheighti",
// Type of the command data
floatType,
// Function pointer
NULL
},
// height d constant subtype
{
// ID
0x14,
// Command text
"setheightd",
// Type of the command data
floatType,
// Function pointer
NULL
},
// lat p constant subtype
{
// ID
0x15,
// Command text
"setlatp",
// Type of the command data
floatType,
// Function pointer
NULL
},
// lat i constant subtype
{
// ID
0x16,
// Command text
"setlati",
// Type of the command data
floatType,
// Function pointer
NULL
},
// lat d constant subtype
{
// ID
0x17,
// Command text
"setlatd",
// Type of the command data
floatType,
// Function pointer
NULL
},
// long p constant subtype
{
// ID
0x18,
// Command text
"setlongp",
// Type of the command data
floatType,
// Function pointer
NULL
},
// long i constant subtype
{
// ID
0x19,
// Command text
"setlongi",
// Type of the command data
floatType,
// Function pointer
NULL
},
// long d constant subtype
{
// ID
0x1A,
// Command text
"setlongd",
// Type of the command data
floatType,
// Function pointer
NULL
} }
} }
}, },
...@@ -993,4 +1147,4 @@ int respthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs ...@@ -993,4 +1147,4 @@ int respthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs
} }
int respthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs){ int respthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0; return 0;
} }
\ No newline at end of file
...@@ -256,12 +256,16 @@ int processCommand(unsigned char *packet, modular_structs_t *structs) { ...@@ -256,12 +256,16 @@ int processCommand(unsigned char *packet, modular_structs_t *structs) {
} }
if(metadata.data_len >= 0) { if(metadata.data_len >= 0) {
// Call the appropriate subtype function /* Null check*/
(* (MessageTypes[(unsigned char)metadata.msg_type].subtypes[(unsigned char)metadata.msg_subtype].functionPtr))(data, metadata.data_len, structs); if (MessageTypes[(unsigned char)metadata.msg_type].subtypes[
(unsigned char) metadata.msg_subtype].functionPtr) {
// Call the appropriate subtype function
(* (MessageTypes[(unsigned char)metadata.msg_type].subtypes[(unsigned char)metadata.msg_subtype].functionPtr))(data, metadata.data_len, structs);
}
return 0; return 0;
} }
// Only gets here if there is an error // Only gets here if there is an error
return -1; return -1;
} }
\ No newline at end of file
...@@ -63,19 +63,19 @@ int cli_setpid(struct backend_conn * conn, int argc, char **argv) { ...@@ -63,19 +63,19 @@ int cli_setpid(struct backend_conn * conn, int argc, char **argv) {
} else if (setPitch) { } else if (setPitch) {
pid_data.controller = PID_PITCH; pid_data.controller = PID_PITCH;
} else if (setRollV) { } else if (setRollV) {
pid_data.controller = PID_ROLL_VELOCITY; pid_data.controller = PID_ROLL_RATE;
} else if (setPitchV) { } else if (setPitchV) {
pid_data.controller = PID_PITCH_VELOCITY; pid_data.controller = PID_PITCH_RATE;
} else if (setYawV) { } else if (setYawV) {
pid_data.controller = PID_YAW_VELOCITY; pid_data.controller = PID_YAW_RATE;
} else if (setHeight) { } else if (setHeight) {
pid_data.controller = PID_HEIGHT; pid_data.controller = PID_HEIGHT;
} else if (setLong) { } else if (setLong) {
pid_data.controller = PID_LONG;
} else if (setLat) {
pid_data.controller = PID_LAT; pid_data.controller = PID_LAT;
} else if (setLat) {
pid_data.controller = PID_LONG;
} }
frontend_setpid(conn, &pid_data, mask); frontend_setpid(conn, &pid_data, mask);
return 0; return 0;
} }
\ No newline at end of file
...@@ -25,7 +25,24 @@ int frontend_setpid( ...@@ -25,7 +25,24 @@ int frontend_setpid(
case PID_YAW: case PID_YAW:
controller = "yaw"; controller = "yaw";
break; break;
/* What is the "throttle" pid constant? */ case PID_PITCH_RATE:
controller = "pitchrate";
break;
case PID_ROLL_RATE:
controller = "rollrate";
break;
case PID_YAW_RATE:
controller = "yawrate";
break;
case PID_HEIGHT:
controller = "height";
break;
case PID_LAT:
controller = "lat";
break;
case PID_LONG:
controller = "long";
break;
default: default:
warnx("Unsupported PID constant"); warnx("Unsupported PID constant");
return -1; return -1;
......
...@@ -5,9 +5,9 @@ enum pid_controller { ...@@ -5,9 +5,9 @@ enum pid_controller {
PID_PITCH, PID_PITCH,
PID_ROLL, PID_ROLL,
PID_YAW, PID_YAW,
PID_PITCH_VELOCITY, PID_PITCH_RATE,
PID_ROLL_VELOCITY, PID_ROLL_RATE,
PID_YAW_VELOCITY, PID_YAW_RATE,
PID_HEIGHT, /* Z */ PID_HEIGHT, /* Z */
PID_LAT, /* X */ PID_LAT, /* X */
PID_LONG, /* Y */ PID_LONG, /* Y */
......
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