34 #include <gtest/gtest.h> 36 #include <px4_platform_common/defines.h> 42 TEST(ControlMathTest, ThrottleAttitudeMapping)
50 EXPECT_EQ(att.roll_body, 0);
51 EXPECT_EQ(att.pitch_body, 0);
52 EXPECT_EQ(att.yaw_body, 0);
53 EXPECT_EQ(att.thrust_body[2], -1.f);
59 EXPECT_EQ(att.roll_body, 0);
60 EXPECT_EQ(att.pitch_body, 0);
61 EXPECT_EQ(att.yaw_body, M_PI_2_F);
62 EXPECT_EQ(att.thrust_body[2], -1.f);
69 EXPECT_NEAR(att.roll_body, -
M_PI_F, 1e-4);
70 EXPECT_EQ(att.pitch_body, 0);
71 EXPECT_EQ(att.yaw_body, M_PI_2_F);
72 EXPECT_EQ(att.thrust_body[2], -1.f);
75 TEST(ControlMathTest, ConstrainXYPriorities)
77 const float max = 5.0f;
83 EXPECT_EQ(v_r(0), max);
89 EXPECT_EQ(v_r(1), -max);
95 const float diff =
Vector2f(v_r - (v0 + v1)).length();
102 EXPECT_EQ(v_r(0), v0(0));
103 EXPECT_GT(v_r(0), 0);
104 const float remaining = sqrtf(max * max - (v0(0) * v0(0)));
105 EXPECT_EQ(v_r(1), -remaining);
108 TEST(ControlMathTest, CrossSphereLine)
167 EXPECT_FALSE(retval);
172 EXPECT_FALSE(retval);
177 EXPECT_FALSE(retval);
bool cross_sphere_line(const Vector3f &sphere_c, const float sphere_r, const Vector3f &line_a, const Vector3f &line_b, Vector3f &res)
This method was used for smoothing the corners along two lines.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Vector2< float > Vector2f
void thrustToAttitude(const Vector3f &thr_sp, const float yaw_sp, vehicle_attitude_setpoint_s &att_sp)
Converts thrust vector and yaw set-point to a desired attitude.
Vector3< float > Vector3f
Vector2f constrainXY(const Vector2f &v0, const Vector2f &v1, const float &max)
Outputs the sum of two vectors but respecting the limits and priority.
Dual< Scalar, N > max(const Dual< Scalar, N > &a, const Dual< Scalar, N > &b)
TEST(ControlMathTest, ThrottleAttitudeMapping)
Simple functions for vector manipulation that do not fit into matrix lib.