Skip to content

Commit 99906b7

Browse files
style(pre-commit): autofix
1 parent 1ae1873 commit 99906b7

File tree

6 files changed

+139
-150
lines changed

6 files changed

+139
-150
lines changed

planning/static_centerline_generator/include/static_centerline_generator/centerline_source/optimization_trajectory_based_centerline.hpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef \
16-
STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_ // NOLINT
17-
#define \
18-
STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_ // NOLINT
15+
#ifndef STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_
16+
STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_ // NOLINT
17+
#define STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_
18+
STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_ // NOLINT
1919

2020
#include "rclcpp/rclcpp.hpp"
2121
#include "route_handler/route_handler.hpp"
@@ -27,27 +27,27 @@
2727

2828
#include <vector>
2929

30-
namespace autoware::static_centerline_generator
30+
namespace autoware::static_centerline_generator
3131
{
32-
using ::autoware_auto_planning_msgs::msg::Path;
33-
using ::autoware_auto_planning_msgs::msg::PathWithLaneId;
34-
using ::autoware_auto_planning_msgs::msg::TrajectoryPoint;
35-
using ::route_handler::RouteHandler;
36-
class OptimizationTrajectoryBasedCenterline
37-
{
38-
public:
39-
OptimizationTrajectoryBasedCenterline() = default;
40-
explicit OptimizationTrajectoryBasedCenterline(rclcpp::Node & node);
41-
std::vector<TrajectoryPoint> generate_centerline_with_optimization(
42-
rclcpp::Node & node, const RouteHandler & route_handler,
43-
const std::vector<lanelet::Id> & route_lane_ids);
32+
using ::autoware_auto_planning_msgs::msg::Path;
33+
using ::autoware_auto_planning_msgs::msg::PathWithLaneId;
34+
using ::autoware_auto_planning_msgs::msg::TrajectoryPoint;
35+
using ::route_handler::RouteHandler;
36+
class OptimizationTrajectoryBasedCenterline
37+
{
38+
public:
39+
OptimizationTrajectoryBasedCenterline() = default;
40+
explicit OptimizationTrajectoryBasedCenterline(rclcpp::Node & node);
41+
std::vector<TrajectoryPoint> generate_centerline_with_optimization(
42+
rclcpp::Node & node, const RouteHandler & route_handler,
43+
const std::vector<lanelet::Id> & route_lane_ids);
4444

45-
private:
46-
[[nodiscard]] static std::vector<TrajectoryPoint> optimize_trajectory(const Path & raw_path);
45+
private:
46+
[[nodiscard]] static std::vector<TrajectoryPoint> optimize_trajectory(const Path & raw_path);
4747

48-
rclcpp::Publisher<PathWithLaneId>::SharedPtr pub_raw_path_with_lane_id_{nullptr};
49-
rclcpp::Publisher<Path>::SharedPtr pub_raw_path_{nullptr};
50-
};
48+
rclcpp::Publisher<PathWithLaneId>::SharedPtr pub_raw_path_with_lane_id_{nullptr};
49+
rclcpp::Publisher<Path>::SharedPtr pub_raw_path_{nullptr};
50+
};
5151
} // namespace autoware::static_centerline_generator
5252
// clang-format off
5353
#endif // STATIC_CENTERLINE_GENERATOR__CENTERLINE_SOURCE__OPTIMIZATION_TRAJECTORY_BASED_CENTERLINE_HPP_ // NOLINT

planning/static_centerline_generator/include/static_centerline_generator/static_centerline_generator_node.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#include "autoware_static_centerline_generator/srv/plan_path.hpp"
2020
#include "autoware_static_centerline_generator/srv/plan_route.hpp"
2121
#include "rclcpp/rclcpp.hpp"
22-
#include \
23-
"static_centerline_generator/centerline_source/optimization_trajectory_based_centerline.hpp"
22+
#include "static_centerline_generator/centerline_source/optimization_trajectory_based_centerline.hpp"
2423
#include "static_centerline_generator/type_alias.hpp"
2524
#include "vehicle_info_util/vehicle_info_util.hpp"
2625

@@ -90,8 +89,7 @@ class StaticCenterlineGeneratorNode : public rclcpp::Node
9089
std::pair<int, int> traj_range_indices_{0, 0};
9190
std::optional<CenterlineWithRoute> centerline_with_route_{std::nullopt};
9291

93-
enum class CenterlineSource
94-
{
92+
enum class CenterlineSource {
9593
OptimizationTrajectoryBase = 0,
9694
BagEgoTrajectoryBase,
9795
};

planning/static_centerline_generator/src/centerline_source/bag_ego_trajectory_based_centerline.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ std::vector<TrajectoryPoint> generate_centerline_with_bag(rclcpp::Node & node)
4949
constexpr double epsilon = 1e-1;
5050
if (
5151
std::abs(centerline_traj_points.back().pose.position.x - ros_msg->pose.pose.position.x) <
52-
epsilon &&
52+
epsilon &&
5353
std::abs(centerline_traj_points.back().pose.position.y - ros_msg->pose.pose.position.y) <
54-
epsilon)
55-
{
54+
epsilon) {
5655
continue;
5756
}
5857
}

planning/static_centerline_generator/src/centerline_source/optimization_trajectory_based_centerline.cpp

+19-21
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include \
16-
"static_centerline_generator/centerline_source/optimization_trajectory_based_centerline.hpp"
15+
#include "static_centerline_generator/centerline_source/optimization_trajectory_based_centerline.hpp"
1716

1817
#include "motion_utils/resample/resample.hpp"
1918
#include "motion_utils/trajectory/conversion.hpp"
@@ -91,19 +90,19 @@ OptimizationTrajectoryBasedCenterline::generate_centerline_with_optimization(
9190

9291
// extract path with lane id from lanelets
9392
const auto raw_path_with_lane_id = [&]() {
94-
const auto non_resampled_path_with_lane_id = utils::get_path_with_lane_id(
95-
route_handler, route_lanelets, start_center_pose, ego_nearest_dist_threshold,
96-
ego_nearest_yaw_threshold);
97-
return motion_utils::resamplePath(non_resampled_path_with_lane_id, behavior_path_interval);
98-
}();
93+
const auto non_resampled_path_with_lane_id = utils::get_path_with_lane_id(
94+
route_handler, route_lanelets, start_center_pose, ego_nearest_dist_threshold,
95+
ego_nearest_yaw_threshold);
96+
return motion_utils::resamplePath(non_resampled_path_with_lane_id, behavior_path_interval);
97+
}();
9998
pub_raw_path_with_lane_id_->publish(raw_path_with_lane_id);
10099
RCLCPP_INFO(node.get_logger(), "Calculated raw path with lane id and published.");
101100

102101
// convert path with lane id to path
103102
const auto raw_path = [&]() {
104-
const auto non_resampled_path = convert_to_path(raw_path_with_lane_id);
105-
return motion_utils::resamplePath(non_resampled_path, behavior_vel_interval);
106-
}();
103+
const auto non_resampled_path = convert_to_path(raw_path_with_lane_id);
104+
return motion_utils::resamplePath(non_resampled_path, behavior_vel_interval);
105+
}();
107106
pub_raw_path_->publish(raw_path);
108107
RCLCPP_INFO(node.get_logger(), "Converted to path and published.");
109108

@@ -121,9 +120,9 @@ std::vector<TrajectoryPoint> OptimizationTrajectoryBasedCenterline::optimize_tra
121120
{
122121
// convert to trajectory points
123122
const auto raw_traj_points = [&]() {
124-
const auto raw_traj = convert_to_trajectory(raw_path);
125-
return motion_utils::convertToTrajectoryPointArray(raw_traj);
126-
}();
123+
const auto raw_traj = convert_to_trajectory(raw_path);
124+
return motion_utils::convertToTrajectoryPointArray(raw_traj);
125+
}();
127126

128127
// create an instance of elastic band and model predictive trajectory.
129128
const auto eb_path_smoother_ptr =
@@ -133,25 +132,24 @@ std::vector<TrajectoryPoint> OptimizationTrajectoryBasedCenterline::optimize_tra
133132

134133
// NOTE: The optimization is executed every valid_optimized_traj_points_num points.
135134
constexpr int valid_optimized_traj_points_num = 10;
136-
const int traj_segment_num = static_cast<int>(raw_traj_points.size()) /
137-
valid_optimized_traj_points_num;
135+
const int traj_segment_num =
136+
static_cast<int>(raw_traj_points.size()) / valid_optimized_traj_points_num;
138137

139138
// NOTE: num_initial_optimization exists to make the both optimizations stable since they may use
140139
// warm start.
141140
constexpr int num_initial_optimization = 2;
142141

143142
std::vector<TrajectoryPoint> whole_optimized_traj_points;
144143
for (int virtual_ego_pose_idx = -num_initial_optimization;
145-
virtual_ego_pose_idx < traj_segment_num; ++virtual_ego_pose_idx)
146-
{
144+
virtual_ego_pose_idx < traj_segment_num; ++virtual_ego_pose_idx) {
147145
// calculate virtual ego pose for the optimization
148146
constexpr int virtual_ego_pose_offset_idx = 1;
149147
const auto virtual_ego_pose =
150148
raw_traj_points
151-
.at(
152-
valid_optimized_traj_points_num * std::max(virtual_ego_pose_idx, 0) +
153-
virtual_ego_pose_offset_idx)
154-
.pose;
149+
.at(
150+
valid_optimized_traj_points_num * std::max(virtual_ego_pose_idx, 0) +
151+
virtual_ego_pose_offset_idx)
152+
.pose;
155153

156154
// smooth trajectory by elastic band in the path_smoother package
157155
const auto smoothed_traj_points =

0 commit comments

Comments
 (0)