35 #include <gtest/gtest.h>
40 #define EPSILON 1.0e-10
42 TEST(ATrapTest, Test_SetProfile1)
89 TEST(ATrapTest, Test_SetProfile2)
128 TEST(ATrapTest, Test_SetProfile3)
163 TEST(ATrapTest, Test_SetProfile4)
196 TEST(ATrapTest, Test_SetProfileToLowDuration)
203 double fastest_duration = vp1.
Duration();
207 EXPECT_TRUE(vp1 == vp2) <<
"Not equal! Profile 1: \n" << vp1 <<
"\n Profile 2: " << vp2;
223 TEST(ATrapTest, Test_setProfileAllDurationsToLowDuration)
230 double fastest_duration = vp1.
Duration();
235 EXPECT_TRUE(vp1 == vp2) <<
"Not equal! Profile 1: \n" << vp1 <<
"\n Profile 2: " << vp2;
249 TEST(ATrapTest, Test_SetProfileZeroStartVelocity)
258 EXPECT_TRUE(vp1 == vp2) <<
"Not equal! Profile 1: \n" << vp1 <<
"\n Profile 2: " << vp2;
261 TEST(ATrapTest, Test_SetProfileDuration)
308 TEST(ATrapTest, Test_setProfileAllDurations1)
326 EXPECT_NEAR(vp.
Pos(2), 3.0 + 8.0 / 3.0,
EPSILON);
355 TEST(ATrapTest, Test_setProfileAllDurations2)
368 TEST(ATrapTest, Test_setProfileStartVelocity1)
405 TEST(ATrapTest, Test_setProfileStartVelocity2)
437 EXPECT_NEAR(vp.
Pos(2 + sqrt(1.0 / 3.0)), 5.0 - 1.0 / 3.0,
EPSILON);
438 EXPECT_NEAR(vp.
Vel(2 + sqrt(1.0 / 3.0)), -2 * sqrt(1.0 / 3.0),
EPSILON);
439 EXPECT_NEAR(vp.
Acc(2 + sqrt(1.0 / 3.0)), -2.0,
EPSILON);
441 EXPECT_NEAR(vp.
Pos(2 + 3 * sqrt(1.0 / 3.0) - 0.2), 4.02,
EPSILON);
442 EXPECT_NEAR(vp.
Vel(2 + 3 * sqrt(1.0 / 3.0) - 0.2), -0.2,
EPSILON);
443 EXPECT_NEAR(vp.
Acc(2 + 3 * sqrt(1.0 / 3.0) - 0.2), 1.0,
EPSILON);
445 EXPECT_NEAR(vp.
Pos(2 + 3 * sqrt(1.0 / 3.0)), 4.0,
EPSILON);
446 EXPECT_NEAR(vp.
Vel(2 + 3 * sqrt(1.0 / 3.0)), 0,
EPSILON);
447 EXPECT_NEAR(vp.
Acc(2 + 3 * sqrt(1.0 / 3.0)), 1.0,
EPSILON);
454 TEST(ATrapTest, Test_setProfileStartVelocity3)
495 TEST(ATrapTest, Test_setProfileStartVelocity4)
536 TEST(ATrapTest, Test_setProfileStartVelocity5)
581 TEST(ATrapTest, Test_setProfileStartVelocity6)
623 EXPECT_EQ(vp, *vp_clone);
627 int main(
int argc,
char** argv)
629 testing::InitGoogleTest(&argc, argv);
630 return RUN_ALL_TESTS();
A PTP Trajectory Generator of Asymmetric Trapezoidal Velocity Profile. Differences to VelocityProfile...
double Vel(double time) const override
Get velocity at given time.
double Pos(double time) const override
Get position at given time.
double thirdPhaseDuration() const
get the time of third phase
void SetProfile(double pos1, double pos2) override
compute the fastest profile Algorithm:
bool setProfileStartVelocity(double pos1, double pos2, double vel1)
Profile with start velocity Note: This function is not general and is currently only used for live co...
double Duration() const override
Duration.
double secondPhaseDuration() const
get the time of second phase
void SetProfileDuration(double pos1, double pos2, double duration) override
Profile scaled by the total duration.
KDL::VelocityProfile * Clone() const override
returns copy of current VelocityProfile object
bool setProfileAllDurations(double pos1, double pos2, double duration1, double duration2, double duration3)
Profile with given acceleration/constant/deceleration durations. Each duration must obey the maximal ...
double Acc(double time) const override
Get given acceleration/deceleration at given time.
double firstPhaseDuration() const
get the time of first phase
int main(int argc, char **argv)
TEST(ATrapTest, Test_SetProfile1)