Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d1a8572
add path cut for road border
ohtt Jul 13, 2026
e59e566
change param structure
ohtt Jul 13, 2026
f6db3c1
reduce change
ohtt Jul 13, 2026
0272064
Merge branch 'feat/v0.64/e2e' into feature/map_based_predictor_cut_pe…
ohtt Jul 13, 2026
4c382f5
fix precommit
ohtt Jul 13, 2026
f08207c
Merge branch 'feature/map_based_predictor_cut_pedestrian_path_with_ro…
ohtt Jul 13, 2026
90c33b3
merge test file
ohtt Jul 13, 2026
0fecc06
rename
ohtt Jul 14, 2026
622c978
generalize
ohtt Jul 14, 2026
6fd9bdc
rename
ohtt Jul 14, 2026
ca54044
update
ohtt Jul 14, 2026
a9a645a
remove duplicate
ohtt Jul 14, 2026
8afb3ca
revert to simple module
ohtt Jul 14, 2026
007b732
common
ohtt Jul 14, 2026
b103a4a
remove comment
ohtt Jul 14, 2026
a839665
remove new params
ohtt Jul 14, 2026
89916d6
remove lanelet lib
ohtt Jul 14, 2026
ea9a18f
remove include
ohtt Jul 14, 2026
3e2cabd
revert
ohtt Jul 14, 2026
4e26406
revert
ohtt Jul 14, 2026
d2e49c3
remove mergin
ohtt Jul 14, 2026
654eeec
rename functions
ohtt Jul 15, 2026
8807321
refactor
ohtt Jul 15, 2026
bd415bf
fix format
ohtt Jul 15, 2026
3482dab
change to remove road_border in extended Crooswalk
ohtt Jul 15, 2026
672a728
fix format
ohtt Jul 15, 2026
bdf7762
fix format
ohtt Jul 15, 2026
76235b7
update
ohtt Jul 16, 2026
a291d85
build rtree once
ohtt Jul 16, 2026
284449f
chage to use has_value
ohtt Jul 16, 2026
288a4b0
Merge branch 'feat/v0.64/e2e' into feature/map_based_predictor_cut_pe…
ohtt Jul 16, 2026
3193de6
refactor , change to use LaneletMapConstUPtr
ohtt Jul 16, 2026
9152e54
Merge branch 'feature/map_based_predictor_cut_pedestrian_path_with_ro…
ohtt Jul 16, 2026
84845bd
refactoring
ohtt Jul 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions perception/autoware_map_based_prediction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ ament_auto_add_library(map_based_prediction_node SHARED
lib/predictor_vru/traffic_signal.cpp
lib/predictor_vru/fence.cpp
lib/predictor_vru/vegetation.cpp
lib/predictor_vru/guard_rail.cpp
lib/predictor_vru/road_border.cpp
lib/predictor_vru/path_cut_debug.cpp
lib/path_cut/path_cut_utils.cpp
lib/path_cut/footprint_path_cut.cpp
lib/utils.cpp
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2026 TIER IV, inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE__MAP_BASED_PREDICTION__PATH_CUT__FOOTPRINT_PATH_CUT_HPP_
#define AUTOWARE__MAP_BASED_PREDICTION__PATH_CUT__FOOTPRINT_PATH_CUT_HPP_

#include "autoware/map_based_prediction/path_cut/path_cut_utils.hpp"

#include <autoware_utils_geometry/boost_geometry.hpp>

#include <autoware_perception_msgs/msg/predicted_objects.hpp>
#include <autoware_perception_msgs/msg/shape.hpp>

#include <lanelet2_core/primitives/BoundingBox.h>

#include <optional>
#include <vector>

namespace autoware::map_based_prediction::path_cut
{

double calc_footprint_search_margin(const autoware_perception_msgs::msg::Shape & shape);

bool shape_has_footprint(const autoware_perception_msgs::msg::Shape & shape);

bool has_required_info(const autoware_perception_msgs::msg::PredictedObject & predicted_object);

lanelet::BoundingBox2d get_bbox_contain_path_with_footprint(
const std::vector<PredictedPath> & predicted_paths,
const autoware_perception_msgs::msg::Shape & object_shape);
lanelet::BoundingBox2d get_bbox_contain_path_with_footprint(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape);

std::optional<size_t> find_footprint_crossing_index(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape,
const std::vector<autoware_utils_geometry::LineString2d> & linestrings_2d);

std::optional<size_t> find_footprint_crossing_index(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape,
const std::vector<autoware_utils_geometry::Polygon2d> & polygons_2d);

} // namespace autoware::map_based_prediction::path_cut

#endif // AUTOWARE__MAP_BASED_PREDICTION__PATH_CUT__FOOTPRINT_PATH_CUT_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2026 TIER IV, inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__GUARD_RAIL_HPP_
#define AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__GUARD_RAIL_HPP_

#include "autoware/map_based_prediction/path_generator/path_generator.hpp"

#include <autoware_perception_msgs/msg/predicted_objects.hpp>

#include <lanelet2_core/LaneletMap.h>

#include <memory>
#include <vector>

namespace autoware::map_based_prediction
{

class GuardRailModule
{
public:
GuardRailModule() = default;

void build_from_map(std::shared_ptr<lanelet::LaneletMap> lanelet_map_ptr);

[[nodiscard]] std::vector<PredictedPath> cut_paths_crossing_guard_rail(
const autoware_perception_msgs::msg::PredictedObject & predicted_object) const;

private:
lanelet::LaneletMapUPtr guard_rail_layer_{nullptr};
};

} // namespace autoware::map_based_prediction

#endif // AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__GUARD_RAIL_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace autoware::map_based_prediction
{

enum class PathCutSource { Vegetation, Fence };
enum class PathCutSource { Vegetation, Fence, RoadBorder, GuardRail };

struct PathCutDebug
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
#define AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__PREDICTOR_VRU_HPP_

#include "autoware/map_based_prediction/data_structure.hpp"
#include "autoware/map_based_prediction/path_cut/path_cut_utils.hpp"
#include "autoware/map_based_prediction/path_generator/path_generator.hpp"
#include "autoware/map_based_prediction/predictor_vru/fence.hpp"
#include "autoware/map_based_prediction/predictor_vru/guard_rail.hpp"
#include "autoware/map_based_prediction/predictor_vru/history.hpp"
#include "autoware/map_based_prediction/predictor_vru/road_border.hpp"
#include "autoware/map_based_prediction/predictor_vru/traffic_signal.hpp"
#include "autoware/map_based_prediction/predictor_vru/vegetation.hpp"

Expand Down Expand Up @@ -72,6 +75,11 @@ class PredictorVru

const Params & getParams() const { return params_; }

void set_max_deceleration(const path_cut::MaxDecelerationParams & max_decel_params)
{
max_decel_params_ = max_decel_params;
}

void setLaneletMap(std::shared_ptr<lanelet::LaneletMap> lanelet_map_ptr);

void setTimeKeeper(std::shared_ptr<autoware_utils::TimeKeeper> time_keeper_ptr)
Expand Down Expand Up @@ -108,10 +116,13 @@ class PredictorVru
// Sub-modules
FenceModule fence_module_;
VegetationModule vegetation_module_;
GuardRailModule guard_rail_module_;
RoadBorderModule road_border_module_;
TrafficSignalModule traffic_signal_module_;
CrosswalkUserHistoryManager history_manager_;

Params params_{};
path_cut::MaxDecelerationParams max_decel_params_{};

PredictedObject getPredictedObjectAsCrosswalkUser(
const TrackedObject & object, const rclcpp::Time & stamp,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2026 TIER IV, inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__ROAD_BORDER_HPP_
#define AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__ROAD_BORDER_HPP_

#include "autoware/map_based_prediction/path_cut/path_cut_utils.hpp"
#include "autoware/map_based_prediction/path_generator/path_generator.hpp"

#include <autoware_perception_msgs/msg/tracked_object.hpp>

#include <lanelet2_core/LaneletMap.h>

#include <memory>

namespace autoware::map_based_prediction
{

class RoadBorderModule
{
public:
RoadBorderModule() = default;

void build_from_map(std::shared_ptr<lanelet::LaneletMap> lanelet_map_ptr);

[[nodiscard]] PredictedPath cut_path_at_road_border(
const PredictedPath & predicted_path,
const autoware_perception_msgs::msg::TrackedObject & object,
const path_cut::MaxDecelerationParams & max_decel_params) const;

private:
std::shared_ptr<lanelet::LaneletMap> lanelet_map_ptr_{nullptr};
lanelet::LaneletMapUPtr road_border_layer_{nullptr};
};

} // namespace autoware::map_based_prediction

#endif // AUTOWARE__MAP_BASED_PREDICTION__PREDICTOR_VRU__ROAD_BORDER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright 2026 TIER IV, inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "autoware/map_based_prediction/path_cut/footprint_path_cut.hpp"

#include <autoware_utils_geometry/boost_polygon_utils.hpp>
#include <autoware_utils_geometry/geometry.hpp>

#include <boost/geometry.hpp>

#include <algorithm>
#include <cmath>

namespace autoware::map_based_prediction::path_cut
{

namespace
{
void extend_bbox_by_footprint(
lanelet::BoundingBox2d & search_bbox, const PredictedPath & predicted_path, const double margin)
{
const lanelet::BasicPoint2d offset(margin, margin);
for (const auto & pose : predicted_path.path) {
const lanelet::BasicPoint2d center(pose.position.x, pose.position.y);
search_bbox.extend(center - offset);
search_bbox.extend(center + offset);
}
}
} // namespace

double calc_footprint_search_margin(const autoware_perception_msgs::msg::Shape & shape)
{
if (shape.type == autoware_perception_msgs::msg::Shape::BOUNDING_BOX) {
const auto hx = shape.dimensions.x * 0.5;
const auto hy = shape.dimensions.y * 0.5;
return std::hypot(hx, hy);
}
if (shape.type == autoware_perception_msgs::msg::Shape::CYLINDER) {
return shape.dimensions.x * 0.5;
}
return std::max(shape.dimensions.x, shape.dimensions.y) * 0.5;
}

bool shape_has_footprint(const autoware_perception_msgs::msg::Shape & shape)
{
using autoware_perception_msgs::msg::Shape;
switch (shape.type) {
case Shape::BOUNDING_BOX:
return shape.dimensions.x > 0.0 && shape.dimensions.y > 0.0;
case Shape::CYLINDER:
return shape.dimensions.x > 0.0;
case Shape::POLYGON:
return !shape.footprint.points.empty();
default:
return false;
}
}

bool has_required_info(const autoware_perception_msgs::msg::PredictedObject & predicted_object)
{
return !predicted_object.kinematics.predicted_paths.empty() &&
shape_has_footprint(predicted_object.shape);
}

lanelet::BoundingBox2d get_bbox_contain_path_with_footprint(
const std::vector<PredictedPath> & predicted_paths,
const autoware_perception_msgs::msg::Shape & object_shape)
{
lanelet::BoundingBox2d search_bbox;
const auto margin = calc_footprint_search_margin(object_shape);
for (const auto & predicted_path : predicted_paths) {
extend_bbox_by_footprint(search_bbox, predicted_path, margin);
}
return search_bbox;
}

lanelet::BoundingBox2d get_bbox_contain_path_with_footprint(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape)
{
lanelet::BoundingBox2d search_bbox;
extend_bbox_by_footprint(search_bbox, predicted_path, calc_footprint_search_margin(object_shape));
return search_bbox;
}

std::optional<size_t> find_footprint_crossing_index(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape,
const std::vector<autoware_utils_geometry::LineString2d> & linestrings_2d)
{
if (linestrings_2d.empty()) {
return std::nullopt;
}
for (auto i = 0UL; i < predicted_path.path.size(); ++i) {
const autoware_utils_geometry::Polygon2d footprint =
autoware_utils_geometry::to_polygon2d(predicted_path.path.at(i), object_shape);
for (const auto & linestring : linestrings_2d) {
if (boost::geometry::intersects(footprint, linestring)) {
return i;
}
}
}
return std::nullopt;
}

std::optional<size_t> find_footprint_crossing_index(
const PredictedPath & predicted_path, const autoware_perception_msgs::msg::Shape & object_shape,
const std::vector<autoware_utils_geometry::Polygon2d> & polygons_2d)
{
if (polygons_2d.empty()) {
return std::nullopt;
}
for (auto i = 0UL; i < predicted_path.path.size(); ++i) {
const autoware_utils_geometry::Polygon2d footprint =
autoware_utils_geometry::to_polygon2d(predicted_path.path.at(i), object_shape);
for (const auto & polygon : polygons_2d) {
// NOTE: intersects_convex (GJK) treats both polygons as convex. A non-convex boundary area
// is evaluated as its convex hull, but this works effectively.
if (autoware_utils_geometry::intersects_convex(footprint, polygon)) {
return i;
}
}
}
return std::nullopt;
}

} // namespace autoware::map_based_prediction::path_cut
Loading
Loading