Skip to content

Commit

Permalink
fix(bpp): use common steering factor interface for same scene modules (
Browse files Browse the repository at this point in the history
…autowarefoundation#8675)

Signed-off-by: satoshi-ota <[email protected]>
Signed-off-by: Batuhan Beytekin <[email protected]>
  • Loading branch information
satoshi-ota authored and batuhanbeytekin committed Sep 2, 2024
1 parent 034a0d7 commit c34983e
Show file tree
Hide file tree
Showing 27 changed files with 60 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ AvoidanceByLaneChangeInterface::AvoidanceByLaneChangeInterface(
const std::shared_ptr<AvoidanceByLCParameters> & avoidance_by_lane_change_parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: LaneChangeInterface{
name,
node,
parameters,
rtc_interface_ptr_map,
objects_of_interest_marker_interface_ptr_map,
steering_factor_interface_ptr,
std::make_unique<AvoidanceByLaneChange>(parameters, avoidance_by_lane_change_parameters)}
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class AvoidanceByLaneChangeInterface : public LaneChangeInterface
const std::shared_ptr<AvoidanceByLCParameters> & avoidance_by_lane_change_parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

bool isExecutionRequested() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ AvoidanceByLaneChangeModuleManager::createNewSceneModuleInstance()
{
return std::make_unique<AvoidanceByLaneChangeInterface>(
name_, *node_, parameters_, avoidance_parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

} // namespace autoware::behavior_path_planner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DynamicObstacleAvoidanceModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<DynamicObstacleAvoidanceModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(const std::vector<rclcpp::Parameter> & parameters) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ class DynamicObstacleAvoidanceModule : public SceneModuleInterface
std::shared_ptr<DynamicAvoidanceParameters> parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

void updateModuleParams(const std::any & parameters) override
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ DynamicObstacleAvoidanceModule::DynamicObstacleAvoidanceModule(
std::shared_ptr<DynamicAvoidanceParameters> parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
parameters_{std::move(parameters)},
target_objects_manager_{TargetObjectsManager(
parameters_->successive_num_to_entry_dynamic_avoidance_condition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ExternalRequestLaneChangeRightModuleManager::createNewSceneModuleInstance()
{
return std::make_unique<LaneChangeInterface>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_,
std::make_unique<ExternalRequestLaneChange>(parameters_, direction_));
}

Expand All @@ -35,7 +35,7 @@ ExternalRequestLaneChangeLeftModuleManager::createNewSceneModuleInstance()
{
return std::make_unique<LaneChangeInterface>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_,
std::make_unique<ExternalRequestLaneChange>(parameters_, direction_));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ class GoalPlannerModule : public SceneModuleInterface
const std::shared_ptr<GoalPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

~GoalPlannerModule()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GoalPlannerModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<GoalPlannerModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(const std::vector<rclcpp::Parameter> & parameters) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ GoalPlannerModule::GoalPlannerModule(
const std::shared_ptr<GoalPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
parameters_{parameters},
vehicle_info_{autoware::vehicle_info_utils::VehicleInfoUtils(node).getVehicleInfo()},
thread_safe_data_{mutex_, clock_},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class LaneChangeInterface : public SceneModuleInterface
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr,
std::unique_ptr<LaneChangeBase> && module_type);

LaneChangeInterface(const LaneChangeInterface &) = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ LaneChangeInterface::LaneChangeInterface(
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr,
std::unique_ptr<LaneChangeBase> && module_type)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
parameters_{std::move(parameters)},
module_type_{std::move(module_type)},
prev_approved_path_{std::make_unique<PathWithLaneId>()}
{
module_type_->setTimeKeeper(getTimeKeeper());
steering_factor_interface_ptr_ = std::make_unique<SteeringFactorInterface>(&node, name);
logger_ = utils::lane_change::getLogger(module_type_->getModuleTypeStr());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ std::unique_ptr<SceneModuleInterface> LaneChangeModuleManager::createNewSceneMod
{
return std::make_unique<LaneChangeInterface>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_,
std::make_unique<NormalLaneChange>(parameters_, LaneChangeModuleType::NORMAL, direction_));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class SceneModuleInterface
const std::string & name, rclcpp::Node & node,
std::unordered_map<std::string, std::shared_ptr<RTCInterface>> rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>>
objects_of_interest_marker_interface_ptr_map)
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: name_{name},
logger_{node.get_logger().get_child(name)},
clock_{node.get_clock()},
rtc_interface_ptr_map_(std::move(rtc_interface_ptr_map)),
objects_of_interest_marker_interface_ptr_map_(
std::move(objects_of_interest_marker_interface_ptr_map)),
steering_factor_interface_ptr_(
std::make_unique<SteeringFactorInterface>(&node, utils::convertToSnakeCase(name))),
steering_factor_interface_ptr_{steering_factor_interface_ptr},
time_keeper_(std::make_shared<universe_utils::TimeKeeper>())
{
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
Expand Down Expand Up @@ -640,7 +640,7 @@ class SceneModuleInterface
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>>
objects_of_interest_marker_interface_ptr_map_;

std::unique_ptr<SteeringFactorInterface> steering_factor_interface_ptr_;
std::shared_ptr<SteeringFactorInterface> steering_factor_interface_ptr_;

mutable std::optional<Pose> stop_pose_{std::nullopt};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ class SceneModuleManagerInterface
"~/processing_time/" + name_, 20);
}

// init steering factor
{
steering_factor_interface_ptr_ =
std::make_shared<SteeringFactorInterface>(node, utils::convertToSnakeCase(name_));
}

// misc
{
node_ = node;
Expand All @@ -322,6 +328,8 @@ class SceneModuleManagerInterface

std::shared_ptr<PlannerData> planner_data_;

std::shared_ptr<SteeringFactorInterface> steering_factor_interface_ptr_;

std::vector<SceneModuleObserver> observers_;

std::unique_ptr<SceneModuleInterface> idle_module_ptr_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SamplingPlannerModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<SamplingPlannerModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class SamplingPlannerModule : public SceneModuleInterface
const std::shared_ptr<SamplingPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

bool isExecutionRequested() const override;
bool isExecutionReady() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ SamplingPlannerModule::SamplingPlannerModule(
const std::shared_ptr<SamplingPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
vehicle_info_{autoware::vehicle_info_utils::VehicleInfoUtils(node).getVehicleInfo()}
{
internal_params_ = std::make_shared<SamplingPlannerInternalParameters>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SideShiftModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<SideShiftModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(const std::vector<rclcpp::Parameter> & parameters) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class SideShiftModule : public SceneModuleInterface
const std::shared_ptr<SideShiftParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

bool isExecutionRequested() const override;
bool isExecutionReady() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ SideShiftModule::SideShiftModule(
const std::shared_ptr<SideShiftParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
parameters_{parameters}
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StartPlannerModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<StartPlannerModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(const std::vector<rclcpp::Parameter> & parameters) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class StartPlannerModule : public SceneModuleInterface
const std::shared_ptr<StartPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

~StartPlannerModule() override
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ StartPlannerModule::StartPlannerModule(
const std::shared_ptr<StartPlannerParameters> & parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
parameters_{parameters},
vehicle_info_{autoware::vehicle_info_utils::VehicleInfoUtils(node).getVehicleInfo()},
is_freespace_planner_cb_running_{false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class StaticObstacleAvoidanceModuleManager : public SceneModuleManagerInterface
{
return std::make_unique<StaticObstacleAvoidanceModule>(
name_, *node_, parameters_, rtc_interface_ptr_map_,
objects_of_interest_marker_interface_ptr_map_);
objects_of_interest_marker_interface_ptr_map_, steering_factor_interface_ptr_);
}

void updateModuleParams(const std::vector<rclcpp::Parameter> & parameters) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class StaticObstacleAvoidanceModule : public SceneModuleInterface
const std::string & name, rclcpp::Node & node, std::shared_ptr<AvoidanceParameters> parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map);
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr);

CandidateOutput planCandidate() const override;
BehaviorModuleOutput plan() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ StaticObstacleAvoidanceModule::StaticObstacleAvoidanceModule(
const std::string & name, rclcpp::Node & node, std::shared_ptr<AvoidanceParameters> parameters,
const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map,
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
objects_of_interest_marker_interface_ptr_map)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
objects_of_interest_marker_interface_ptr_map,
std::shared_ptr<SteeringFactorInterface> & steering_factor_interface_ptr)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map, steering_factor_interface_ptr}, // NOLINT
helper_{std::make_shared<AvoidanceHelper>(parameters)},
parameters_{parameters},
generator_{parameters}
Expand Down

0 comments on commit c34983e

Please sign in to comment.