Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_lidar_marker_localizer
Browse files Browse the repository at this point in the history
  • Loading branch information
SakodaShintaro authored Nov 20, 2023
2 parents 2c5f463 + 7fe0b59 commit 1d3181a
Show file tree
Hide file tree
Showing 83 changed files with 2,478 additions and 979 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- planning/**/*
"component:sensing":
- sensing/**/*
"component:simulator":
"component:simulation":
- simulator/**/*
"component:system":
- system/**/*
Expand Down
2 changes: 0 additions & 2 deletions .github/sync-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
- source: .github/PULL_REQUEST_TEMPLATE/standard-change.md
- source: .github/dependabot.yaml
- source: .github/stale.yml
pre-commands: |
sd "staleLabel: stale" "staleLabel: status:stale" {source}
- source: .github/workflows/cancel-previous-workflows.yaml
- source: .github/workflows/github-release.yaml
- source: .github/workflows/pre-commit.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <geometry_msgs/msg/twist_stamped.hpp>
#include <nav_msgs/msg/odometry.hpp>

#include <boost/geometry/index/rtree.hpp>
#include <boost/optional.hpp>

#include <lanelet2_core/LaneletMap.h>
Expand All @@ -46,7 +47,9 @@ using autoware_auto_planning_msgs::msg::TrajectoryPoint;
using autoware_planning_msgs::msg::LaneletRoute;
using tier4_autoware_utils::LinearRing2d;
using tier4_autoware_utils::PoseDeviation;
using tier4_autoware_utils::Segment2d;
using TrajectoryPoints = std::vector<TrajectoryPoint>;
typedef boost::geometry::index::rtree<Segment2d, boost::geometry::index::rstar<16>> SegmentRtree;

struct Param
{
Expand Down Expand Up @@ -137,13 +140,15 @@ class LaneDepartureChecker
const lanelet::ConstLanelets & candidate_lanelets,
const std::vector<LinearRing2d> & vehicle_footprints);

double calcMaxSearchLengthForBoundaries(const Trajectory & trajectory) const;

static SegmentRtree extractUncrossableBoundaries(
const lanelet::LaneletMap & lanelet_map, const geometry_msgs::msg::Point & ego_point,
const double max_search_length, const std::vector<std::string> & boundary_types_to_detect);

static bool willCrossBoundary(
const lanelet::ConstLanelets & candidate_lanelets,
const std::vector<LinearRing2d> & vehicle_footprints,
const std::vector<std::string> & boundary_types_to_detects);

static bool isCrossingRoadBorder(
const lanelet::BasicLineString2d & road_border, const std::vector<LinearRing2d> & footprints);
const SegmentRtree & uncrossable_segments);
};
} // namespace lane_departure_checker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include <algorithm>
#include <vector>

using motion_utils::calcArcLength;
using tier4_autoware_utils::LinearRing2d;
using tier4_autoware_utils::LineString2d;
using tier4_autoware_utils::MultiPoint2d;
using tier4_autoware_utils::Point2d;

Expand All @@ -41,15 +43,6 @@ using autoware_auto_planning_msgs::msg::TrajectoryPoint;
using TrajectoryPoints = std::vector<TrajectoryPoint>;
using geometry_msgs::msg::Point;

Point fromVector2dToMsg(const Eigen::Vector2d & point)
{
Point msg{};
msg.x = point.x();
msg.y = point.y();
msg.z = 0.0;
return msg;
}

double calcBrakingDistance(
const double abs_velocity, const double max_deceleration, const double delay_time)
{
Expand All @@ -67,27 +60,6 @@ bool isInAnyLane(const lanelet::ConstLanelets & candidate_lanelets, const Point2
return false;
}

bool isCrossingWithBoundary(
const lanelet::BasicLineString2d & boundary, const std::vector<LinearRing2d> & footprints)
{
for (auto & footprint : footprints) {
for (size_t i = 0; i < footprint.size() - 1; ++i) {
auto footprint1 = footprint.at(i).to_3d();
auto footprint2 = footprint.at(i + 1).to_3d();
for (size_t i = 0; i < boundary.size() - 1; ++i) {
auto boundary1 = boundary.at(i);
auto boundary2 = boundary.at(i + 1);
if (tier4_autoware_utils::intersect(
tier4_autoware_utils::toMsg(footprint1), tier4_autoware_utils::toMsg(footprint2),
fromVector2dToMsg(boundary1), fromVector2dToMsg(boundary2))) {
return true;
}
}
}
}
return false;
}

LinearRing2d createHullFromFootprints(const std::vector<LinearRing2d> & footprints)
{
MultiPoint2d combined;
Expand Down Expand Up @@ -172,8 +144,12 @@ Output LaneDepartureChecker::update(const Input & input)
output.is_out_of_lane = isOutOfLane(output.candidate_lanelets, output.vehicle_footprints.front());
output.processing_time_map["isOutOfLane"] = stop_watch.toc(true);

output.will_cross_boundary = willCrossBoundary(
output.candidate_lanelets, output.vehicle_footprints, input.boundary_types_to_detect);
const double max_search_length_for_boundaries =
calcMaxSearchLengthForBoundaries(*input.predicted_trajectory);
const auto uncrossable_boundaries = extractUncrossableBoundaries(
*input.lanelet_map, input.predicted_trajectory->points.front().pose.position,
max_search_length_for_boundaries, input.boundary_types_to_detect);
output.will_cross_boundary = willCrossBoundary(output.vehicle_footprints, uncrossable_boundaries);
output.processing_time_map["willCrossBoundary"] = stop_watch.toc(true);

return output;
Expand Down Expand Up @@ -334,38 +310,58 @@ bool LaneDepartureChecker::isOutOfLane(
return false;
}

bool LaneDepartureChecker::willCrossBoundary(
const lanelet::ConstLanelets & candidate_lanelets,
const std::vector<LinearRing2d> & vehicle_footprints,
const std::vector<std::string> & boundary_types_to_detect)
double LaneDepartureChecker::calcMaxSearchLengthForBoundaries(const Trajectory & trajectory) const
{
for (const auto & candidate_lanelet : candidate_lanelets) {
const std::string r_type =
candidate_lanelet.rightBound().attributeOr(lanelet::AttributeName::Type, "none");
if (
std::find(boundary_types_to_detect.begin(), boundary_types_to_detect.end(), r_type) !=
boundary_types_to_detect.end()) {
if (isCrossingWithBoundary(
candidate_lanelet.rightBound2d().basicLineString(), vehicle_footprints)) {
// std::cerr << "The crossed road_border's line string id: "
// << candidate_lanelet.rightBound().id() << std::endl;
return true;
const double max_ego_lon_length = std::max(
std::abs(vehicle_info_ptr_->max_longitudinal_offset_m),
std::abs(vehicle_info_ptr_->min_longitudinal_offset_m));
const double max_ego_lat_length = std::max(
std::abs(vehicle_info_ptr_->max_lateral_offset_m),
std::abs(vehicle_info_ptr_->min_lateral_offset_m));
const double max_ego_search_length = std::hypot(max_ego_lon_length, max_ego_lat_length);
return calcArcLength(trajectory.points) + max_ego_search_length;
}

SegmentRtree LaneDepartureChecker::extractUncrossableBoundaries(
const lanelet::LaneletMap & lanelet_map, const geometry_msgs::msg::Point & ego_point,
const double max_search_length, const std::vector<std::string> & boundary_types_to_detect)
{
const auto has_types =
[](const lanelet::ConstLineString3d & ls, const std::vector<std::string> & types) {
constexpr auto no_type = "";
const auto type = ls.attributeOr(lanelet::AttributeName::Type, no_type);
return (type != no_type && std::find(types.begin(), types.end(), type) != types.end());
};

SegmentRtree uncrossable_segments_in_range;
LineString2d line;
const auto ego_p = Point2d{ego_point.x, ego_point.y};
for (const auto & ls : lanelet_map.lineStringLayer) {
if (has_types(ls, boundary_types_to_detect)) {
line.clear();
for (const auto & p : ls) line.push_back(Point2d{p.x(), p.y()});
for (auto segment_idx = 0LU; segment_idx + 1 < line.size(); ++segment_idx) {
const Segment2d segment = {line[segment_idx], line[segment_idx + 1]};
if (boost::geometry::distance(segment, ego_p) < max_search_length) {
uncrossable_segments_in_range.insert(segment);
}
}
}
const std::string l_type =
candidate_lanelet.leftBound().attributeOr(lanelet::AttributeName::Type, "none");
if (
std::find(boundary_types_to_detect.begin(), boundary_types_to_detect.end(), l_type) !=
boundary_types_to_detect.end()) {
if (isCrossingWithBoundary(
candidate_lanelet.leftBound2d().basicLineString(), vehicle_footprints)) {
// std::cerr << "The crossed road_border's line string id: "
// << candidate_lanelet.leftBound().id() << std::endl;
return true;
}
}
return uncrossable_segments_in_range;
}

bool LaneDepartureChecker::willCrossBoundary(
const std::vector<LinearRing2d> & vehicle_footprints, const SegmentRtree & uncrossable_segments)
{
for (const auto & footprint : vehicle_footprints) {
std::vector<Segment2d> intersection_result;
uncrossable_segments.query(
boost::geometry::index::intersects(footprint), std::back_inserter(intersection_result));
if (!intersection_result.empty()) {
return true;
}
}
return false;
}

} // namespace lane_departure_checker
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@
<arg name="out_accel" value="/localization/acceleration"/>
</include>
</group>

<group>
<include file="$(find-pkg-share pose_instability_detector)/launch/pose_instability_detector.launch.xml">
<arg name="input_odometry" value="/localization/kinematic_state"/>
<arg name="input_twist" value="/localization/twist_estimator/twist_with_covariance"/>
<arg name="param_file" value="$(find-pkg-share pose_instability_detector)/config/pose_instability_detector.param.yaml"/>
</include>
</group>
</launch>
1 change: 1 addition & 0 deletions launch/tier4_localization_launch/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<exec_depend>ndt_scan_matcher</exec_depend>
<exec_depend>pointcloud_preprocessor</exec_depend>
<exec_depend>pose_initializer</exec_depend>
<exec_depend>pose_instability_detector</exec_depend>
<exec_depend>topic_tools</exec_depend>
<exec_depend>yabloc_common</exec_depend>
<exec_depend>yabloc_image_processing</exec_depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<arg name="radar_lanelet_filtering_range_param" default="$(find-pkg-share detected_object_validation)/config/object_lanelet_filter.param.yaml"/>
<arg name="use_near_radar_fusion" default="false"/>
<arg name="far_object_merger_sync_queue_size" default="20"/>
<arg name="radar_object_clustering_param_path" default="$(find-pkg-share radar_object_clustering)/config/radar_object_clustering.param.yaml"/>

<!-- Filter output name. Switch output topic name by 'use_radar_tracking_fusion' parameter defined in perception.launch -->
<let name="output_of_filtered_objects" value="$(var output/objects)" if="$(var use_radar_tracking_fusion)"/>
Expand Down Expand Up @@ -78,9 +79,7 @@
<arg name="filter/velocity_threshold" value="3.0"/>
<arg name="split/velocity_threshold" value="4.5"/>
<arg name="split_range" value="70.0"/>
<arg name="clustering/angle_threshold" value="0.174"/>
<arg name="clustering/distance_threshold" value="10.0"/>
<arg name="clustering/velocity_threshold" value="4.0"/>
<arg name="radar_object_clustering_param_path" value="$(var radar_object_clustering_param_path)"/>
</include>
</group>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<!-- Radar parameters -->
<arg name="input/radar" default="/sensing/radar/detected_objects"/>
<arg name="radar_lanelet_filtering_range_param" default="$(find-pkg-share detected_object_validation)/config/object_lanelet_filter.param.yaml"/>
<arg name="radar_object_clustering_param_path" default="$(find-pkg-share radar_object_clustering)/config/radar_object_clustering.param.yaml"/>

<!-- Camera-LiDAR fusion parameters -->
<arg name="remove_unknown" default="true"/>
Expand Down Expand Up @@ -145,6 +146,7 @@
<arg name="input/radar" value="$(var input/radar)"/>
<arg name="output/objects" value="objects"/>
<arg name="radar_lanelet_filtering_range_param" value="$(var radar_lanelet_filtering_range_param)"/>
<arg name="radar_object_clustering_param_path" value="$(var radar_object_clustering_param_path)"/>
</include>
</group>
</launch>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<!-- Radar parameters -->
<arg name="input/radar" default="/sensing/radar/detected_objects"/>
<arg name="radar_lanelet_filtering_range_param" default="$(find-pkg-share detected_object_validation)/config/object_lanelet_filter.param.yaml"/>
<arg name="radar_object_clustering_param_path" default="$(find-pkg-share radar_object_clustering)/config/radar_object_clustering.param.yaml"/>

<!-- LiDAR detection-->
<group>
Expand All @@ -37,9 +38,7 @@
<arg name="filter/velocity_threshold" value="3.0"/>
<arg name="split/velocity_threshold" value="4.5"/>
<arg name="split_range" value="70.0"/>
<arg name="clustering/angle_threshold" value="0.174"/>
<arg name="clustering/distance_threshold" value="10.0"/>
<arg name="clustering/velocity_threshold" value="4.0"/>
<arg name="radar_object_clustering_param_path" value="$(var radar_object_clustering_param_path)"/>
</include>
</group>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
<arg name="filter/velocity_threshold" default="1.5"/>
<arg name="split/velocity_threshold" default="5.5"/>
<arg name="split_range" default="80.0"/>
<arg name="clustering/angle_threshold" default="0.349"/>
<arg name="clustering/distance_threshold" default="10.0"/>
<arg name="clustering/velocity_threshold" default="5.0"/>
<arg name="radar_lanelet_filtering_range_param" default="$(find-pkg-share detected_object_validation)/config/object_lanelet_filter.param.yaml"/>
<arg name="radar_object_clustering_param_path" default="$(find-pkg-share radar_object_clustering)/config/radar_object_clustering.param.yaml"/>

<!-- Detection for far dynamic objects -->
<include file="$(find-pkg-share radar_crossing_objects_noise_filter)/launch/radar_crossing_objects_noise_filter.launch.xml">
Expand Down Expand Up @@ -43,14 +41,6 @@
<include file="$(find-pkg-share radar_object_clustering)/launch/radar_object_clustering.launch.xml">
<arg name="input/objects" value="lanelet_filtered_objects"/>
<arg name="output/objects" value="$(var output/objects)"/>
<arg name="angle_threshold" value="$(var clustering/angle_threshold)"/>
<arg name="distance_threshold" value="$(var clustering/distance_threshold)"/>
<arg name="velocity_threshold" value="$(var clustering/velocity_threshold)"/>
<arg name="is_fixed_label" value="true"/>
<arg name="fixed_label" value="CAR"/>
<arg name="is_fixed_size" value="true"/>
<arg name="size_x" value="4.0"/>
<arg name="size_y" value="1.5"/>
<arg name="size_z" value="1.5"/>
<arg name="radar_object_clustering_param_path" value="$(var radar_object_clustering_param_path)"/>
</include>
</launch>
5 changes: 4 additions & 1 deletion launch/tier4_perception_launch/launch/perception.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<arg name="object_recognition_detection_fusion_sync_param_path"/>
<arg name="object_recognition_detection_lidar_model_param_path"/>
<arg name="object_recognition_detection_radar_lanelet_filtering_range_param"/>
<arg name="object_recognition_detection_radar_object_clustering_param_path"/>
<arg name="object_recognition_tracking_multi_object_tracker_data_association_matrix_param_path"/>
<arg name="object_recognition_tracking_radar_object_tracker_data_association_matrix_param_path"/>
<arg name="object_recognition_tracking_radar_object_tracker_tracking_setting_param_path"/>
Expand Down Expand Up @@ -103,7 +104,7 @@
<!-- Radar long range integration methods -->
<arg
name="use_radar_tracking_fusion"
default="false"
default="true"
description="if use_radar_tracking_fusion:=true, radar information is merged in tracking launch. Otherwise, radar information is merged in detection launch."
/>

Expand Down Expand Up @@ -175,7 +176,9 @@
<arg name="outlier_param_path" value="$(var object_recognition_detection_outlier_param_path)"/>
<arg name="voxel_grid_based_euclidean_param_path" value="$(var object_recognition_detection_voxel_grid_based_euclidean_cluster_param_path)"/>
<arg name="radar_lanelet_filtering_range_param" value="$(var object_recognition_detection_radar_lanelet_filtering_range_param)"/>
<arg name="radar_object_clustering_param_path" value="$(var object_recognition_detection_radar_object_clustering_param_path)"/>
<arg name="detection_by_tracker_param_path" value="$(var object_recognition_detection_detection_by_tracker_param)"/>

<arg name="use_pointcloud_map" value="$(var use_pointcloud_map)"/>
<arg name="use_low_height_cropbox" value="$(var use_low_height_cropbox)"/>
<arg name="use_object_filter" value="$(var use_object_filter)"/>
Expand Down
1 change: 1 addition & 0 deletions launch/tier4_perception_launch/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<exec_depend>shape_estimation</exec_depend>
<exec_depend>tensorrt_yolo</exec_depend>
<exec_depend>topic_tools</exec_depend>
<exec_depend>tracking_object_merger</exec_depend>
<exec_depend>traffic_light_arbiter</exec_depend>
<exec_depend>traffic_light_classifier</exec_depend>
<exec_depend>traffic_light_fine_detector</exec_depend>
Expand Down
5 changes: 3 additions & 2 deletions localization/geo_pose_projector/src/geo_pose_projector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ GeoPoseProjector::GeoPoseProjector()

// Subscribe to geo_pose topic
geo_pose_sub_ = create_subscription<GeoPoseWithCovariance>(
"input_geo_pose", 10, [this](const GeoPoseWithCovariance::SharedPtr msg) { on_geo_pose(msg); });
"input_geo_pose", 10,
[this](const GeoPoseWithCovariance::ConstSharedPtr msg) { on_geo_pose(msg); });

// Publish pose topic
pose_pub_ = create_publisher<PoseWithCovariance>("output_pose", 10);
Expand All @@ -49,7 +50,7 @@ GeoPoseProjector::GeoPoseProjector()
}
}

void GeoPoseProjector::on_geo_pose(const GeoPoseWithCovariance::SharedPtr msg)
void GeoPoseProjector::on_geo_pose(const GeoPoseWithCovariance::ConstSharedPtr msg)
{
if (!projector_info_) {
RCLCPP_WARN_THROTTLE(
Expand Down
2 changes: 1 addition & 1 deletion localization/geo_pose_projector/src/geo_pose_projector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GeoPoseProjector : public rclcpp::Node
GeoPoseProjector();

private:
void on_geo_pose(const GeoPoseWithCovariance::SharedPtr msg);
void on_geo_pose(const GeoPoseWithCovariance::ConstSharedPtr msg);

component_interface_utils::Subscription<MapProjectorInfo>::SharedPtr sub_map_projector_info_;
rclcpp::Subscription<GeoPoseWithCovariance>::SharedPtr geo_pose_sub_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>ament_index_cpp</depend>
<depend>aruco</depend>
<depend>cv_bridge</depend>
<depend>diagnostic_msgs</depend>
Expand Down
Loading

0 comments on commit 1d3181a

Please sign in to comment.