Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 9, 2023
1 parent 1a8d8e6 commit 0becf24
Showing 1 changed file with 32 additions and 40 deletions.
72 changes: 32 additions & 40 deletions planning/obstacle_stop_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,14 +867,11 @@ void ObstacleStopPlannerNode::searchPredictedObject(
bool is_init = false;
size_t nearest_collision_object_index = 0;

for (size_t j = 0; j < predicted_object_history_.size(); ++j)
{
for (size_t j = 0; j < predicted_object_history_.size(); ++j) {
// check new collision points
const auto& obj = predicted_object_history_.at(j).object;
if (node_param_.enable_z_axis_obstacle_filtering)
{
if (!intersectsInZAxis(obj, z_axis_min, z_axis_max))
{
const auto & obj = predicted_object_history_.at(j).object;
if (node_param_.enable_z_axis_obstacle_filtering) {
if (!intersectsInZAxis(obj, z_axis_min, z_axis_max)) {
continue;
}
}
Expand All @@ -883,42 +880,37 @@ void ObstacleStopPlannerNode::searchPredictedObject(
// collision_point.x() = predicted_object_history_.at(j).point.x;
// collision_point.y() = predicted_object_history_.at(j).point.y;
Polygon2d one_step_move_vehicle_polygon;
if (obj.shape.type == tractor_perception_msgs::msg::Shape::CYLINDER)
{
object_polygon =
convertCylindricalObjectToGeometryPolygon(obj.kinematics.initial_pose_with_covariance.pose, obj.shape);
createOneStepPolygon(p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.pedestrian_lateral_margin);
}
else if (obj.shape.type == tractor_perception_msgs::msg::Shape::BOUNDING_BOX)
{
const double& length_m = obj.shape.dimensions.x / 2;
const double& width_m = obj.shape.dimensions.y / 2;
object_polygon = convertBoundingBoxObjectToGeometryPolygon(obj.kinematics.initial_pose_with_covariance.pose,
length_m, length_m, width_m);
createOneStepPolygon(p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.vehicle_lateral_margin);
}
else if (obj.shape.type == tractor_perception_msgs::msg::Shape::POLYGON)
{
object_polygon =
convertPolygonObjectToGeometryPolygon(obj.kinematics.initial_pose_with_covariance.pose, obj.shape);
createOneStepPolygon(p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.unknown_lateral_margin);
}
else
{
RCLCPP_WARN_THROTTLE(get_logger(), *get_clock(), 3000, "Object type is not supported. type: %d",
obj.shape.type);
if (obj.shape.type == tractor_perception_msgs::msg::Shape::CYLINDER) {
object_polygon = convertCylindricalObjectToGeometryPolygon(
obj.kinematics.initial_pose_with_covariance.pose, obj.shape);
createOneStepPolygon(
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.pedestrian_lateral_margin);
} else if (obj.shape.type == tractor_perception_msgs::msg::Shape::BOUNDING_BOX) {
const double & length_m = obj.shape.dimensions.x / 2;
const double & width_m = obj.shape.dimensions.y / 2;
object_polygon = convertBoundingBoxObjectToGeometryPolygon(
obj.kinematics.initial_pose_with_covariance.pose, length_m, length_m, width_m);
createOneStepPolygon(
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.vehicle_lateral_margin);
} else if (obj.shape.type == tractor_perception_msgs::msg::Shape::POLYGON) {
object_polygon = convertPolygonObjectToGeometryPolygon(
obj.kinematics.initial_pose_with_covariance.pose, obj.shape);
createOneStepPolygon(
p_front, p_back, one_step_move_vehicle_polygon, vehicle_info,
stop_param.unknown_lateral_margin);
} else {
RCLCPP_WARN_THROTTLE(
get_logger(), *get_clock(), 3000, "Object type is not supported. type: %d",
obj.shape.type);
continue;
}
if (bg::intersects(one_step_move_vehicle_polygon, object_polygon))
{
if (bg::intersects(one_step_move_vehicle_polygon, object_polygon)) {

Check warning on line 909 in planning/obstacle_stop_planner/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

ObstacleStopPlannerNode::searchPredictedObject already has high cyclomatic complexity, and now it increases in Lines of Code from 343 to 349. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
const double norm = calcDistance2d(predicted_object_history_.at(j).point, p_front.position);
if (norm < min_collision_norm || !is_init)
{
min_collision_norm = norm;
is_init = true;
if (norm < min_collision_norm || !is_init) {
min_collision_norm = norm;
is_init = true;
nearest_collision_object_index = j;
}
}
Expand Down

0 comments on commit 0becf24

Please sign in to comment.