Skip to content

Commit 7eeea66

Browse files
authored
Merge pull request #8 from openads-project/feature/separate-global-route
Handle enriched/global route separation in lanelet2_route_planning
2 parents 55e07bb + 424001f commit 7eeea66

5 files changed

Lines changed: 44 additions & 30 deletions

File tree

.repos

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ repositories:
22
perception_interfaces:
33
type: git
44
url: https://github.com/ika-rwth-aachen/perception_interfaces.git
5-
version: v1.0.0
5+
version: v1.1.2
66
planning_interfaces:
77
type: git
88
url: https://github.com/ika-rwth-aachen/planning_interfaces.git
9-
version: v1.0.0
9+
version: v1.1.2

demo/docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
route_topic:=/planning/lanelet2_route_planning/route
1212
1313
lanelet2-route-planning:
14-
image: ghcr.io/openads-project/lanelet2_route_planning:v1.2.0
14+
image: ghcr.io/openads-project/lanelet2_route_planning:v2.0.0
1515
environment:
1616
RMW_IMPLEMENTATION: rmw_fastrtps_cpp
1717
command: |
@@ -20,15 +20,15 @@ services:
2020
ego_data_topic:=/localization/ego_data
2121
2222
lanelet2-map-server:
23-
image: ghcr.io/openads-project/lanelet2_map_server:v1.2.2
23+
image: ghcr.io/openads-project/lanelet2_map_server:v1.2.3
2424
environment:
2525
RMW_IMPLEMENTATION: rmw_fastrtps_cpp
2626
command: |
2727
ros2 launch lanelet2_map_server lanelet2_map_server_launch.py
2828
namespace:=/localization
2929
3030
ego-data-publisher:
31-
image: ghcr.io/openads-project/monitoring:v1.0.0
31+
image: ghcr.io/openads-project/monitoring:v26.9.4
3232
environment:
3333
RMW_IMPLEMENTATION: rmw_fastrtps_cpp
3434
command: |
@@ -38,19 +38,19 @@ services:
3838
"{header: {stamp: 'now', frame_id: 'map'}, state: {model_id: 1, continuous_state: [80.0, 90.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5708, 0.0, 0.0, 0.0], discrete_state: [0, 0, 0, 0]}, length: 4.0, width: 1.8, height: 1.5}"
3939
4040
base-link-transform-publisher:
41-
image: ghcr.io/openads-project/monitoring:v1.0.0
41+
image: ghcr.io/openads-project/monitoring:v26.9.4
4242
environment:
4343
RMW_IMPLEMENTATION: rmw_fastrtps_cpp
4444
command: |
4545
ros2 run tf2_ros static_transform_publisher
4646
80.0 88.54 0.0 1.5708 0.0 0.0 map base_link
4747
4848
rviz:
49-
image: ghcr.io/openads-project/monitoring:v1.0.0
49+
image: ghcr.io/openads-project/monitoring:v26.9.4
5050
environment:
5151
RMW_IMPLEMENTATION: rmw_fastrtps_cpp
5252
DISPLAY: ${DISPLAY}
5353
command: rviz2 -d /config.rviz
5454
volumes:
5555
- ./rviz/config.rviz:/config.rviz
56-
- /tmp/.X11-unix:/tmp/.X11-unix:rw
56+
- /tmp/.X11-unix:/tmp/.X11-unix:rw

deployment/helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ description: ROS 2 Reference Trajectory Planning for Automated Driving
66
dependencies:
77
- repository: oci://ghcr.io/openads-project/openads-helm
88
name: openadservice
9-
version: 1.0.0
9+
version: 1.1.0

simple_planner/src/simple_planner.cpp

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ void SimplePlannerNode::routeCallback(const route_planning_msgs::msg::Route::Uni
351351
route_topic_diagnostic_->tick(msg->header.stamp);
352352
}
353353
route_ = *msg;
354-
355354
if (!route_init_) {
356355
RCLCPP_INFO(this->get_logger(), "Received new route message, initialized global variable");
357356
route_init_ = true;
@@ -647,12 +646,28 @@ SimplePlannerNode::FollowRoutePlan SimplePlannerNode::buildRoutePlan(const std_m
647646
void SimplePlannerNode::appendRoutePoints(const route_planning_msgs::msg::Route& tf_route,
648647
FollowRoutePlan& route_plan,
649648
std::map<uint64_t, uint64_t>& lane_change_indices_map) {
649+
if (tf_route.current_route_element_idx >= tf_route.route_elements.size()) {
650+
const std::string msg = "Current route element index is outside the received local route";
651+
setHealth(diagnostic_msgs::msg::DiagnosticStatus::WARN, msg, health_.key_value_pairs);
652+
RCLCPP_WARN(this->get_logger(), "%s", msg.c_str());
653+
return;
654+
}
655+
656+
const bool destination_is_present = tf_route.destination_route_element_idx < tf_route.route_elements.size();
657+
const size_t destination_or_route_end_idx =
658+
destination_is_present ? tf_route.destination_route_element_idx : tf_route.route_elements.size();
659+
if (destination_or_route_end_idx <= tf_route.current_route_element_idx) {
660+
const std::string msg = "Received local route contains no remaining route elements";
661+
setHealth(diagnostic_msgs::msg::DiagnosticStatus::WARN, msg, health_.key_value_pairs);
662+
RCLCPP_WARN(this->get_logger(), "%s", msg.c_str());
663+
return;
664+
}
665+
650666
double t_total = 0.0;
651-
RCLCPP_DEBUG(this->get_logger(), "Number of remaining route elements: %zu",
652-
tf_route.destination_route_element_idx - tf_route.current_route_element_idx);
653-
health_.key_value_pairs.insert(
654-
{"RemainingRouteElements", std::to_string(tf_route.destination_route_element_idx - tf_route.current_route_element_idx)});
655-
for (size_t j = tf_route.current_route_element_idx; j < tf_route.destination_route_element_idx; ++j) {
667+
const size_t remaining_route_elements = destination_or_route_end_idx - tf_route.current_route_element_idx;
668+
RCLCPP_DEBUG(this->get_logger(), "Number of remaining route elements: %zu", remaining_route_elements);
669+
health_.key_value_pairs.insert_or_assign("RemainingRouteElements", std::to_string(remaining_route_elements));
670+
for (size_t j = tf_route.current_route_element_idx; j < destination_or_route_end_idx; ++j) {
656671
const auto& route_element = tf_route.route_elements[j];
657672
if (!route_element.is_enriched) {
658673
RCLCPP_DEBUG(this->get_logger(), "Route element %zu is not enriched. Skipping.", j);
@@ -664,21 +679,15 @@ void SimplePlannerNode::appendRoutePoints(const route_planning_msgs::msg::Route&
664679
simple_path_point.position =
665680
Eigen::Vector2d(suggested_lane.reference_pose.position.x, suggested_lane.reference_pose.position.y);
666681
simple_path_point.s = route_element.s;
667-
simple_path_point.v = v_ref_;
668-
if (v_ref_ < 0.0) {
669-
simple_path_point.v = suggested_lane.speed_limit / 3.6;
670-
}
682+
simple_path_point.v = v_ref_ < 0.0 ? suggested_lane.speed_limit / 3.6 : v_ref_;
671683

672684
if (!route_plan.path.points.empty()) {
673-
double v_average = (route_plan.path.points.back().v + simple_path_point.v) / 2.0;
674-
double dt = 0.0;
675-
if (v_average != 0.0) {
676-
dt = (simple_path_point.s - route_plan.path.points.back().s) / v_average;
677-
}
685+
const double v_average = (route_plan.path.points.back().v + simple_path_point.v) / 2.0;
686+
const double dt = v_average != 0.0 ? (simple_path_point.s - route_plan.path.points.back().s) / v_average : 0.0;
678687
if (dt <= 0.0) {
679-
std::string msg = "Negative time difference " + std::to_string(dt) +
680-
" between points at s=" + std::to_string(route_plan.path.points.back().s) +
681-
" and s=" + std::to_string(simple_path_point.s) + ". Could lead to unexpected behavior.";
688+
const std::string msg = "Negative time difference " + std::to_string(dt) +
689+
" between points at s=" + std::to_string(route_plan.path.points.back().s) +
690+
" and s=" + std::to_string(simple_path_point.s) + ". Could lead to unexpected behavior.";
682691
setHealth(diagnostic_msgs::msg::DiagnosticStatus::WARN, msg, health_.key_value_pairs);
683692
RCLCPP_WARN(this->get_logger(), "%s", msg.c_str());
684693
}
@@ -700,8 +709,7 @@ void SimplePlannerNode::appendRoutePoints(const route_planning_msgs::msg::Route&
700709
}
701710

702711
route_plan.path.points.push_back(simple_path_point);
703-
704-
if (j == tf_route.destination_route_element_idx - 1) {
712+
if (destination_is_present && j + 1 == destination_or_route_end_idx) {
705713
SimplePathPoint destination_point;
706714
destination_point.position = Eigen::Vector2d(tf_route.destination.x, tf_route.destination.y);
707715
destination_point.s = simple_path_point.s + (destination_point.position - simple_path_point.position).norm();
@@ -714,6 +722,12 @@ void SimplePlannerNode::appendRoutePoints(const route_planning_msgs::msg::Route&
714722
break;
715723
}
716724
}
725+
726+
if (!destination_is_present && !route_plan.stop_at_end && t_total < 2.0 * trajectory_horizon_) {
727+
const std::string msg = "Local enriched route ends before the planner horizon; trajectory will end at its last element";
728+
setHealth(diagnostic_msgs::msg::DiagnosticStatus::WARN, msg, health_.key_value_pairs);
729+
RCLCPP_WARN(this->get_logger(), "%s", msg.c_str());
730+
}
717731
}
718732

719733
bool SimplePlannerNode::tryRegisterLaneChange(const route_planning_msgs::msg::Route& tf_route,

0 commit comments

Comments
 (0)