Skip to content

Commit

Permalink
fix(autoware_behavior_path_avoidance_by_lane_change_module): fix clan…
Browse files Browse the repository at this point in the history
…g-tidy issues

Signed-off-by: Esteve Fernandez <[email protected]>
  • Loading branch information
esteve committed Apr 12, 2024
1 parent 4fac342 commit 27264d2
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

#include "behavior_path_avoidance_module/data_structs.hpp"

namespace autoware
namespace autoware::behavior_path_planner
{
namespace behavior_path_planner
{
using ::behavior_path_planner::DebugData;
using ::behavior_path_planner::AvoidanceParameters;

struct AvoidanceByLCParameters : public ::behavior_path_planner::AvoidanceParameters
struct AvoidanceByLCParameters : public AvoidanceParameters
{
// execute only when the target object longitudinal distance is larger than this param.
double execute_object_longitudinal_margin{0.0};
Expand All @@ -34,7 +32,6 @@ struct AvoidanceByLCParameters : public ::behavior_path_planner::AvoidanceParame
{
}
};
} // namespace behavior_path_planner
} // namespace autoware
} // namespace autoware::behavior_path_planner

#endif // BEHAVIOR_PATH_AVOIDANCE_BY_LANE_CHANGE_MODULE__DATA_STRUCTS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
#include <string>
#include <unordered_map>

namespace autoware
namespace autoware::behavior_path_planner
{
namespace behavior_path_planner
{
using ::behavior_path_planner::Direction;
using ::behavior_path_planner::LaneChangeInterface;
using ::behavior_path_planner::ObjectsOfInterestMarkerInterface;
using ::behavior_path_planner::RTCInterface;
Expand All @@ -52,7 +49,6 @@ class AvoidanceByLaneChangeInterface : public LaneChangeInterface
protected:
void updateRTCStatus(const double start_distance, const double finish_distance) override;
};
} // namespace behavior_path_planner
} // namespace autoware
} // namespace autoware::behavior_path_planner

#endif // BEHAVIOR_PATH_AVOIDANCE_BY_LANE_CHANGE_MODULE__INTERFACE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
#include <unordered_map>
#include <vector>

namespace autoware
namespace autoware::behavior_path_planner
{
namespace behavior_path_planner
{
using ::behavior_path_planner::AvoidancePlanningData;
using ::behavior_path_planner::LaneChangeModuleManager;
using ::behavior_path_planner::LaneChangeModuleType;
using ::behavior_path_planner::ObjectParameter;
using ::behavior_path_planner::SceneModuleInterface;
using ::behavior_path_planner::SceneModuleManagerInterface;
using ::route_handler::Direction;

class AvoidanceByLaneChangeModuleManager : public LaneChangeModuleManager
{
Expand All @@ -55,7 +49,6 @@ class AvoidanceByLaneChangeModuleManager : public LaneChangeModuleManager
private:
std::shared_ptr<AvoidanceByLCParameters> avoidance_parameters_;
};
} // namespace behavior_path_planner
} // namespace autoware
} // namespace autoware::behavior_path_planner

#endif // BEHAVIOR_PATH_AVOIDANCE_BY_LANE_CHANGE_MODULE__MANAGER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,24 @@

#include <memory>

namespace autoware
namespace autoware::behavior_path_planner
{
namespace behavior_path_planner
{
using ::behavior_path_planner::AvoidanceParameters;
using ::route_handler::Direction;
using ::behavior_path_planner::DebugData;
using AvoidanceDebugData = DebugData;
using ::behavior_path_planner::AvoidancePlanningData;
using ::behavior_path_planner::LaneChangeModuleType;
using ::behavior_path_planner::LaneChangeParameters;
using ::behavior_path_planner::ObjectData;
using ::behavior_path_planner::ObjectDataArray;
using ::behavior_path_planner::Point2d;
using ::behavior_path_planner::PredictedObject;
using ::behavior_path_planner::helper::avoidance::AvoidanceHelper;
using ::behavior_path_planner::NormalLaneChange;

class AvoidanceByLaneChange : public ::behavior_path_planner::NormalLaneChange
class AvoidanceByLaneChange : public NormalLaneChange
{
public:
AvoidanceByLaneChange(
const std::shared_ptr<LaneChangeParameters> & parameters,
std::shared_ptr<AvoidanceByLCParameters> avoidance_by_lane_change_parameters);
std::shared_ptr<AvoidanceByLCParameters> avoidance_parameters);

bool specialRequiredCheck() const override;

Expand All @@ -53,24 +49,23 @@ class AvoidanceByLaneChange : public ::behavior_path_planner::NormalLaneChange
private:
std::shared_ptr<AvoidanceByLCParameters> avoidance_parameters_;

AvoidancePlanningData calcAvoidancePlanningData(AvoidanceDebugData & debug) const;
AvoidancePlanningData calc_avoidance_planning_data(AvoidanceDebugData & debug) const;
AvoidancePlanningData avoidance_data_;
mutable AvoidanceDebugData avoidance_debug_data_;

ObjectDataArray registered_objects_;
mutable ObjectDataArray stopped_objects_;
std::shared_ptr<AvoidanceHelper> avoidance_helper_;

std::optional<ObjectData> createObjectData(
std::optional<ObjectData> create_object_data(
const AvoidancePlanningData & data, const PredictedObject & object) const;

void fillAvoidanceTargetObjects(AvoidancePlanningData & data, AvoidanceDebugData & debug) const;
void fill_avoidance_target_objects(AvoidancePlanningData & data, AvoidanceDebugData & debug) const;

double calcMinAvoidanceLength(const ObjectData & nearest_object) const;
double calcMinimumLaneChangeLength() const;
double calcLateralOffset() const;
double calc_min_avoidance_length(const ObjectData & nearest_object) const;
double calc_minimum_lane_change_length() const;
double calc_lateral_offset() const;
};
} // namespace behavior_path_planner
} // namespace autoware
} // namespace autoware::behavior_path_planner

#endif // BEHAVIOR_PATH_AVOIDANCE_BY_LANE_CHANGE_MODULE__SCENE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace autoware::behavior_path_planner
{
using ::route_handler::Direction;

AvoidanceByLaneChangeInterface::AvoidanceByLaneChangeInterface(
const std::string & name, rclcpp::Node & node,
const std::shared_ptr<LaneChangeParameters> & parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

namespace autoware::behavior_path_planner
{
using ::behavior_path_planner::ObjectParameter;

void AvoidanceByLaneChangeModuleManager::init(rclcpp::Node * node)
{
using autoware_auto_perception_msgs::msg::ObjectClassification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
namespace autoware::behavior_path_planner
{
using ::behavior_path_planner::utils::lane_change::debug::createExecutionArea;
using ::route_handler::Direction;
using ::behavior_path_planner::LaneChangeModuleType;
using ::behavior_path_planner::Point2d;

AvoidanceByLaneChange::AvoidanceByLaneChange(
const std::shared_ptr<LaneChangeParameters> & parameters,
Expand Down Expand Up @@ -76,12 +79,12 @@ bool AvoidanceByLaneChange::specialRequiredCheck() const
}

const auto & nearest_object = data.target_objects.front();
const auto minimum_avoid_length = calcMinAvoidanceLength(nearest_object);
const auto minimum_lane_change_length = calcMinimumLaneChangeLength();
const auto minimum_avoid_length = calc_min_avoidance_length(nearest_object);
const auto minimum_lane_change_length = calc_minimum_lane_change_length();

lane_change_debug_.execution_area = createExecutionArea(
getCommonParam().vehicle_info, getEgoPose(),
std::max(minimum_lane_change_length, minimum_avoid_length), calcLateralOffset());
std::max(minimum_lane_change_length, minimum_avoid_length), calc_lateral_offset());

RCLCPP_DEBUG(
logger_, "Conditions ? %f, %f, %f", nearest_object.longitudinal, minimum_lane_change_length,
Expand All @@ -99,7 +102,7 @@ void AvoidanceByLaneChange::updateSpecialData()
const auto p = std::dynamic_pointer_cast<AvoidanceParameters>(avoidance_parameters_);

avoidance_debug_data_ = DebugData();
avoidance_data_ = calcAvoidancePlanningData(avoidance_debug_data_);
avoidance_data_ = calc_avoidance_planning_data(avoidance_debug_data_);

if (avoidance_data_.target_objects.empty()) {
direction_ = Direction::NONE;
Expand All @@ -120,7 +123,7 @@ void AvoidanceByLaneChange::updateSpecialData()
[](auto a, auto b) { return a.longitudinal < b.longitudinal; });
}

AvoidancePlanningData AvoidanceByLaneChange::calcAvoidancePlanningData(
AvoidancePlanningData AvoidanceByLaneChange::calc_avoidance_planning_data(
AvoidanceDebugData & debug) const
{
AvoidancePlanningData data;
Expand All @@ -136,12 +139,12 @@ AvoidancePlanningData AvoidanceByLaneChange::calcAvoidancePlanningData(

data.current_lanelets = getCurrentLanes();

fillAvoidanceTargetObjects(data, debug);
fill_avoidance_target_objects(data, debug);

return data;
}

void AvoidanceByLaneChange::fillAvoidanceTargetObjects(
void AvoidanceByLaneChange::fill_avoidance_target_objects(
AvoidancePlanningData & data, [[maybe_unused]] DebugData & debug) const
{
const auto p = std::dynamic_pointer_cast<AvoidanceParameters>(avoidance_parameters_);
Expand Down Expand Up @@ -176,7 +179,7 @@ void AvoidanceByLaneChange::fillAvoidanceTargetObjects(
ObjectDataArray target_lane_objects;
target_lane_objects.reserve(object_within_target_lane.objects.size());
for (const auto & obj : object_within_target_lane.objects) {
const auto target_lane_object = createObjectData(data, obj);
const auto target_lane_object = create_object_data(data, obj);
if (!target_lane_object) {
continue;
}
Expand All @@ -187,7 +190,7 @@ void AvoidanceByLaneChange::fillAvoidanceTargetObjects(
data.target_objects = target_lane_objects;
}

std::optional<ObjectData> AvoidanceByLaneChange::createObjectData(
std::optional<ObjectData> AvoidanceByLaneChange::create_object_data(
const AvoidancePlanningData & data, const PredictedObject & object) const
{
using boost::geometry::return_centroid;
Expand Down Expand Up @@ -252,7 +255,7 @@ std::optional<ObjectData> AvoidanceByLaneChange::createObjectData(
return object_data;
}

double AvoidanceByLaneChange::calcMinAvoidanceLength(const ObjectData & nearest_object) const
double AvoidanceByLaneChange::calc_min_avoidance_length(const ObjectData & nearest_object) const
{
const auto ego_width = getCommonParam().vehicle_width;
const auto nearest_object_type =
Expand All @@ -273,7 +276,7 @@ double AvoidanceByLaneChange::calcMinAvoidanceLength(const ObjectData & nearest_
return avoidance_helper_->getMinAvoidanceDistance(shift_length);
}

double AvoidanceByLaneChange::calcMinimumLaneChangeLength() const
double AvoidanceByLaneChange::calc_minimum_lane_change_length() const
{
const auto current_lanes = getCurrentLanes();
if (current_lanes.empty()) {
Expand All @@ -289,7 +292,7 @@ double AvoidanceByLaneChange::calcMinimumLaneChangeLength() const
lane_change_parameters_->backward_length_buffer_for_end_of_lane);
}

double AvoidanceByLaneChange::calcLateralOffset() const
double AvoidanceByLaneChange::calc_lateral_offset() const
{
auto additional_lat_offset{0.0};
for (const auto & [type, p] : avoidance_parameters_->object_parameters) {
Expand Down

0 comments on commit 27264d2

Please sign in to comment.