diff --git a/groundStation/src/backend/commands.c b/groundStation/src/backend/commands.c index b88aebba678d28b8c62f0f5ddca142b959c6b1e5..b358118a29a51ee1b0cf34d4b8654f7169fa6246 100644 --- a/groundStation/src/backend/commands.c +++ b/groundStation/src/backend/commands.c @@ -57,9 +57,9 @@ command_cb cb_log __attribute__((weak, alias("cb_default"))); command_cb cb_response __attribute__((weak, alias("cb_default"))); /* Callbacks for configuration */ -command_cb cb_setcontrol __attribute__((weak, alias("cb_default"))); -command_cb cb_getcontrol __attribute__((weak, alias("cb_default"))); -command_cb cb_respcontrol __attribute__((weak, alias("cb_default"))); +command_cb cb_setparam __attribute__((weak, alias("cb_default"))); +command_cb cb_getparam __attribute__((weak, alias("cb_default"))); +command_cb cb_respparam __attribute__((weak, alias("cb_default"))); /* * Command structure. @@ -137,32 +137,32 @@ struct MessageType MessageTypes[MAX_TYPE_ID] = // Function pointer &cb_response }, - // SETCONTROL + // SETPARAM { // Command text - "setcontrol", + "setparam", // Type of the command data floatType, // Function pointer - &cb_setcontrol + &cb_setparam }, - // GETCONTROL + // GETPARAM { // Command text - "getcontrol", + "getparam", // Type of the command data floatType, // Function pointer - &cb_getcontrol + &cb_getparam }, - // RESPCONTROL + // RESPPARAM { // Command text - "respcontrol", + "respparam", // Type of the command data floatType, // Function pointer - &cb_respcontrol + &cb_respparam } }; diff --git a/groundStation/src/backend/commands.h b/groundStation/src/backend/commands.h index 094e3ac59c76e869c7d1420baa72d4279b5a1553..55584945c28662db1c7f35550795210a408e9350 100644 --- a/groundStation/src/backend/commands.h +++ b/groundStation/src/backend/commands.h @@ -41,9 +41,9 @@ enum MessageTypeID{ BEGINUPDATE_ID, // 04 LOG_ID, // 05 RESPONSE_ID, // 06 - SETCONTROL_ID, // 07 - Setting controller values. Example: PID constants - GETCONTROL_ID, // 08 - Getting controller values. Example: PID constants - RESPCONTROL_ID, // 09 - Responding with controller values. Example: PID constants + SETPARAM_ID, // 07 - Setting controller parameters. Example: PID constants + GETPARAM_ID, // 08 - Getting controller parameters. Example: PID constants + RESPPARAM_ID, // 09 - Responding with controller parameters. Example: PID constants MAX_TYPE_ID // 10 - Just used to keep track of the size }; @@ -64,14 +64,14 @@ enum ControllerID{ }; /* - * Enumeration of controller values + * Enumeration of controller parameters */ -enum ControllerValueID{ +enum ControlParamID{ KP_ID, // 00 - P constant KI_ID, // 01 - I constant KD_ID, // 02 - D constant SP_ID, // 03 - Setpoint value - MAX_CONTROL_VAL_ID, // 04 - Just used to keep track of the size + MAX_CONTROL_PARAM_ID, // 04 - Just used to keep track of the size }; /* diff --git a/quad/sw/modular_quad_pid/src/callbacks.c b/quad/sw/modular_quad_pid/src/callbacks.c index 0a166ca4fd27a9ebafdb5ecbbef20d963a6f72a2..8c6661dad66de3b07db273c85753b97ef34e36fd 100644 --- a/quad/sw/modular_quad_pid/src/callbacks.c +++ b/quad/sw/modular_quad_pid/src/callbacks.c @@ -93,50 +93,50 @@ int cb_beginupdate(modular_structs_t *structs) { /* Callbacks for configuration */ /** - * Handles a command to set a controller value on the quad. + * Handles a command to set a controller parameter on the quad. * * NOTE: * Expects the uart buff to have data in the following format: * |--------------------------------------------------------| * | data index || 0 | 1 | 2 - 5 | * |--------------------------------------------------------| - * | param || control ID | ctrl val ID | float val | + * | parameter || control ID | ctrl parmID | param val | * |--------------------------------------------------------| * | bytes || 1 | 1 | 4 | * |--------------------------------------------------------| * * Does not send anything in response. */ -int cb_setcontrol(modular_structs_t *structs) +int cb_setparam(modular_structs_t *structs) { // Get some of the meta data u16 data_len = uart_buff_get_u16(6); // Check if the data length is correct if (data_len == 6) { - // Get the controller ID, value ID, float value + // Get the controller ID, parameter ID, parameter value u8 controller_id = uart_buff_data_get_u8(0); - u8 controller_value_id = uart_buff_data_get_u8(1); - float controller_value = uart_buff_data_get_float(3); + u8 param_id = uart_buff_data_get_u8(1); + float param_val = uart_buff_data_get_float(3); // Check to make sure the IDs are in bounds if (controller_id < MAX_CONTROLLER_ID && - controller_value_id < MAX_CONTROL_VAL_ID) + param_id < MAX_CONTROL_PARAM_ID) { - // Set the controller_value into the controller by controller_id, controller_value_id - switch(controller_value_id) + // Set the param_val into the controller by controller_id, param_id + switch(param_id) { case KP_ID: - structs->parameter_struct.pid_controllers[controller_id].Kp = controller_value; + structs->parameter_struct.pid_controllers[controller_id].Kp = param_val; break; case KI_ID: - structs->parameter_struct.pid_controllers[controller_id].Ki = controller_value; + structs->parameter_struct.pid_controllers[controller_id].Ki = param_val; break; case KD_ID: - structs->parameter_struct.pid_controllers[controller_id].Kd = controller_value; + structs->parameter_struct.pid_controllers[controller_id].Kd = param_val; break; case SP_ID: - structs->parameter_struct.pid_controllers[controller_id].setpoint = controller_value; + structs->parameter_struct.pid_controllers[controller_id].setpoint = param_val; break; } } @@ -147,14 +147,14 @@ int cb_setcontrol(modular_structs_t *structs) } /** - * Handles a command to get a controller value from the quad. + * Handles a command to get a controller parameter from the quad. * * NOTE: * Expects the uart buff to have data in the following format: * |------------------------------------------| * | data index || 0 | 1 | * |------------------------------------------| - * | param || control ID | ctrl val ID | + * | parameter || control ID | ctrl parmID | * |------------------------------------------| * | bytes || 1 | 1 | * |------------------------------------------| @@ -165,12 +165,12 @@ int cb_setcontrol(modular_structs_t *structs) * |--------------------------------------------------------| * | data index || 0 | 1 | 2 - 5 | * |--------------------------------------------------------| - * | param || control ID | ctrl val ID | float val | + * | parameter || control ID | ctrl parmID | param val | * |--------------------------------------------------------| * | bytes || 1 | 1 | 4 | * |--------------------------------------------------------| */ -int cb_getcontrol(modular_structs_t* structs) +int cb_getparam(modular_structs_t* structs) { // Get some of the meta data u16 data_len = uart_buff_get_u16(6); @@ -178,31 +178,31 @@ int cb_getcontrol(modular_structs_t* structs) // Check if the data length is correct if (data_len == 2) { - // Get the controller ID, value ID + // Get the controller ID, parameter ID u8 controller_id = uart_buff_data_get_u8(0); - u8 controller_value_id = uart_buff_data_get_u8(1); + u8 param_id = uart_buff_data_get_u8(1); // Check to make sure the IDs are in bounds if (controller_id < MAX_CONTROLLER_ID && - controller_value_id < MAX_CONTROL_VAL_ID) + param_id < MAX_CONTROL_PARAM_ID) { // Make the variable to send - float controller_value; - // Set the controller_value equal to the controller value stored in the controller by - // controllerid, controller_value_id - switch(controller_value_id) + float param_val; + // Set the param_val equal to the parameter value stored in the controller by + // controller_id, param_id + switch(param_id) { case KP_ID: - controller_value = structs->parameter_struct.pid_controllers[controller_id].Kp; + param_val = structs->parameter_struct.pid_controllers[controller_id].Kp; break; case KI_ID: - controller_value = structs->parameter_struct.pid_controllers[controller_id].Ki; + param_val = structs->parameter_struct.pid_controllers[controller_id].Ki; break; case KD_ID: - controller_value = structs->parameter_struct.pid_controllers[controller_id].Kd; + param_val = structs->parameter_struct.pid_controllers[controller_id].Kd; break; case SP_ID: - controller_value = structs->parameter_struct.pid_controllers[controller_id].setpoint; + param_val = structs->parameter_struct.pid_controllers[controller_id].setpoint; break; } @@ -211,16 +211,15 @@ int cb_getcontrol(modular_structs_t* structs) // Controller ID resp_data[0] = controller_id; - // Controller value ID - resp_data[1] = controller_value_id; - // Controller value (4 byte float) + // Parameter ID + resp_data[1] = param_id; + // Parameter value (4 byte float) // TODO set a strict byte ordering for communication between the ground station and the quad - memcpy(&resp_data[2], &controller_value, sizeof(controller_value)); + memcpy(&resp_data[2], ¶m_val, sizeof(param_val)); - // Send the data - send_data(RESPCONTROL_ID, msg_id, resp_data, sizeof(resp_data)); + // Send the response + send_data(RESPPARAM_ID, msg_id, resp_data, sizeof(resp_data)); } - } return 0;