Skip to content

Commit

Permalink
invert controller output, update CAN message to uint8_t format
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Joe-Joe-Joe committed Jul 8, 2024
1 parent 781ecd8 commit 69f1c57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions STM32Cube/Tasks/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void controlTask(void *argument)
last_ms = millis_();
airbrakesController.last_error = airbrakesController.error;

float extension = airbrakesController.controller_term_P + airbrakesController.controller_term_I - airbrakesController.controller_term_D;
float output = airbrakesController.controller_term_P + airbrakesController.controller_term_I - airbrakesController.controller_term_D;
float extension = 1.0 - output; //invert the controller output

if(extension > CONTROLLER_MAX_EXTENSION) extension = CONTROLLER_MAX_EXTENSION;
if(extension < CONTROLLER_MIN_EXTENSION) extension = CONTROLLER_MIN_EXTENSION;
Expand All @@ -56,7 +57,7 @@ void controlTask(void *argument)
if(extensionAllowed())
{
can_msg_t msg;
build_actuator_cmd_analog( (uint32_t) millis_(), ACTUATOR_AIRBRAKES_SERVO, extension, &msg);
build_actuator_cmd_analog( (uint32_t) millis_(), ACTUATOR_AIRBRAKES_SERVO, (uint8_t) (100 * extension), &msg);
xQueueSend(busQueue, &msg, 5); //If we are in the coast phase, command the airbrakes servo to the target extension value
}
printf_("extension: %f", extension);
Expand Down

0 comments on commit 69f1c57

Please sign in to comment.