mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 01:05:21 +03:00
useless code removed
This commit is contained in:
parent
f4cdbb2d0a
commit
72b611ac5c
4 changed files with 2 additions and 21 deletions
|
@ -34,13 +34,9 @@
|
|||
#include "sensors/sonar.h"
|
||||
|
||||
// Sonar measurements are in cm, a value of SONAR_OUT_OF_RANGE indicates sonar is not in range.
|
||||
// Inclination is adjusted by imu
|
||||
float baro_cf_vel; // apply Complimentary Filter to keep the calculated velocity based on baro velocity (i.e. near real velocity)
|
||||
float baro_cf_alt; // apply CF to use ACC for height estimation
|
||||
|
||||
#ifdef SONAR
|
||||
int16_t sonarMaxRangeCm;
|
||||
int16_t sonarMaxAltWithTiltCm;
|
||||
|
||||
STATIC_UNIT_TESTED int16_t sonarMaxTiltDeciDegrees;
|
||||
float sonarMaxTiltCos;
|
||||
|
||||
|
@ -113,10 +109,8 @@ void sonarInit(const sonarHardware_t *sonarHardware)
|
|||
|
||||
hcsr04_init(sonarHardware, &sonarRange);
|
||||
sensorsSet(SENSOR_SONAR);
|
||||
sonarMaxRangeCm = sonarRange.maxRangeCm;
|
||||
sonarMaxTiltDeciDegrees = sonarRange.detectionConeExtendedDeciDegrees / 2;
|
||||
sonarMaxTiltCos = cos_approx(sonarMaxTiltDeciDegrees / 10.0f * RAD);
|
||||
sonarMaxAltWithTiltCm = sonarMaxRangeCm * sonarMaxTiltCos;
|
||||
calculatedAltitude = SONAR_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
|
@ -125,8 +119,6 @@ void sonarUpdate(void)
|
|||
hcsr04_start_reading();
|
||||
}
|
||||
|
||||
#define SONAR_SAMPLES_MEDIAN 3
|
||||
|
||||
/**
|
||||
* Get the last distance measured by the sonar in centimeters. When the ground is too far away, SONAR_OUT_OF_RANGE is returned.
|
||||
*/
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
|
||||
#define SONAR_OUT_OF_RANGE (-1)
|
||||
|
||||
extern int16_t sonarMaxRangeCm;
|
||||
extern int16_t sonarMaxAltWithTiltCm;
|
||||
|
||||
void sonarUpdate(void);
|
||||
int32_t sonarRead(void);
|
||||
int32_t sonarCalculateAltitude(int32_t sonarDistance, float cosTiltAngle);
|
||||
|
|
|
@ -143,7 +143,6 @@ uint8_t armingFlags;
|
|||
|
||||
int32_t sonarAlt;
|
||||
int16_t sonarCfAltCm;
|
||||
int16_t sonarMaxAltWithTiltCm;
|
||||
int32_t accADC[XYZ_AXIS_COUNT];
|
||||
int32_t gyroADC[XYZ_AXIS_COUNT];
|
||||
|
||||
|
|
|
@ -44,13 +44,9 @@ TEST(SonarUnittest, TestConstants)
|
|||
TEST(SonarUnittest, TestSonarInit)
|
||||
{
|
||||
sonarInit(0);
|
||||
EXPECT_EQ(sonarMaxRangeCm, HCSR04_MAX_RANGE_CM);
|
||||
// Check against gross errors in max range values
|
||||
EXPECT_GE(sonarMaxAltWithTiltCm, 100);
|
||||
EXPECT_LE(sonarMaxAltWithTiltCm, sonarMaxRangeCm);
|
||||
EXPECT_GE(sonarCfAltCm, 100);
|
||||
EXPECT_LE(sonarCfAltCm, sonarMaxRangeCm);
|
||||
EXPECT_LE(sonarCfAltCm, sonarMaxAltWithTiltCm);
|
||||
EXPECT_LE(sonarCfAltCm, HCSR04_MAX_RANGE_CM);
|
||||
// Check reasonable values for maximum tilt
|
||||
EXPECT_GE(sonarMaxTiltDeciDegrees, 0);
|
||||
EXPECT_LE(sonarMaxTiltDeciDegrees, 450);
|
||||
|
@ -102,9 +98,6 @@ TEST(SonarUnittest, TestAltitude)
|
|||
// distance 400, 22.4 degrees of roll, this corresponds to HC-SR04 effective max detection angle
|
||||
EXPECT_EQ(sonarCalculateAltitude(400, cosf(DECIDEGREES_TO_RADIANS(224))), 369);
|
||||
EXPECT_EQ(sonarGetLatestAltitude(), 369);
|
||||
// max range, max tilt
|
||||
EXPECT_EQ(sonarCalculateAltitude(sonarMaxRangeCm, cosf(DECIDEGREES_TO_RADIANS(sonarMaxTiltDeciDegrees))), sonarMaxAltWithTiltCm);
|
||||
EXPECT_EQ(sonarGetLatestAltitude(), sonarMaxAltWithTiltCm);
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue