Skip to content

Commit d6e8012

Browse files
refactor(map_based_prediction): add const (#7054)
* refactor(map_based_prediction): add const Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix --------- Signed-off-by: kminoda <koji.minoda@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ef90fb7 commit d6e8012

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

perception/map_based_prediction/include/map_based_prediction/path_generator.hpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ class PathGenerator
8484
const double time_horizon, const double lateral_time_horizon,
8585
const double sampling_time_interval, const double min_crosswalk_user_velocity);
8686

87-
PredictedPath generatePathForNonVehicleObject(const TrackedObject & object);
87+
PredictedPath generatePathForNonVehicleObject(const TrackedObject & object) const;
8888

8989
PredictedPath generatePathForLowSpeedVehicle(const TrackedObject & object) const;
9090

91-
PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object);
91+
PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object) const;
9292

9393
PredictedPath generatePathForOnLaneVehicle(
94-
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit = 0.0);
94+
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit = 0.0) const;
9595

9696
PredictedPath generatePathForCrosswalkUser(
9797
const TrackedObject & object, const CrosswalkEdgePoints & reachable_crosswalk) const;
@@ -122,24 +122,25 @@ class PathGenerator
122122
PredictedPath generateStraightPath(const TrackedObject & object) const;
123123

124124
PredictedPath generatePolynomialPath(
125-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
125+
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0) const;
126126

127127
FrenetPath generateFrenetPath(
128-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length);
128+
const FrenetPoint & current_point, const FrenetPoint & target_point,
129+
const double max_length) const;
129130
Eigen::Vector3d calcLatCoefficients(
130-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T);
131+
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const;
131132
Eigen::Vector2d calcLonCoefficients(
132-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T);
133+
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const;
133134

134135
PosePath interpolateReferencePath(
135-
const PosePath & base_path, const FrenetPath & frenet_predicted_path);
136+
const PosePath & base_path, const FrenetPath & frenet_predicted_path) const;
136137

137138
PredictedPath convertToPredictedPath(
138139
const TrackedObject & object, const FrenetPath & frenet_predicted_path,
139-
const PosePath & ref_path);
140+
const PosePath & ref_path) const;
140141

141142
FrenetPoint getFrenetPoint(
142-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
143+
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0) const;
143144
};
144145
} // namespace map_based_prediction
145146

perception/map_based_prediction/src/path_generator.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PathGenerator::PathGenerator(
3232
{
3333
}
3434

35-
PredictedPath PathGenerator::generatePathForNonVehicleObject(const TrackedObject & object)
35+
PredictedPath PathGenerator::generatePathForNonVehicleObject(const TrackedObject & object) const
3636
{
3737
return generateStraightPath(object);
3838
}
@@ -143,13 +143,13 @@ PredictedPath PathGenerator::generatePathForLowSpeedVehicle(const TrackedObject
143143
return path;
144144
}
145145

146-
PredictedPath PathGenerator::generatePathForOffLaneVehicle(const TrackedObject & object)
146+
PredictedPath PathGenerator::generatePathForOffLaneVehicle(const TrackedObject & object) const
147147
{
148148
return generateStraightPath(object);
149149
}
150150

151151
PredictedPath PathGenerator::generatePathForOnLaneVehicle(
152-
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit)
152+
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit) const
153153
{
154154
if (ref_paths.size() < 2) {
155155
return generateStraightPath(object);
@@ -178,7 +178,7 @@ PredictedPath PathGenerator::generateStraightPath(const TrackedObject & object)
178178
}
179179

180180
PredictedPath PathGenerator::generatePolynomialPath(
181-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit)
181+
const TrackedObject & object, const PosePath & ref_path, const double speed_limit) const
182182
{
183183
// Get current Frenet Point
184184
const double ref_path_len = motion_utils::calcArcLength(ref_path);
@@ -210,7 +210,8 @@ PredictedPath PathGenerator::generatePolynomialPath(
210210
}
211211

212212
FrenetPath PathGenerator::generateFrenetPath(
213-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length)
213+
const FrenetPoint & current_point, const FrenetPoint & target_point,
214+
const double max_length) const
214215
{
215216
FrenetPath path;
216217
const double duration = time_horizon_;
@@ -252,7 +253,7 @@ FrenetPath PathGenerator::generateFrenetPath(
252253
}
253254

254255
Eigen::Vector3d PathGenerator::calcLatCoefficients(
255-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T)
256+
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const
256257
{
257258
// Lateral Path Calculation
258259
// Quintic polynomial for d
@@ -278,7 +279,7 @@ Eigen::Vector3d PathGenerator::calcLatCoefficients(
278279
}
279280

280281
Eigen::Vector2d PathGenerator::calcLonCoefficients(
281-
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T)
282+
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const
282283
{
283284
// Longitudinal Path Calculation
284285
// Quadric polynomial
@@ -296,7 +297,7 @@ Eigen::Vector2d PathGenerator::calcLonCoefficients(
296297
}
297298

298299
PosePath PathGenerator::interpolateReferencePath(
299-
const PosePath & base_path, const FrenetPath & frenet_predicted_path)
300+
const PosePath & base_path, const FrenetPath & frenet_predicted_path) const
300301
{
301302
PosePath interpolated_path;
302303
const size_t interpolate_num = frenet_predicted_path.size();
@@ -356,7 +357,8 @@ PosePath PathGenerator::interpolateReferencePath(
356357
}
357358

358359
PredictedPath PathGenerator::convertToPredictedPath(
359-
const TrackedObject & object, const FrenetPath & frenet_predicted_path, const PosePath & ref_path)
360+
const TrackedObject & object, const FrenetPath & frenet_predicted_path,
361+
const PosePath & ref_path) const
360362
{
361363
PredictedPath predicted_path;
362364
predicted_path.time_step = rclcpp::Duration::from_seconds(sampling_time_interval_);
@@ -385,7 +387,7 @@ PredictedPath PathGenerator::convertToPredictedPath(
385387
}
386388

387389
FrenetPoint PathGenerator::getFrenetPoint(
388-
const TrackedObject & object, const PosePath & ref_path, const double speed_limit)
390+
const TrackedObject & object, const PosePath & ref_path, const double speed_limit) const
389391
{
390392
FrenetPoint frenet_point;
391393
const auto obj_point = object.kinematics.pose_with_covariance.pose.position;

0 commit comments

Comments
 (0)