teb_basics.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
4 
5 TEST(TEBBasic, autoResizeLargeValueAtEnd)
6 {
7  double dt = 0.1;
8  double dt_hysteresis = dt/3.;
10 
11  teb.addPose(teb_local_planner::PoseSE2(0., 0., 0.));
12  for (int i = 1; i < 10; ++i) {
13  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(i * 1., 0., 0.), dt);
14  }
15  // add a pose with a large timediff as the last one
16  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(10., 0., 0.), dt + 2*dt_hysteresis);
17 
18  // auto resize + test of the result
19  teb.autoResize(dt, dt_hysteresis, 3, 100, false);
20  for (int i = 0; i < teb.sizeTimeDiffs(); ++i) {
21  ASSERT_LE(teb.TimeDiff(i), dt + dt_hysteresis + 1e-3) << "dt is greater than allowed: " << i;
22  ASSERT_LE(dt - dt_hysteresis - 1e-3, teb.TimeDiff(i)) << "dt is less than allowed: " << i;
23  }
24 }
25 
26 TEST(TEBBasic, autoResizeSmallValueAtEnd)
27 {
28  double dt = 0.1;
29  double dt_hysteresis = dt/3.;
31 
32  teb.addPose(teb_local_planner::PoseSE2(0., 0., 0.));
33  for (int i = 1; i < 10; ++i) {
34  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(i * 1., 0., 0.), dt);
35  }
36  // add a pose with a small timediff as the last one
37  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(10., 0., 0.), dt - 2*dt_hysteresis);
38 
39  // auto resize + test of the result
40  teb.autoResize(dt, dt_hysteresis, 3, 100, false);
41  for (int i = 0; i < teb.sizeTimeDiffs(); ++i) {
42  ASSERT_LE(teb.TimeDiff(i), dt + dt_hysteresis + 1e-3) << "dt is greater than allowed: " << i;
43  ASSERT_LE(dt - dt_hysteresis - 1e-3, teb.TimeDiff(i)) << "dt is less than allowed: " << i;
44  }
45 }
46 
47 TEST(TEBBasic, autoResize)
48 {
49  double dt = 0.1;
50  double dt_hysteresis = dt/3.;
52 
53  teb.addPose(teb_local_planner::PoseSE2(0., 0., 0.));
54  for (int i = 1; i < 10; ++i) {
55  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(i * 1., 0., 0.), dt);
56  }
57  // modify the timediff in the middle and add a pose with a smaller timediff as the last one
58  teb.TimeDiff(5) = dt + 2*dt_hysteresis;
59  teb.addPoseAndTimeDiff(teb_local_planner::PoseSE2(10., 0., 0.), dt - 2*dt_hysteresis);
60 
61  // auto resize
62  teb.autoResize(dt, dt_hysteresis, 3, 100, false);
63  for (int i = 0; i < teb.sizeTimeDiffs(); ++i) {
64  ASSERT_LE(teb.TimeDiff(i), dt + dt_hysteresis + 1e-3) << "dt is greater than allowed: " << i;
65  ASSERT_LE(dt - dt_hysteresis - 1e-3, teb.TimeDiff(i)) << "dt is less than allowed: " << i;
66  }
67 }
68 
69 int main(int argc, char** argv)
70 {
71  testing::InitGoogleTest(&argc, argv);
72  return RUN_ALL_TESTS();
73 }
Class that defines a trajectory modeled as an elastic band with augmented tempoarl information...
void addPoseAndTimeDiff(const PoseSE2 &pose, double dt)
Append a (pose, timediff) vertex pair to the end of the current trajectory (pose and timediff sequenc...
void addPose(const PoseSE2 &pose, bool fixed=false)
Append a new pose vertex to the back of the pose sequence.
int sizeTimeDiffs() const
Get the length of the internal timediff sequence.
double & TimeDiff(int index)
Access the time difference at pos index of the time sequence.
int main(int argc, char **argv)
Definition: teb_basics.cpp:69
TEST(TEBBasic, autoResizeLargeValueAtEnd)
Definition: teb_basics.cpp:5
This class implements a pose in the domain SE2: The pose consist of the position x and y and an orie...
Definition: pose_se2.h:57
void autoResize(double dt_ref, double dt_hysteresis, int min_samples=3, int max_samples=1000, bool fast_mode=false)
Resize the trajectory by removing or inserting a (pose,dt) pair depending on a reference temporal res...


teb_local_planner
Author(s): Christoph Rösmann
autogenerated on Wed Jun 3 2020 04:03:08