mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-19 19:04:33 +08:00
mc_pos_control: address @bresch's review comments
This commit is contained in:
@@ -66,7 +66,7 @@ TEST(ControlMathTest, ThrottleAttitudeMapping)
|
||||
* order is: 1. roll, 2. pitch, 3. yaw */
|
||||
thr = Vector3f(0.0f, 0.0f, 1.0f);
|
||||
att = thrustToAttitude(thr, yaw);
|
||||
EXPECT_NEAR(abs(att.roll_body), M_PI_F, 1e4f);
|
||||
EXPECT_NEAR(att.roll_body, -M_PI_F, 1e-4);
|
||||
EXPECT_EQ(att.pitch_body, 0);
|
||||
EXPECT_EQ(att.yaw_body, M_PI_2_F);
|
||||
EXPECT_EQ(att.thrust_body[2], -1.f);
|
||||
@@ -74,27 +74,25 @@ TEST(ControlMathTest, ThrottleAttitudeMapping)
|
||||
|
||||
TEST(ControlMathTest, ConstrainXYPriorities)
|
||||
{
|
||||
float max = 5.0f;
|
||||
const float max = 5.0f;
|
||||
// v0 already at max
|
||||
Vector2f v0(max, 0);
|
||||
Vector2f v1(v0(1), -v0(0));
|
||||
|
||||
Vector2f v_r = constrainXY(v0, v1, max);
|
||||
EXPECT_EQ(v_r(0), max);
|
||||
EXPECT_GT(v_r(0), 0);
|
||||
EXPECT_EQ(v_r(1), 0);
|
||||
|
||||
// v1 exceeds max but v0 is zero
|
||||
// norm of v1 exceeds max but v0 is zero
|
||||
v0.zero();
|
||||
v_r = constrainXY(v0, v1, max);
|
||||
EXPECT_EQ(v_r(1), -max);
|
||||
EXPECT_LT(v_r(1), 0);
|
||||
EXPECT_EQ(v_r(0), 0);
|
||||
|
||||
v0 = Vector2f(0.5f, 0.5f);
|
||||
v1 = Vector2f(0.5f, -0.5f);
|
||||
v_r = constrainXY(v0, v1, max);
|
||||
float diff = Vector2f(v_r - (v0 + v1)).length();
|
||||
const float diff = Vector2f(v_r - (v0 + v1)).length();
|
||||
EXPECT_EQ(diff, 0);
|
||||
|
||||
// v0 and v1 exceed max and are perpendicular
|
||||
@@ -103,7 +101,7 @@ TEST(ControlMathTest, ConstrainXYPriorities)
|
||||
v_r = constrainXY(v0, v1, max);
|
||||
EXPECT_EQ(v_r(0), v0(0));
|
||||
EXPECT_GT(v_r(0), 0);
|
||||
float remaining = sqrtf(max * max - (v0(0) * v0(0)));
|
||||
const float remaining = sqrtf(max * max - (v0(0) * v0(0)));
|
||||
EXPECT_EQ(v_r(1), -remaining);
|
||||
}
|
||||
|
||||
@@ -129,8 +127,8 @@ TEST(ControlMathTest, CrossSphereLine)
|
||||
*
|
||||
*
|
||||
* On trajectory --+----o----1----+--------2/3---+-- */
|
||||
Vector3f prev = Vector3f(0.0f, 0.0f, 0.0f);
|
||||
Vector3f curr = Vector3f(0.0f, 0.0f, 2.0f);
|
||||
const Vector3f prev = Vector3f(0.0f, 0.0f, 0.0f);
|
||||
const Vector3f curr = Vector3f(0.0f, 0.0f, 2.0f);
|
||||
Vector3f res;
|
||||
bool retval = false;
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_trajectory_waypoint.h>
|
||||
|
||||
#include "PositionControl.hpp"
|
||||
#include "PositionControl/ControlMath.hpp"
|
||||
#include <PositionControl.hpp>
|
||||
#include <ControlMath.hpp>
|
||||
#include "Takeoff.hpp"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
Reference in New Issue
Block a user