scenario_simulator_v2 C++ API
Classes | Macros | Functions
test_longitudinal_speed_planner.cpp File Reference
#include <gtest/gtest.h>
#include <cmath>
#include <geometry_msgs/msg/accel.hpp>
#include <geometry_msgs/msg/twist.hpp>
#include <geometry_msgs/msg/vector3.hpp>
#include <traffic_simulator/behavior/longitudinal_speed_planning.hpp>
#include "../expect_eq_macros.hpp"
Include dependency graph for test_longitudinal_speed_planner.cpp:

Classes

class  LongitudinalSpeedPlannerTest
 

Macros

#define EXPECT_CONSTRAINTS_BOUNDED(DATA, lower, upper)
 

Functions

int main (int argc, char **argv)
 
auto makeTwistWithLinearX (double x) -> geometry_msgs::msg::Twist
 
auto makeAccelWithLinearX (double x) -> geometry_msgs::msg::Accel
 
 TEST_F (LongitudinalSpeedPlannerTest, isAccelerating_true)
 
 TEST_F (LongitudinalSpeedPlannerTest, isAccelerating_false)
 
 TEST_F (LongitudinalSpeedPlannerTest, isDecelerating_true)
 
 TEST_F (LongitudinalSpeedPlannerTest, isDecelerating_false)
 
 TEST_F (LongitudinalSpeedPlannerTest, getAccelerationDuration_acceleration)
 
 TEST_F (LongitudinalSpeedPlannerTest, getAccelerationDuration_targetSpeed_difference)
 
 TEST_F (LongitudinalSpeedPlannerTest, getDynamicStates_targetSpeedOverLimit)
 
 TEST_F (LongitudinalSpeedPlannerTest, getDynamicStates_maxJerk)
 
 TEST_F (LongitudinalSpeedPlannerTest, getDynamicStates_shortAccel)
 
 TEST_F (LongitudinalSpeedPlannerTest, isTargetSpeedReached_different)
 
 TEST_F (LongitudinalSpeedPlannerTest, isTargetSpeedReached_same)
 
 TEST_F (LongitudinalSpeedPlannerTest, getRunningDistance_shortTime)
 
 TEST_F (LongitudinalSpeedPlannerTest, getRunningDistance_longTime)
 
 TEST_F (LongitudinalSpeedPlannerTest, getRunningDistance_zero)
 

Macro Definition Documentation

◆ EXPECT_CONSTRAINTS_BOUNDED

#define EXPECT_CONSTRAINTS_BOUNDED (   DATA,
  lower,
  upper 
)
Value:
EXPECT_GE(DATA.max_speed, lower); \
EXPECT_GE(DATA.max_acceleration, lower); \
EXPECT_GE(DATA.max_deceleration, lower); \
EXPECT_GE(DATA.max_acceleration_rate, lower); \
EXPECT_GE(DATA.max_deceleration_rate, lower); \
EXPECT_LE(DATA.max_speed, upper); \
EXPECT_LE(DATA.max_acceleration, upper); \
EXPECT_LE(DATA.max_deceleration, upper); \
EXPECT_LE(DATA.max_acceleration_rate, upper); \
EXPECT_LE(DATA.max_deceleration_rate, upper);

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

◆ makeAccelWithLinearX()

auto makeAccelWithLinearX ( double  x) -> geometry_msgs::msg::Accel

◆ makeTwistWithLinearX()

auto makeTwistWithLinearX ( double  x) -> geometry_msgs::msg::Twist

◆ TEST_F() [1/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getAccelerationDuration_acceleration   
)
Note
Test calculations correctness of acceleration duration with some positive acceleration and speed substantially below target_speed.

Actual duration calculated by hand based on input. Tolerance value chosen as very small, but acceptable numerical error.

◆ TEST_F() [2/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getAccelerationDuration_targetSpeed_difference   
)
Note
Test calculations correctness when difference between getVelocityWithConstantJerk and target_speed is more than 0.01, https://github.com/tier4/scenario_simulator_v2/issues/1395

◆ TEST_F() [3/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getDynamicStates_maxJerk   
)
Note
Test functionality aggregation used in other classes. Test calculations correctness with target_speed = max speed and current speed = 0
  • goal is to test the situation when acceleration is so long that max jerk is reached.

◆ TEST_F() [4/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getDynamicStates_shortAccel   
)
Note
Test functionality aggregation used in other classes. Test calculations correctness with target_speed slightly smaller than current speed
  • goal is to test the situation when the max jerk is not reached because the target_speed is reached first.

◆ TEST_F() [5/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getDynamicStates_targetSpeedOverLimit   
)
Note
Test functionality aggregation used in other classes. Test function behavior when target_speed is bigger than max speed.

◆ TEST_F() [6/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getRunningDistance_longTime   
)
Note
Test functionality aggregation used in other classes. Test calculations correctness with target_speed = 0 and current speed = 50 (or other cruising speed)
  • goal is to test the situation when the target speed is reached takes longer to reach so the loop has to run multiple times.

◆ TEST_F() [7/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getRunningDistance_shortTime   
)
Note
Test functionality aggregation used in other classes. Test calculations correctness with target_speed slightly bigger than current speed
  • goal is to test the situation when the target speed is reached in little time, so the loop executes only several times.

◆ TEST_F() [8/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
getRunningDistance_zero   
)
Note
Test functionality aggregation used in other classes. Test calculations correctness with target_speed identical to current speed so that the time is 0.

◆ TEST_F() [9/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isAccelerating_false   
)
Note
Test basic functionality. Test with non accelerating situation.

◆ TEST_F() [10/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isAccelerating_true   
)
Note
Test basic functionality. Test with an accelerating situation.

◆ TEST_F() [11/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isDecelerating_false   
)
Note
Test basic functionality. Test with non decelerating situation.

◆ TEST_F() [12/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isDecelerating_true   
)
Note
Test basic functionality. Test with a decelerating situation.

◆ TEST_F() [13/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isTargetSpeedReached_different   
)
Note
Test functionality used in other classes. Test calculations correctness with target_speed differing from current speed by several units.

◆ TEST_F() [14/14]

TEST_F ( LongitudinalSpeedPlannerTest  ,
isTargetSpeedReached_same   
)
Note
Test functionality used in other classes. Test calculations correctness with target_speed differing from current speed by very small amount
  • goal is to simulate equal speed but with numerical noise.