Skip to content

Commit b48ac7d

Browse files
committed
refactor: change style of polygon names and observation_sources names
Signed-off-by: AJedancov <andrei.jedancov@gmail.com>
1 parent 316690f commit b48ac7d

17 files changed

Lines changed: 170 additions & 170 deletions

nav2_bringup/params/nav2_params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ collision_monitor:
508508
stop_pub_timeout: 2.0
509509
# Polygons represent zone around the robot for "stop", "slowdown" and "limit" action types,
510510
# and robot footprint for "approach" action type.
511-
polygons: ["FootprintApproach"]
512-
FootprintApproach:
511+
polygons: ["footprint_approach"]
512+
footprint_approach:
513513
type: "polygon"
514514
action_type: "approach"
515515
footprint_topic: "local_costmap/published_footprint"

nav2_collision_monitor/params/collision_detector_params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ collision_detector:
66
transform_tolerance: 0.5
77
source_timeout: 5.0
88
base_shift_correction: true
9-
polygons: ["PolygonFront"]
10-
PolygonFront:
9+
polygons: ["polygon_front"]
10+
polygon_front:
1111
type: "polygon"
1212
points: "[[0.3, 0.3], [0.3, -0.3], [0.0, -0.3], [0.0, 0.3]]"
1313
action_type: "none"

nav2_collision_monitor/params/collision_monitor_params.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ collision_monitor:
1616
# (2) "circle" type with static footprint set by radius. "footprint_topic" parameter
1717
# to be ignored in circular case.
1818
# (3) "velocity_polygon" type with dynamically set polygon from velocity_polygons
19-
polygons: ["PolygonStop"]
20-
PolygonStop:
19+
polygons: ["polygon_stop"]
20+
polygon_stop:
2121
type: "polygon"
2222
points: "[[0.3, 0.3], [0.3, -0.3], [0.0, -0.3], [0.0, 0.3]]"
2323
action_type: "stop"
2424
min_points: 4
2525
visualize: true
2626
polygon_pub_topic: "polygon_stop"
2727
enabled: true
28-
PolygonSlow:
28+
polygon_slow:
2929
type: "polygon"
3030
points: "[[0.4, 0.4], [0.4, -0.4], [-0.4, -0.4], [-0.4, 0.4]]"
3131
action_type: "slowdown"
@@ -34,7 +34,7 @@ collision_monitor:
3434
visualize: true
3535
polygon_pub_topic: "polygon_slowdown"
3636
enabled: true
37-
PolygonLimit:
37+
polygon_limit:
3838
type: "polygon"
3939
points: "[[0.5, 0.5], [0.5, -0.5], [-0.5, -0.5], [-0.5, 0.5]]"
4040
action_type: "limit"
@@ -44,7 +44,7 @@ collision_monitor:
4444
visualize: true
4545
polygon_pub_topic: "polygon_limit"
4646
enabled: true
47-
FootprintApproach:
47+
footprint_approach:
4848
type: "polygon"
4949
action_type: "approach"
5050
footprint_topic: "/local_costmap/published_footprint"
@@ -53,7 +53,7 @@ collision_monitor:
5353
min_points: 6
5454
visualize: false
5555
enabled: true
56-
VelocityPolygonStop:
56+
velocity_polygon_stop:
5757
type: "velocity_polygon"
5858
action_type: "stop"
5959
min_points: 6

nav2_collision_monitor/src/collision_monitor_node.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void CollisionMonitor::process(const Velocity & cmd_vel_in, const std_msgs::msg:
432432
source->getSourceTimeout().seconds() != 0.0)
433433
{
434434
action_polygon = nullptr;
435-
robot_action.polygon_name = "invalid source";
435+
robot_action.polygon_name = "invalid_source";
436436
robot_action.action_type = STOP;
437437
robot_action.req_vel.x = 0.0;
438438
robot_action.req_vel.y = 0.0;
@@ -606,7 +606,7 @@ void CollisionMonitor::notifyActionState(
606606
const Action & robot_action, const std::shared_ptr<Polygon> action_polygon) const
607607
{
608608
if (robot_action.action_type == STOP) {
609-
if (robot_action.polygon_name == "invalid source") {
609+
if (robot_action.polygon_name == "invalid_source") {
610610
RCLCPP_WARN(
611611
get_logger(),
612612
"Robot to stop due to invalid source."

nav2_collision_monitor/test/collision_detector_node_test.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ static constexpr double EPSILON = 1e-5;
4848
static const char BASE_FRAME_ID[]{"base_link"};
4949
static const char SOURCE_FRAME_ID[]{"base_source"};
5050
static const char ODOM_FRAME_ID[]{"odom"};
51-
static const char SCAN_NAME[]{"Scan"};
52-
static const char POINTCLOUD_NAME[]{"PointCloud"};
53-
static const char RANGE_NAME[]{"Range"};
54-
static const char POLYGON_NAME[]{"Polygon"};
55-
static const char COSTMAP_NAME[]{"Costmap"};
51+
static const char SCAN_NAME[]{"scan"};
52+
static const char POINTCLOUD_NAME[]{"pointcloud"};
53+
static const char RANGE_NAME[]{"range"};
54+
static const char POLYGON_NAME[]{"polygon"};
55+
static const char COSTMAP_NAME[]{"costmap"};
5656
static const char STATE_TOPIC[]{"collision_detector_state"};
5757
static const char COLLISION_POINTS_MARKERS_TOPIC[]{"/collision_detector/collision_points_marker"};
5858
static const int MIN_POINTS{1};
@@ -559,9 +559,9 @@ bool Tester::waitData(
559559
TEST_F(Tester, testIncorrectPolygonType)
560560
{
561561
setCommonParameters();
562-
addPolygon("UnknownShape", POLYGON_UNKNOWN, 1.0, "none");
562+
addPolygon("unknown_shape", POLYGON_UNKNOWN, 1.0, "none");
563563
addSource(SCAN_NAME, SCAN);
564-
setVectors({"UnknownShape"}, {SCAN_NAME});
564+
setVectors({"unknown_shape"}, {SCAN_NAME});
565565

566566
// Check that Collision Detector node can not be configured for this parameters set
567567
cd_->cant_configure();
@@ -570,9 +570,9 @@ TEST_F(Tester, testIncorrectPolygonType)
570570
TEST_F(Tester, testIncorrectActionType)
571571
{
572572
setCommonParameters();
573-
addPolygon("DetectionRegion", POLYGON, 1.0, "approach");
573+
addPolygon("detection_region", POLYGON, 1.0, "approach");
574574
addSource(SCAN_NAME, SCAN);
575-
setVectors({"DetectionRegion"}, {SCAN_NAME});
575+
setVectors({"detection_region"}, {SCAN_NAME});
576576

577577
// Check that Collision Detector node can not be configured for this action type
578578
cd_->cant_configure();
@@ -581,9 +581,9 @@ TEST_F(Tester, testIncorrectActionType)
581581
TEST_F(Tester, testIncorrectSourceType)
582582
{
583583
setCommonParameters();
584-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
585-
addSource("UnknownSource", SOURCE_UNKNOWN);
586-
setVectors({"DetectionRegion"}, {"UnknownSource"});
584+
addPolygon("detection_region", POLYGON, 1.0, "none");
585+
addSource("unknown_source", SOURCE_UNKNOWN);
586+
setVectors({"detection_region"}, {"unknown_source"});
587587

588588
// Check that Collision Detector node can not be configured for this parameters set
589589
cd_->cant_configure();
@@ -592,7 +592,7 @@ TEST_F(Tester, testIncorrectSourceType)
592592
TEST_F(Tester, testPolygonsNotSet)
593593
{
594594
setCommonParameters();
595-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
595+
addPolygon("detection_region", POLYGON, 1.0, "none");
596596
addSource(SCAN_NAME, SCAN);
597597

598598
// Check that Collision Detector node can not be configured for this parameters set
@@ -602,11 +602,11 @@ TEST_F(Tester, testPolygonsNotSet)
602602
TEST_F(Tester, testSourcesNotSet)
603603
{
604604
setCommonParameters();
605-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
605+
addPolygon("detection_region", POLYGON, 1.0, "none");
606606
addSource(SCAN_NAME, SCAN);
607607
cd_->declare_parameter(
608608
"polygons",
609-
rclcpp::ParameterValue(std::vector<std::string>{"DetectionRegion"}));
609+
rclcpp::ParameterValue(std::vector<std::string>{"detection_region"}));
610610

611611
// Check that Collision Detector node can not be configured for this parameters set
612612
cd_->cant_configure();
@@ -615,9 +615,9 @@ TEST_F(Tester, testSourcesNotSet)
615615
TEST_F(Tester, testSuccessfulConfigure)
616616
{
617617
setCommonParameters();
618-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
618+
addPolygon("detection_region", POLYGON, 1.0, "none");
619619
addSource(SCAN_NAME, SCAN);
620-
setVectors({"DetectionRegion"}, {SCAN_NAME});
620+
setVectors({"detection_region"}, {SCAN_NAME});
621621

622622
// Check that Collision Detector node can be configured successfully for this parameters set
623623
cd_->configure();
@@ -628,9 +628,9 @@ TEST_F(Tester, testProcessNonActive)
628628
rclcpp::Time curr_time = cd_->now();
629629

630630
setCommonParameters();
631-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
631+
addPolygon("detection_region", POLYGON, 1.0, "none");
632632
addSource(SCAN_NAME, SCAN);
633-
setVectors({"DetectionRegion"}, {SCAN_NAME});
633+
setVectors({"detection_region"}, {SCAN_NAME});
634634

635635
// Configure Collision Detector node, but not activate
636636
cd_->configure();
@@ -647,9 +647,9 @@ TEST_F(Tester, testProcessActive)
647647
rclcpp::Time curr_time = cd_->now();
648648

649649
setCommonParameters();
650-
addPolygon("DetectionRegion", POLYGON, 1.0, "none");
650+
addPolygon("detection_region", POLYGON, 1.0, "none");
651651
addSource(SCAN_NAME, SCAN);
652-
setVectors({"DetectionRegion"}, {SCAN_NAME});
652+
setVectors({"detection_region"}, {SCAN_NAME});
653653

654654
// Configure and activate Collision Detector node
655655
cd_->start();
@@ -667,17 +667,17 @@ TEST_F(Tester, testPolygonDetection)
667667
// Set Collision Detector parameters.
668668
setCommonParameters();
669669
// Create polygon
670-
addPolygon("DetectionRegion", POLYGON, 2.0, "none");
670+
addPolygon("detection_region", POLYGON, 2.0, "none");
671671
addSource(RANGE_NAME, RANGE);
672-
setVectors({"DetectionRegion"}, {RANGE_NAME});
672+
setVectors({"detection_region"}, {RANGE_NAME});
673673

674674
// Start Collision Detector node
675675
cd_->start();
676676

677677
// Share TF
678678
sendTransforms(curr_time);
679679

680-
// Obstacle is in DetectionRegion
680+
// Obstacle is in detection_region
681681
publishRange(1.5, curr_time);
682682

683683
ASSERT_TRUE(waitData(1.5, 300ms, curr_time));
@@ -696,17 +696,17 @@ TEST_F(Tester, testCircleDetection)
696696
// Set Collision Detector parameters.
697697
setCommonParameters();
698698
// Create Circle
699-
addPolygon("DetectionRegion", CIRCLE, 3.0, "none");
699+
addPolygon("detection_region", CIRCLE, 3.0, "none");
700700
addSource(RANGE_NAME, RANGE);
701-
setVectors({"DetectionRegion"}, {RANGE_NAME});
701+
setVectors({"detection_region"}, {RANGE_NAME});
702702

703703
// Start Collision Detector node
704704
cd_->start();
705705

706706
// Share TF
707707
sendTransforms(curr_time);
708708

709-
// Obstacle is in DetectionRegion
709+
// Obstacle is in detection_region
710710
publishRange(1.5, curr_time);
711711

712712
ASSERT_TRUE(waitData(1.5, 300ms, curr_time));
@@ -725,17 +725,17 @@ TEST_F(Tester, testScanDetection)
725725
// Set Collision Detector parameters.
726726
setCommonParameters();
727727
// Create polygon
728-
addPolygon("DetectionRegion", CIRCLE, 3.0, "none");
728+
addPolygon("detection_region", CIRCLE, 3.0, "none");
729729
addSource(SCAN_NAME, SCAN);
730-
setVectors({"DetectionRegion"}, {SCAN_NAME});
730+
setVectors({"detection_region"}, {SCAN_NAME});
731731

732732
// Start Collision Detector node
733733
cd_->start();
734734

735735
// Share TF
736736
sendTransforms(curr_time);
737737

738-
// Obstacle is in DetectionRegion
738+
// Obstacle is in detection_region
739739
publishScan(1.5, curr_time);
740740

741741
ASSERT_TRUE(waitData(1.5, 300ms, curr_time));
@@ -754,17 +754,17 @@ TEST_F(Tester, testPointcloudDetection)
754754
// Set Collision Detector parameters.
755755
setCommonParameters();
756756
// Create polygon
757-
addPolygon("DetectionRegion", CIRCLE, 3.0, "none");
757+
addPolygon("detection_region", CIRCLE, 3.0, "none");
758758
addSource(POINTCLOUD_NAME, POINTCLOUD);
759-
setVectors({"DetectionRegion"}, {POINTCLOUD_NAME});
759+
setVectors({"detection_region"}, {POINTCLOUD_NAME});
760760

761761
// Start Collision Detector node
762762
cd_->start();
763763

764764
// Share TF
765765
sendTransforms(curr_time);
766766

767-
// Obstacle is in DetectionRegion
767+
// Obstacle is in detection_region
768768
publishPointCloud(2.5, curr_time);
769769

770770
ASSERT_TRUE(waitData(std::hypot(2.5, 0.01), 500ms, curr_time));
@@ -783,17 +783,17 @@ TEST_F(Tester, testPolygonSourceDetection)
783783
// Set Collision Detector parameters.
784784
setCommonParameters();
785785
// Create polygon
786-
addPolygon("DetectionRegion", CIRCLE, 3.0, "none");
786+
addPolygon("detection_region", CIRCLE, 3.0, "none");
787787
addSource(POLYGON_NAME, POLYGON_SOURCE);
788-
setVectors({"DetectionRegion"}, {POLYGON_NAME});
788+
setVectors({"detection_region"}, {POLYGON_NAME});
789789

790790
// Start Collision Detector node
791791
cd_->start();
792792

793793
// Share TF
794794
sendTransforms(curr_time);
795795

796-
// Obstacle is in DetectionRegion
796+
// Obstacle is in detection_region
797797
publishPolygon(2.5, curr_time);
798798

799799
ASSERT_TRUE(waitData(std::hypot(2.5, 1.0), 500ms, curr_time));
@@ -812,17 +812,17 @@ TEST_F(Tester, testCostmapDetection)
812812
// Set Collision Detector parameters.
813813
setCommonParameters();
814814
// Create polygon
815-
addPolygon("DetectionRegion", CIRCLE, 3.0, "none");
815+
addPolygon("detection_region", CIRCLE, 3.0, "none");
816816
addSource(COSTMAP_NAME, COSTMAP);
817-
setVectors({"DetectionRegion"}, {COSTMAP_NAME});
817+
setVectors({"detection_region"}, {COSTMAP_NAME});
818818

819819
// Start Collision Detector node
820820
cd_->start();
821821

822822
// Share TF
823823
sendTransforms(curr_time);
824824

825-
// Obstacle is in DetectionRegion
825+
// Obstacle is in detection_region
826826
publishCostmap(1.5, curr_time);
827827

828828
ASSERT_TRUE(waitData(1.5, 500ms, curr_time));

nav2_collision_monitor/test/collision_monitor_node_bag.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ collision_monitor:
1717
cost_threshold: 253
1818
enabled: true
1919

20-
polygons: [Detection]
21-
Detection:
20+
polygons: [detection]
21+
detection:
2222
type: circle
2323
action_type: stop
2424
min_points: 1

0 commit comments

Comments
 (0)