mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-25 04:36:36 +08:00
PositionSmoothing: guard division by zero
Note that the unit test also passes without thechange. But the VelocitySmoothing's local_time would get NAN. This would leads to wrong trajectory calculations.
This commit is contained in:
@@ -2,6 +2,26 @@
|
||||
|
||||
#include <motion_planning/PositionSmoothing.hpp>
|
||||
|
||||
TEST(PositionSmoothingBasicTest, AllZeroCase)
|
||||
{
|
||||
PositionSmoothing position_smoothing;
|
||||
PositionSmoothing::PositionSmoothingSetpoints out;
|
||||
|
||||
position_smoothing.generateSetpoints(
|
||||
Vector3f(),
|
||||
{Vector3f(), Vector3f(), Vector3f()},
|
||||
Vector3f(),
|
||||
0.f,
|
||||
false,
|
||||
out
|
||||
);
|
||||
|
||||
EXPECT_EQ(out.jerk, Vector3f());
|
||||
EXPECT_EQ(out.acceleration, Vector3f());
|
||||
EXPECT_EQ(out.velocity, Vector3f());
|
||||
EXPECT_EQ(out.position, Vector3f());
|
||||
EXPECT_EQ(out.unsmoothed_velocity, Vector3f());
|
||||
}
|
||||
|
||||
static constexpr float MAX_JERK = 4.f;
|
||||
static constexpr float MAX_ACCELERATION = 3.f;
|
||||
|
||||
Reference in New Issue
Block a user