From 4b7fd40967e862ddee0e571234b849d1ce2320e2 Mon Sep 17 00:00:00 2001 From: mdhsweden Date: Mon, 31 Oct 2016 18:30:09 +0100 Subject: [PATCH] Cast Ints to float in constrainf. What happens if we return an int on a function which returns a float? Just to be sure --- UAV-ControlSystem/src/Flight/pid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UAV-ControlSystem/src/Flight/pid.c b/UAV-ControlSystem/src/Flight/pid.c index 018181f..b7fee19 100644 --- a/UAV-ControlSystem/src/Flight/pid.c +++ b/UAV-ControlSystem/src/Flight/pid.c @@ -1,6 +1,6 @@ /************************************************************************** * NAME: pid.c * -* AUTHOR: Johan Gärtner * +* AUTHOR: Johan G�rtner * * * PURPOSE: This file contains pid functions * * INFORMATION: pidUAV is the final pid controller which only takes * @@ -114,9 +114,9 @@ float convertData(int inputRange, int outputRange, int offset, float value) float constrainf(float amt, int low, int high) { if (amt < low) - return low; + return (float)low; else if (amt > high) - return high; + return (float)high; else return amt; } @@ -469,7 +469,7 @@ void pidUAVInitBuff(pidProfileBuff_t *pidProfile, uint8_t ID) case PID_ID_GYRO: PidProfileBuff[ID].DOF = 3; - PidProfileBuff[ID].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //ÄNDRA TILL SEKUNDER inte ms + PidProfileBuff[ID].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //�NDRA TILL SEKUNDER inte ms break; case PID_ID_ACCELEROMETER: @@ -631,7 +631,7 @@ void pidEproom(void) PidProfile[PID_ID_ACCELEROMETER].PIDweight[PITCH] = 2; PidProfile[PID_ID_ACCELEROMETER].PIDweight[YAW] = 100; - PidProfileBuff[PID_ID_GYRO].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //ÄNDRA TILL SEKUNDER inte ms + PidProfileBuff[PID_ID_GYRO].dT = SystemTasks[TASK_GYROPID].desiredPeriod/1000000; //�NDRA TILL SEKUNDER inte ms PidProfileBuff[PID_ID_ACCELEROMETER].dT = SystemTasks[TASK_ACCELEROMETER].desiredPeriod/1000000; PidProfileBuff[PID_ID_COMPASS].dT = SystemTasks[TASK_COMPASS].desiredPeriod/1000000; PidProfileBuff[PID_ID_BAROMETER].dT = SystemTasks[TASK_BARO].desiredPeriod/1000000;