1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Add tests for the calculateHeading method of the IMU.

This commit is contained in:
Pierre Hugo 2015-01-23 23:27:53 -08:00
parent f312636b9f
commit 6a0d1b84f2

View file

@ -24,6 +24,7 @@
extern "C" {
#include "common/axis.h"
#include "common/maths.h"
#include "flight/flight.h"
#include "sensors/sensors.h"
@ -48,10 +49,23 @@ extern "C" {
#define UPWARDS_THRUST false
TEST(FlightImuTest, Placeholder)
TEST(FlightImuTest, TestCalculateHeading)
{
// TODO test things
EXPECT_EQ(true, true);
//TODO: Add test cases using the Z dimension.
t_fp_vector north = {.A={1.0f, 0.0f, 0.0f}};
EXPECT_EQ(calculateHeading(&north), 0);
t_fp_vector east = {.A={0.0f, 1.0f, 0.0f}};
EXPECT_EQ(calculateHeading(&east), 90);
t_fp_vector south = {.A={-1.0f, 0.0f, 0.0f}};
EXPECT_EQ(calculateHeading(&south), 180);
t_fp_vector west = {.A={0.0f, -1.0f, 0.0f}};
EXPECT_EQ(calculateHeading(&west), 270);
t_fp_vector north_east = {.A={1.0f, 1.0f, 0.0f}};
EXPECT_EQ(calculateHeading(&north_east), 45);
}
// STUBS