Skip to content

Commit d5aa5d6

Browse files
authored
feat(map_based_prediction): use different time horizon (#6877)
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 010965b commit d5aa5d6

File tree

6 files changed

+109
-73
lines changed

6 files changed

+109
-73
lines changed

perception/map_based_prediction/config/map_based_prediction.param.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/**:
22
ros__parameters:
33
enable_delay_compensation: true
4-
prediction_time_horizon: 10.0 #[s]
4+
prediction_time_horizon:
5+
vehicle: 15.0 #[s]
6+
pedestrian: 10.0 #[s]
7+
unknown: 10.0 #[s]
58
lateral_control_time_horizon: 5.0 #[s]
69
prediction_sampling_delta_time: 0.5 #[s]
710
min_velocity_for_map_based_prediction: 1.39 #[m/s]

perception/map_based_prediction/include/map_based_prediction/map_based_prediction_node.hpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ struct PredictedRefPath
9999
Maneuver maneuver;
100100
};
101101

102+
struct PredictionTimeHorizon
103+
{
104+
double vehicle;
105+
double pedestrian;
106+
double unknown;
107+
};
108+
102109
using LaneletsData = std::vector<LaneletData>;
103110
using ManeuverProbability = std::unordered_map<Maneuver, float>;
104111
using autoware_auto_mapping_msgs::msg::HADMapBin;
@@ -161,7 +168,7 @@ class MapBasedPredictionNode : public rclcpp::Node
161168

162169
// Parameters
163170
bool enable_delay_compensation_;
164-
double prediction_time_horizon_;
171+
PredictionTimeHorizon prediction_time_horizon_;
165172
double lateral_control_time_horizon_;
166173
double prediction_time_horizon_rate_for_validate_lane_length_;
167174
double prediction_sampling_time_interval_;
@@ -238,7 +245,7 @@ class MapBasedPredictionNode : public rclcpp::Node
238245

239246
std::vector<PredictedRefPath> getPredictedReferencePath(
240247
const TrackedObject & object, const LaneletsData & current_lanelets_data,
241-
const double object_detected_time);
248+
const double object_detected_time, const double time_horizon);
242249
Maneuver predictObjectManeuver(
243250
const TrackedObject & object, const LaneletData & current_lanelet_data,
244251
const double object_detected_time);

perception/map_based_prediction/include/map_based_prediction/path_generator.hpp

+17-14
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,23 @@ using PosePath = std::vector<geometry_msgs::msg::Pose>;
8080
class PathGenerator
8181
{
8282
public:
83-
PathGenerator(
84-
const double time_horizon, const double lateral_time_horizon,
85-
const double sampling_time_interval, const double min_crosswalk_user_velocity);
83+
PathGenerator(const double sampling_time_interval, const double min_crosswalk_user_velocity);
8684

87-
PredictedPath generatePathForNonVehicleObject(const TrackedObject & object);
85+
PredictedPath generatePathForNonVehicleObject(
86+
const TrackedObject & object, const double duration);
8887

89-
PredictedPath generatePathForLowSpeedVehicle(const TrackedObject & object) const;
88+
PredictedPath generatePathForLowSpeedVehicle(
89+
const TrackedObject & object, const double duration) const;
9090

91-
PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object);
91+
PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object, const double duration);
9292

9393
PredictedPath generatePathForOnLaneVehicle(
94-
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit = 0.0);
94+
const TrackedObject & object, const PosePath & ref_paths, const double duration,
95+
const double lateral_duration, const double speed_limit = 0.0);
9596

9697
PredictedPath generatePathForCrosswalkUser(
97-
const TrackedObject & object, const CrosswalkEdgePoints & reachable_crosswalk) const;
98+
const TrackedObject & object, const CrosswalkEdgePoints & reachable_crosswalk,
99+
const double duration) const;
98100

99101
PredictedPath generatePathToTargetPoint(
100102
const TrackedObject & object, const Eigen::Vector2d & point) const;
@@ -111,21 +113,21 @@ class PathGenerator
111113

112114
private:
113115
// Parameters
114-
double time_horizon_;
115-
double lateral_time_horizon_;
116116
double sampling_time_interval_;
117117
double min_crosswalk_user_velocity_;
118118
bool use_vehicle_acceleration_;
119119
double acceleration_exponential_half_life_;
120120

121121
// Member functions
122-
PredictedPath generateStraightPath(const TrackedObject & object) const;
122+
PredictedPath generateStraightPath(const TrackedObject & object, const double duration) const;
123123

124124
PredictedPath generatePolynomialPath(
125-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
125+
const TrackedObject & object, const PosePath & ref_path, const double duration,
126+
const double lateral_duration, const double speed_limit = 0.0);
126127

127128
FrenetPath generateFrenetPath(
128-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length);
129+
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length,
130+
const double duration, const double lateral_duration);
129131
Eigen::Vector3d calcLatCoefficients(
130132
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T);
131133
Eigen::Vector2d calcLonCoefficients(
@@ -139,7 +141,8 @@ class PathGenerator
139141
const PosePath & ref_path);
140142

141143
FrenetPoint getFrenetPoint(
142-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
144+
const TrackedObject & object, const PosePath & ref_path, const double duration,
145+
const double speed_limit = 0.0);
143146
};
144147
} // namespace map_based_prediction
145148

perception/map_based_prediction/schema/map_based_prediction.schema.json

+17-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@
1212
"description": "flag to enable the time delay compensation for the position of the object"
1313
},
1414
"prediction_time_horizon": {
15-
"type": "number",
16-
"default": "10.0",
17-
"description": "predict time duration for predicted path"
15+
"properties": {
16+
"vehicle": {
17+
"type": "number",
18+
"default": "15.0",
19+
"description": "predict time duration for predicted path of vehicle"
20+
},
21+
"pedestrian": {
22+
"type": "number",
23+
"default": "10.0",
24+
"description": "predict time duration for predicted path of pedestrian"
25+
},
26+
"unknown": {
27+
"type": "number",
28+
"default": "10.0",
29+
"description": "predict time duration for predicted path of unknown"
30+
}
31+
}
1832
},
1933
"lateral_control_time_horizon": {
2034
"type": "number",

perception/map_based_prediction/src/map_based_prediction_node.cpp

+31-26
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,10 @@ MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_
720720
google::InstallFailureSignalHandler();
721721
}
722722
enable_delay_compensation_ = declare_parameter<bool>("enable_delay_compensation");
723-
prediction_time_horizon_ = declare_parameter<double>("prediction_time_horizon");
723+
prediction_time_horizon_.vehicle = declare_parameter<double>("prediction_time_horizon.vehicle");
724+
prediction_time_horizon_.pedestrian =
725+
declare_parameter<double>("prediction_time_horizon.pedestrian");
726+
prediction_time_horizon_.unknown = declare_parameter<double>("prediction_time_horizon.unknown");
724727
lateral_control_time_horizon_ =
725728
declare_parameter<double>("lateral_control_time_horizon"); // [s] for lateral control point
726729
prediction_sampling_time_interval_ = declare_parameter<double>("prediction_sampling_delta_time");
@@ -791,8 +794,7 @@ MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_
791794
"crosswalk_with_signal.timeout_set_for_no_intention_to_walk");
792795

793796
path_generator_ = std::make_shared<PathGenerator>(
794-
prediction_time_horizon_, lateral_control_time_horizon_, prediction_sampling_time_interval_,
795-
min_crosswalk_user_velocity_);
797+
prediction_sampling_time_interval_, min_crosswalk_user_velocity_);
796798

797799
path_generator_->setUseVehicleAcceleration(use_vehicle_acceleration_);
798800
path_generator_->setAccelerationHalfLife(acceleration_exponential_half_life_);
@@ -969,8 +971,8 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
969971

970972
// For off lane obstacles
971973
if (current_lanelets.empty()) {
972-
PredictedPath predicted_path =
973-
path_generator_->generatePathForOffLaneVehicle(transformed_object);
974+
PredictedPath predicted_path = path_generator_->generatePathForOffLaneVehicle(
975+
transformed_object, prediction_time_horizon_.vehicle);
974976
predicted_path.confidence = 1.0;
975977
if (predicted_path.path.empty()) break;
976978

@@ -985,8 +987,8 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
985987
transformed_object.kinematics.twist_with_covariance.twist.linear.x,
986988
transformed_object.kinematics.twist_with_covariance.twist.linear.y);
987989
if (std::fabs(abs_obj_speed) < min_velocity_for_map_based_prediction_) {
988-
PredictedPath predicted_path =
989-
path_generator_->generatePathForLowSpeedVehicle(transformed_object);
990+
PredictedPath predicted_path = path_generator_->generatePathForLowSpeedVehicle(
991+
transformed_object, prediction_time_horizon_.vehicle);
990992
predicted_path.confidence = 1.0;
991993
if (predicted_path.path.empty()) break;
992994

@@ -998,13 +1000,14 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
9981000

9991001
// Get Predicted Reference Path for Each Maneuver and current lanelets
10001002
// return: <probability, paths>
1001-
const auto ref_paths =
1002-
getPredictedReferencePath(transformed_object, current_lanelets, objects_detected_time);
1003+
const auto ref_paths = getPredictedReferencePath(
1004+
transformed_object, current_lanelets, objects_detected_time,
1005+
prediction_time_horizon_.vehicle);
10031006

10041007
// If predicted reference path is empty, assume this object is out of the lane
10051008
if (ref_paths.empty()) {
1006-
PredictedPath predicted_path =
1007-
path_generator_->generatePathForLowSpeedVehicle(transformed_object);
1009+
PredictedPath predicted_path = path_generator_->generatePathForLowSpeedVehicle(
1010+
transformed_object, prediction_time_horizon_.vehicle);
10081011
predicted_path.confidence = 1.0;
10091012
if (predicted_path.path.empty()) break;
10101013

@@ -1039,7 +1042,8 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
10391042

10401043
for (const auto & ref_path : ref_paths) {
10411044
PredictedPath predicted_path = path_generator_->generatePathForOnLaneVehicle(
1042-
yaw_fixed_transformed_object, ref_path.path, ref_path.speed_limit);
1045+
yaw_fixed_transformed_object, ref_path.path, prediction_time_horizon_.vehicle,
1046+
lateral_control_time_horizon_, ref_path.speed_limit);
10431047
if (predicted_path.path.empty()) continue;
10441048

10451049
if (!check_lateral_acceleration_constraints_) {
@@ -1102,8 +1106,8 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
11021106
}
11031107
default: {
11041108
auto predicted_unknown_object = convertToPredictedObject(transformed_object);
1105-
PredictedPath predicted_path =
1106-
path_generator_->generatePathForNonVehicleObject(transformed_object);
1109+
PredictedPath predicted_path = path_generator_->generatePathForNonVehicleObject(
1110+
transformed_object, prediction_time_horizon_.unknown);
11071111
predicted_path.confidence = 1.0;
11081112

11091113
predicted_unknown_object.kinematics.predicted_paths.push_back(predicted_path);
@@ -1170,7 +1174,8 @@ PredictedObject MapBasedPredictionNode::getPredictedObjectAsCrosswalkUser(
11701174
{
11711175
auto predicted_object = convertToPredictedObject(object);
11721176
{
1173-
PredictedPath predicted_path = path_generator_->generatePathForNonVehicleObject(object);
1177+
PredictedPath predicted_path =
1178+
path_generator_->generatePathForNonVehicleObject(object, prediction_time_horizon_.pedestrian);
11741179
predicted_path.confidence = 1.0;
11751180

11761181
predicted_object.kinematics.predicted_paths.push_back(predicted_path);
@@ -1221,7 +1226,7 @@ PredictedObject MapBasedPredictionNode::getPredictedObjectAsCrosswalkUser(
12211226

12221227
if (hasPotentialToReach(
12231228
object, edge_points.front_center_point, edge_points.front_right_point,
1224-
edge_points.front_left_point, prediction_time_horizon_ * 2.0,
1229+
edge_points.front_left_point, prediction_time_horizon_.pedestrian * 2.0,
12251230
min_crosswalk_user_velocity_, max_crosswalk_user_delta_yaw_threshold_for_lanelet_)) {
12261231
PredictedPath predicted_path =
12271232
path_generator_->generatePathToTargetPoint(object, edge_points.front_center_point);
@@ -1231,7 +1236,7 @@ PredictedObject MapBasedPredictionNode::getPredictedObjectAsCrosswalkUser(
12311236

12321237
if (hasPotentialToReach(
12331238
object, edge_points.back_center_point, edge_points.back_right_point,
1234-
edge_points.back_left_point, prediction_time_horizon_ * 2.0,
1239+
edge_points.back_left_point, prediction_time_horizon_.pedestrian * 2.0,
12351240
min_crosswalk_user_velocity_, max_crosswalk_user_delta_yaw_threshold_for_lanelet_)) {
12361241
PredictedPath predicted_path =
12371242
path_generator_->generatePathToTargetPoint(object, edge_points.back_center_point);
@@ -1255,27 +1260,27 @@ PredictedObject MapBasedPredictionNode::getPredictedObjectAsCrosswalkUser(
12551260

12561261
const auto reachable_first = hasPotentialToReach(
12571262
object, edge_points.front_center_point, edge_points.front_right_point,
1258-
edge_points.front_left_point, prediction_time_horizon_, min_crosswalk_user_velocity_,
1259-
max_crosswalk_user_delta_yaw_threshold_for_lanelet_);
1263+
edge_points.front_left_point, prediction_time_horizon_.pedestrian,
1264+
min_crosswalk_user_velocity_, max_crosswalk_user_delta_yaw_threshold_for_lanelet_);
12601265
const auto reachable_second = hasPotentialToReach(
12611266
object, edge_points.back_center_point, edge_points.back_right_point,
1262-
edge_points.back_left_point, prediction_time_horizon_, min_crosswalk_user_velocity_,
1263-
max_crosswalk_user_delta_yaw_threshold_for_lanelet_);
1267+
edge_points.back_left_point, prediction_time_horizon_.pedestrian,
1268+
min_crosswalk_user_velocity_, max_crosswalk_user_delta_yaw_threshold_for_lanelet_);
12641269

12651270
if (!reachable_first && !reachable_second) {
12661271
continue;
12671272
}
12681273

12691274
const auto reachable_crosswalk = isReachableCrosswalkEdgePoints(
1270-
object, crosswalk, edge_points, lanelet_map_ptr_, prediction_time_horizon_,
1275+
object, crosswalk, edge_points, lanelet_map_ptr_, prediction_time_horizon_.pedestrian,
12711276
min_crosswalk_user_velocity_);
12721277

12731278
if (!reachable_crosswalk) {
12741279
continue;
12751280
}
12761281

1277-
PredictedPath predicted_path =
1278-
path_generator_->generatePathForCrosswalkUser(object, reachable_crosswalk.get());
1282+
PredictedPath predicted_path = path_generator_->generatePathForCrosswalkUser(
1283+
object, reachable_crosswalk.get(), prediction_time_horizon_.pedestrian);
12791284
predicted_path.confidence = 1.0;
12801285

12811286
if (predicted_path.path.empty()) {
@@ -1613,7 +1618,7 @@ void MapBasedPredictionNode::updateObjectsHistory(
16131618

16141619
std::vector<PredictedRefPath> MapBasedPredictionNode::getPredictedReferencePath(
16151620
const TrackedObject & object, const LaneletsData & current_lanelets_data,
1616-
const double object_detected_time)
1621+
const double object_detected_time, const double time_horizon)
16171622
{
16181623
const double obj_vel = std::hypot(
16191624
object.kinematics.twist_with_covariance.twist.linear.x,
@@ -1625,7 +1630,7 @@ std::vector<PredictedRefPath> MapBasedPredictionNode::getPredictedReferencePath(
16251630
object.kinematics.acceleration_with_covariance.accel.linear.x,
16261631
object.kinematics.acceleration_with_covariance.accel.linear.y)
16271632
: 0.0;
1628-
const double t_h = prediction_time_horizon_;
1633+
const double t_h = time_horizon;
16291634
const double λ = std::log(2) / acceleration_exponential_half_life_;
16301635

16311636
auto get_search_distance_with_decaying_acc = [&]() -> double {

0 commit comments

Comments
 (0)