Skip to content

Commit

Permalink
refactor(lane_change): separate leading and trailing objects (autowar…
Browse files Browse the repository at this point in the history
…efoundation#8214)

* refactor(lane_change): separate leading and trailing objects

Signed-off-by: Muhammad Zulfaqar Azmi <[email protected]>

* Refactor to use common function

Signed-off-by: Zulfaqar Azmi <[email protected]>

---------

Signed-off-by: Muhammad Zulfaqar Azmi <[email protected]>
Signed-off-by: Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 authored and saka1-s committed Aug 15, 2024
1 parent ae8d7de commit 34aa590
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class NormalLaneChange : public LaneChangeBase
PathSafetyStatus evaluateApprovedPathWithUnsafeHysteresis(
PathSafetyStatus approved_path_safety_status) override;

bool isRequiredStop(const bool is_object_coming_from_rear) override;
bool isRequiredStop(const bool is_trailing_object) override;

bool isNearEndOfCurrentLanes(
const lanelet::ConstLanelets & current_lanes, const lanelet::ConstLanelets & target_lanes,
Expand Down Expand Up @@ -120,19 +120,16 @@ class NormalLaneChange : public LaneChangeBase
const lanelet::ConstLanelets & current_lanes,
const lanelet::ConstLanelets & target_lanes) const;

ExtendedPredictedObjects getTargetObjects(
const LaneChangeLanesFilteredObjects & predicted_objects,
lane_change::TargetObjects getTargetObjects(
const FilteredByLanesExtendedObjects & predicted_objects,
const lanelet::ConstLanelets & current_lanes) const;

LaneChangeLanesFilteredObjects filterObjects() const;
FilteredByLanesExtendedObjects filterObjects() const;

void filterOncomingObjects(PredictedObjects & objects) const;

void filterObjectsByLanelets(
const PredictedObjects & objects, const PathWithLaneId & current_lanes_ref_path,
std::vector<PredictedObject> & current_lane_objects,
std::vector<PredictedObject> & target_lane_objects,
std::vector<PredictedObject> & other_lane_objects) const;
FilteredByLanesObjects filterObjectsByLanelets(
const PredictedObjects & objects, const PathWithLaneId & current_lanes_ref_path) const;

PathWithLaneId getPrepareSegment(
const lanelet::ConstLanelets & current_lanes, const double backward_path_length,
Expand Down Expand Up @@ -170,7 +167,7 @@ class NormalLaneChange : public LaneChangeBase

PathSafetyStatus isLaneChangePathSafe(
const LaneChangePath & lane_change_path,
const ExtendedPredictedObjects & collision_check_objects,
const lane_change::TargetObjects & collision_check_objects,
const utils::path_safety_checker::RSSparams & rss_params,
CollisionCheckDebugMap & debug_data) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LaneChangeBase

virtual bool isEgoOnPreparePhase() const = 0;

virtual bool isRequiredStop(const bool is_object_coming_from_rear) = 0;
virtual bool isRequiredStop(const bool is_trailing_object) = 0;

virtual PathSafetyStatus isApprovedPathSafe() const = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,33 @@ struct Info
double terminal_lane_changing_velocity{0.0};
};

template <typename Object>
struct LanesObjects
{
ExtendedPredictedObjects current_lane{};
ExtendedPredictedObjects target_lane{};
ExtendedPredictedObjects other_lane{};
Object current_lane{};
Object target_lane_leading{};
Object target_lane_trailing{};
Object other_lane{};

LanesObjects() = default;
LanesObjects(
Object current_lane, Object target_lane_leading, Object target_lane_trailing, Object other_lane)
: current_lane(std::move(current_lane)),
target_lane_leading(std::move(target_lane_leading)),
target_lane_trailing(std::move(target_lane_trailing)),
other_lane(std::move(other_lane))
{
}
};

struct TargetObjects
{
ExtendedPredictedObjects leading;
ExtendedPredictedObjects trailing;
TargetObjects(ExtendedPredictedObjects leading, ExtendedPredictedObjects trailing)
: leading(std::move(leading)), trailing(std::move(trailing))
{
}
};

enum class ModuleType {
Expand All @@ -231,7 +253,13 @@ enum class ModuleType {
struct PathSafetyStatus
{
bool is_safe{true};
bool is_object_coming_from_rear{false};
bool is_trailing_object{false};

PathSafetyStatus() = default;
PathSafetyStatus(const bool is_safe, const bool is_trailing_object)
: is_safe(is_safe), is_trailing_object(is_trailing_object)
{
}
};

struct LanesPolygon
Expand Down Expand Up @@ -280,12 +308,15 @@ using CommonDataPtr = std::shared_ptr<CommonData>;

namespace autoware::behavior_path_planner
{
using autoware_perception_msgs::msg::PredictedObject;
using utils::path_safety_checker::ExtendedPredictedObjects;
using LaneChangeModuleType = lane_change::ModuleType;
using LaneChangeParameters = lane_change::Parameters;
using LaneChangeStates = lane_change::States;
using LaneChangePhaseInfo = lane_change::PhaseInfo;
using LaneChangeInfo = lane_change::Info;
using LaneChangeLanesFilteredObjects = lane_change::LanesObjects;
using FilteredByLanesObjects = lane_change::LanesObjects<std::vector<PredictedObject>>;
using FilteredByLanesExtendedObjects = lane_change::LanesObjects<ExtendedPredictedObjects>;
using LateralAccelerationMap = lane_change::LateralAccelerationMap;
} // namespace autoware::behavior_path_planner

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct Debug
LaneChangePaths valid_paths;
CollisionCheckDebugMap collision_check_objects;
CollisionCheckDebugMap collision_check_objects_after_approval;
LaneChangeLanesFilteredObjects filtered_objects;
FilteredByLanesExtendedObjects filtered_objects;
geometry_msgs::msg::Polygon execution_area;
geometry_msgs::msg::Pose ego_pose;
lanelet::ConstLanelets current_lanes;
Expand All @@ -55,7 +55,8 @@ struct Debug
collision_check_objects.clear();
collision_check_objects_after_approval.clear();
filtered_objects.current_lane.clear();
filtered_objects.target_lane.clear();
filtered_objects.target_lane_leading.clear();
filtered_objects.target_lane_trailing.clear();
filtered_objects.other_lane.clear();
execution_area.points.clear();
current_lanes.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace marker_utils::lane_change_markers
{
using autoware::behavior_path_planner::FilteredByLanesExtendedObjects;
using autoware::behavior_path_planner::LaneChangePath;
using autoware::behavior_path_planner::lane_change::Debug;
using autoware::behavior_path_planner::utils::path_safety_checker::ExtendedPredictedObjects;
Expand All @@ -39,9 +40,7 @@ MarkerArray createLaneChangingVirtualWallMarker(
const geometry_msgs::msg::Pose & lane_changing_pose, const std::string & module_name,
const rclcpp::Time & now, const std::string & ns);
MarkerArray showFilteredObjects(
const ExtendedPredictedObjects & current_lane_objects,
const ExtendedPredictedObjects & target_lane_objects,
const ExtendedPredictedObjects & other_lane_objects, const std::string & ns);
const FilteredByLanesExtendedObjects & filtered_objects, const std::string & ns);
MarkerArray createExecutionArea(const geometry_msgs::msg::Polygon & execution_area);
MarkerArray showExecutionInfo(const Debug & debug_data, const geometry_msgs::msg::Pose & ego_pose);
MarkerArray createDebugMarkerArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ bool is_before_terminal(
const PredictedObject & object);

double calc_angle_to_lanelet_segment(const lanelet::ConstLanelets & lanelets, const Pose & pose);

ExtendedPredictedObjects transform_to_extended_objects(
const CommonDataPtr & common_data_ptr, const std::vector<PredictedObject> & objects,
const bool check_prepare_phase);
} // namespace autoware::behavior_path_planner::utils::lane_change

namespace autoware::behavior_path_planner::utils::lane_change::debug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ bool LaneChangeInterface::canTransitFailureState()
return false;
}

if (module_type_->isRequiredStop(post_process_safety_status_.is_object_coming_from_rear)) {
if (module_type_->isRequiredStop(post_process_safety_status_.is_trailing_object)) {
log_debug_throttled("Module require stopping");
}

Expand Down
Loading

0 comments on commit 34aa590

Please sign in to comment.