@@ -93,6 +93,27 @@ void ObjectInfo::update_safety(
93
93
safe_under_traffic_control_ = safe_under_traffic_control;
94
94
}
95
95
96
+ std::optional<geometry_msgs::msg::Point > ObjectInfo::estimated_past_position (
97
+ const double past_duration) const
98
+ {
99
+ if (!attention_lanelet_opt) {
100
+ return std::nullopt;
101
+ }
102
+ const auto attention_lanelet = attention_lanelet_opt.value ();
103
+ const auto current_arc_coords = lanelet::utils::getArcCoordinates (
104
+ {attention_lanelet}, predicted_object_.kinematics .initial_pose_with_covariance .pose );
105
+ const auto distance = current_arc_coords.distance ;
106
+ const auto past_length =
107
+ current_arc_coords.length -
108
+ predicted_object_.kinematics .initial_twist_with_covariance .twist .linear .x * past_duration;
109
+ const auto past_point = lanelet::geometry::fromArcCoordinates (
110
+ attention_lanelet.centerline2d (), lanelet::ArcCoordinates{past_length, distance});
111
+ geometry_msgs::msg::Point past_position;
112
+ past_position.x = past_point.x ();
113
+ past_position.y = past_point.y ();
114
+ return std::make_optional (past_position);
115
+ }
116
+
96
117
void ObjectInfo::calc_dist_to_stopline ()
97
118
{
98
119
if (!stopline_opt || !attention_lanelet_opt) {
@@ -233,7 +254,7 @@ std::optional<intersection::CollisionInterval> findPassageInterval(
233
254
const autoware_auto_perception_msgs::msg::Shape & shape,
234
255
const lanelet::BasicPolygon2d & ego_lane_poly,
235
256
const std::optional<lanelet::ConstLanelet> & first_attention_lane_opt,
236
- [[maybe_unused]] const std::optional<lanelet::ConstLanelet> & second_attention_lane_opt)
257
+ const std::optional<lanelet::ConstLanelet> & second_attention_lane_opt)
237
258
{
238
259
const auto first_itr = std::adjacent_find (
239
260
predicted_path.path .cbegin (), predicted_path.path .cend (), [&](const auto & a, const auto & b) {
@@ -259,26 +280,30 @@ std::optional<intersection::CollisionInterval> findPassageInterval(
259
280
const size_t exit_idx = std::distance (predicted_path.path .begin (), last_itr.base ()) - 1 ;
260
281
const double object_exit_time =
261
282
static_cast <double >(exit_idx) * rclcpp::Duration (predicted_path.time_step ).seconds ();
262
- const auto [lane_position, lane_id] =
263
- [&]() -> std::pair<intersection::CollisionInterval::LanePosition, lanelet::Id> {
283
+ const auto lane_position = [&]() {
264
284
if (first_attention_lane_opt) {
265
285
if (lanelet::geometry::inside (
266
286
first_attention_lane_opt.value (),
267
287
lanelet::BasicPoint2d (first_itr->position .x , first_itr->position .y ))) {
268
- return std::make_pair (
269
- intersection::CollisionInterval::LanePosition::FIRST,
270
- first_attention_lane_opt.value ().id ());
288
+ return intersection::CollisionInterval::LanePosition::FIRST;
289
+ }
290
+ }
291
+ if (second_attention_lane_opt) {
292
+ if (lanelet::geometry::inside (
293
+ second_attention_lane_opt.value (),
294
+ lanelet::BasicPoint2d (first_itr->position .x , first_itr->position .y ))) {
295
+ return intersection::CollisionInterval::LanePosition::SECOND;
271
296
}
272
297
}
273
- return std::make_pair ( intersection::CollisionInterval::LanePosition::ELSE, lanelet::InvalId) ;
298
+ return intersection::CollisionInterval::LanePosition::ELSE;
274
299
}();
275
300
276
301
std::vector<geometry_msgs::msg::Pose> path;
277
302
for (const auto & pose : predicted_path.path ) {
278
303
path.push_back (pose);
279
304
}
280
305
return intersection::CollisionInterval{
281
- lane_position, lane_id, path, {enter_idx, exit_idx}, {object_enter_time, object_exit_time}};
306
+ lane_position, path, {enter_idx, exit_idx}, {object_enter_time, object_exit_time}};
282
307
}
283
308
284
309
} // namespace behavior_velocity_planner::intersection
0 commit comments