Skip to content

Commit

Permalink
Adding a parameter to make tilt compensation configurable.
Browse files Browse the repository at this point in the history
This closes #106
  • Loading branch information
theseankelly committed May 22, 2016
1 parent 6a6b368 commit cadd553
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/modules/src/controller_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#include "position_controller.h"

#include "log.h"
#include "param.h"

#define ATTITUDE_RATE RATE_500_HZ
#define POSITION_RATE RATE_100_HZ

static bool tiltCompensationEnabled = true;

static attitude_t attitudeDesired;
static attitude_t rateDesired;
static float actuatorThrust;
Expand Down Expand Up @@ -83,7 +86,14 @@ void stateController(control_t *control, const sensorData_t *sensors,
control->yaw = -control->yaw;
}

control->thrust = actuatorThrust / sensfusion6GetInvThrustCompensationForTilt();
if (tiltCompensationEnabled)
{
control->thrust = actuatorThrust / sensfusion6GetInvThrustCompensationForTilt();
}
else
{
control->thrust = actuatorThrust;
}

if (control->thrust == 0)
{
Expand All @@ -106,3 +116,7 @@ LOG_ADD(LOG_FLOAT, roll, &attitudeDesired.roll)
LOG_ADD(LOG_FLOAT, pitch, &attitudeDesired.pitch)
LOG_ADD(LOG_FLOAT, yaw, &attitudeDesired.yaw)
LOG_GROUP_STOP(controller)

PARAM_GROUP_START(controller)
PARAM_ADD(PARAM_UINT8, tiltComp, &tiltCompensationEnabled)
PARAM_GROUP_STOP(controller)

0 comments on commit cadd553

Please sign in to comment.