@@ -67,6 +67,13 @@ static const char RIGHT_POLYGON_STR[]{
6767static const bool IS_HOLONOMIC{true };
6868static const bool IS_NOT_HOLONOMIC{false };
6969static const int MIN_POINTS{2 };
70+ static const double SLOWDOWN_RATIO{0.25 };
71+ static const double LINEAR_LIMIT{0.3 };
72+ static const double ANGULAR_LIMIT{0.2 };
73+ static const double TIME_BEFORE_COLLISION{2.0 };
74+ static const double SIMULATION_TIME_STEP{0.05 };
75+ static const double MIN_VEL_BEFORE_COLLISION{-0.5 };
76+
7077static const tf2::Duration TRANSFORM_TOLERANCE{tf2::durationFromSec (0.1 )};
7178
7279class TestNode : public nav2_util ::LifecycleNode
@@ -145,6 +152,10 @@ class Tester : public ::testing::Test
145152protected:
146153 // Working with parameters
147154 void setCommonParameters (const std::string & polygon_name, const std::string & action_type);
155+ void addSlowdownParameters (const std::string & polygon_name);
156+ void addLimitParameters (const std::string & polygon_name);
157+ void addApproachParameters (const std::string & polygon_name);
158+
148159 void setVelocityPolygonParameters (const bool is_holonomic);
149160 void addPolygonVelocitySubPolygon (
150161 const std::string & sub_polygon_name,
@@ -211,6 +222,39 @@ void Tester::setCommonParameters(const std::string & polygon_name, const std::st
211222 rclcpp::Parameter (polygon_name + " .polygon_pub_topic" , POLYGON_PUB_TOPIC));
212223}
213224
225+ void Tester::addSlowdownParameters (const std::string & polygon_name)
226+ {
227+ test_node_->set_parameter (
228+ rclcpp::Parameter (std::string (POLYGON_NAME) + " ." + polygon_name + " .slowdown_ratio" , SLOWDOWN_RATIO));
229+ }
230+
231+ void Tester::addLimitParameters (const std::string & polygon_name)
232+ {
233+ test_node_->set_parameter (
234+ rclcpp::Parameter (std::string (POLYGON_NAME) + " ." + polygon_name + " .linear_limit" , LINEAR_LIMIT));
235+
236+ test_node_->set_parameter (
237+ rclcpp::Parameter (std::string (POLYGON_NAME) + " ." + polygon_name + " .angular_limit" , ANGULAR_LIMIT));
238+ }
239+
240+ void Tester::addApproachParameters (const std::string & polygon_name)
241+ {
242+ test_node_->set_parameter (
243+ rclcpp::Parameter (
244+ std::string (
245+ POLYGON_NAME) + " ." + polygon_name + " .time_before_collision" , TIME_BEFORE_COLLISION));
246+
247+ test_node_->set_parameter (
248+ rclcpp::Parameter (
249+ std::string (POLYGON_NAME) + " ." + polygon_name + " .simulation_time_step" ,
250+ SIMULATION_TIME_STEP));
251+
252+ test_node_->set_parameter (
253+ rclcpp::Parameter (
254+ std::string (POLYGON_NAME) + " ." + polygon_name + " .min_vel_before_stop" ,
255+ MIN_VEL_BEFORE_COLLISION));
256+ }
257+
214258void Tester::setVelocityPolygonParameters (const bool is_holonomic)
215259{
216260 test_node_->declare_parameter (
@@ -270,6 +314,7 @@ void Tester::setVelocityPolygonParameters(const bool is_holonomic)
270314 rclcpp::Parameter (std::string (POLYGON_NAME) + " .velocity_polygons" , velocity_polygons));
271315}
272316
317+
273318void Tester::addPolygonVelocitySubPolygon (
274319 const std::string & sub_polygon_name,
275320 const double linear_min, const double linear_max,
@@ -560,6 +605,35 @@ TEST_F(Tester, testVelocityPolygonHolonomicVelocitySwitching)
560605 EXPECT_NEAR (poly[3 ].y , RIGHT_POLYGON[7 ], EPSILON);
561606}
562607
608+ // TEST_F(Tester, testVelocityPolygonSlowdownParameters)
609+ // {
610+ // createVelocityPolygon("slowdown", IS_NOT_HOLONOMIC);
611+ // addSlowdownParameters(SUB_POLYGON_FORWARD_NAME);
612+
613+ // EXPECT_EQ(velocity_polygon_->getActionType(), nav2_collision_monitor::SLOWDOWN);
614+ // EXPECT_NEAR(velocity_polygon_->getSlowdownRatio(), 0.25, EPSILON);
615+ // }
616+
617+ // TEST_F(Tester, testVelocityPolygonLimitParameters)
618+ // {
619+ // createVelocityPolygon("limit", IS_NOT_HOLONOMIC);
620+ // addLimitParameters(SUB_POLYGON_FORWARD_NAME);
621+
622+ // EXPECT_EQ(velocity_polygon_->getActionType(), nav2_collision_monitor::LIMIT);
623+ // EXPECT_NEAR(velocity_polygon_->getLinearLimit(), 0.3, EPSILON);
624+ // EXPECT_NEAR(velocity_polygon_->getAngularLimit(), 0.2, EPSILON);
625+ // }
626+
627+ // TEST_F(Tester, testVelocityPolygonApproachParameters)
628+ // {
629+ // createVelocityPolygon("approach", IS_NOT_HOLONOMIC);
630+ // addApproachParameters(SUB_POLYGON_FORWARD_NAME);
631+
632+ // EXPECT_EQ(velocity_polygon_->getActionType(), nav2_collision_monitor::APPROACH);
633+ // EXPECT_NEAR(velocity_polygon_->getTimeBeforeCollision(), 2.0, EPSILON);
634+ // EXPECT_NEAR(velocity_polygon_->getSimulationTimeStep(), 0.05, EPSILON);
635+ // EXPECT_NEAR(velocity_polygon_->getMinVelBeforeStop(), -0.5, EPSILON);
636+ // }
563637
564638int main (int argc, char ** argv)
565639{
0 commit comments