Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the old HIL #8281

Merged
merged 1 commit into from Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/main/CMakeLists.txt
Expand Up @@ -302,8 +302,6 @@ main_sources(COMMON_SRC

flight/failsafe.c
flight/failsafe.h
flight/hil.c
flight/hil.h
flight/imu.c
flight/imu.h
flight/kalman.c
Expand Down
7 changes: 0 additions & 7 deletions src/main/fc/fc_core.c
Expand Up @@ -927,13 +927,6 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
// Calculate stabilisation
pidController(dT);

#ifdef HIL
if (hilActive) {
hilUpdateControlState();
motorControlEnable = false;
}
#endif

mixTable();

if (isMixerUsingServos()) {
Expand Down
10 changes: 0 additions & 10 deletions src/main/fc/fc_msp.c
Expand Up @@ -72,7 +72,6 @@

#include "flight/failsafe.h"
#include "flight/imu.h"
#include "flight/hil.h"
#include "flight/mixer.h"
#include "flight/pid.h"
#include "flight/servos.h"
Expand Down Expand Up @@ -398,15 +397,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteData(dst, shortGitRevision, GIT_SHORT_REVISION_LENGTH);
break;

#ifdef HIL
case MSP_HIL_STATE:
sbufWriteU16(dst, hilToSIM.pidCommand[ROLL]);
sbufWriteU16(dst, hilToSIM.pidCommand[PITCH]);
sbufWriteU16(dst, hilToSIM.pidCommand[YAW]);
sbufWriteU16(dst, hilToSIM.pidCommand[THROTTLE]);
break;
#endif

case MSP_SENSOR_STATUS:
sbufWriteU8(dst, isHardwareHealthy() ? 1 : 0);
sbufWriteU8(dst, getHwGyroStatus());
Expand Down
73 changes: 0 additions & 73 deletions src/main/flight/hil.c

This file was deleted.

42 changes: 0 additions & 42 deletions src/main/flight/hil.h

This file was deleted.

41 changes: 1 addition & 40 deletions src/main/flight/imu.c
Expand Up @@ -47,7 +47,6 @@ FILE_COMPILE_FOR_SPEED
#include "fc/runtime_config.h"
#include "fc/settings.h"

#include "flight/hil.h"
#include "flight/imu.h"
#include "flight/mixer.h"
#include "flight/pid.h"
Expand Down Expand Up @@ -194,7 +193,7 @@ void imuTransformVectorEarthToBody(fpVector3_t * v)
quaternionRotateVector(v, v, &orientation);
}

#if defined(USE_GPS) || defined(HIL)
#if defined(USE_GPS)
STATIC_UNIT_TESTED void imuComputeQuaternionFromRPY(int16_t initialRoll, int16_t initialPitch, int16_t initialYaw)
{
if (initialRoll > 1800) initialRoll -= 3600;
Expand Down Expand Up @@ -585,37 +584,12 @@ static void imuCalculateEstimatedAttitude(float dT)
imuUpdateEulerAngles();
}

#ifdef HIL
void imuHILUpdate(void)
{
/* Set attitude */
attitude.values.roll = hilToFC.rollAngle;
attitude.values.pitch = hilToFC.pitchAngle;
attitude.values.yaw = hilToFC.yawAngle;

/* Compute rotation quaternion for future use */
imuComputeQuaternionFromRPY(attitude.values.roll, attitude.values.pitch, attitude.values.yaw);

/* Fake accADC readings */
accADCf[X] = hilToFC.bodyAccel[X] / GRAVITY_CMSS;
accADCf[Y] = hilToFC.bodyAccel[Y] / GRAVITY_CMSS;
accADCf[Z] = hilToFC.bodyAccel[Z] / GRAVITY_CMSS;
}
#endif

void imuUpdateAccelerometer(void)
{
#ifdef HIL
if (sensors(SENSOR_ACC) && !hilActive) {
accUpdate();
isAccelUpdatedAtLeastOnce = true;
}
#else
if (sensors(SENSOR_ACC)) {
accUpdate();
isAccelUpdatedAtLeastOnce = true;
}
#endif
}

void imuCheckVibrationLevels(void)
Expand All @@ -640,23 +614,10 @@ void imuUpdateAttitude(timeUs_t currentTimeUs)
previousIMUUpdateTimeUs = currentTimeUs;

if (sensors(SENSOR_ACC) && isAccelUpdatedAtLeastOnce) {
#ifdef HIL
if (!hilActive) {
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
imuCheckVibrationLevels();
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
}
else {
imuHILUpdate();
imuUpdateMeasuredAcceleration();
}
#else
gyroGetMeasuredRotationRate(&imuMeasuredRotationBF); // Calculate gyro rate in body frame in rad/s
accGetMeasuredAcceleration(&imuMeasuredAccelBF); // Calculate accel in body frame in cm/s/s
imuCheckVibrationLevels();
imuCalculateEstimatedAttitude(dT); // Update attitude estimate
#endif
} else {
acc.accADCf[X] = 0.0f;
acc.accADCf[Y] = 0.0f;
Expand Down
8 changes: 0 additions & 8 deletions src/main/sensors/barometer.c
Expand Up @@ -50,8 +50,6 @@
#include "sensors/barometer.h"
#include "sensors/sensors.h"

#include "flight/hil.h"

#ifdef USE_HARDWARE_REVISION_DETECTION
#include "hardware_revision.h"
#endif
Expand Down Expand Up @@ -318,12 +316,6 @@ int32_t baroCalculateAltitude(void)
baro.BaroAlt = 0;
}
else {
#ifdef HIL
if (hilActive) {
baro.BaroAlt = hilToFC.baroAlt;
return baro.BaroAlt;
}
#endif
// calculates height from ground via baro readings
baro.BaroAlt = pressureToAltitude(baro.baroPressure) - baroGroundAltitude;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/target/ANYFC/target.h
Expand Up @@ -100,8 +100,6 @@
#define I2C_DEVICE_2_SHARES_UART3
//#define USE_I2C_PULLUP

//#define HIL

#define USE_ADC
#define ADC_CHANNEL_1_PIN PC0
#define ADC_CHANNEL_2_PIN PC1
Expand Down