Skip to content

Commit

Permalink
refactor(map_based_prediction): add const (#7054)
Browse files Browse the repository at this point in the history
* refactor(map_based_prediction): add const

Signed-off-by: kminoda <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: kminoda <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
kminoda and pre-commit-ci[bot] authored May 18, 2024
1 parent ef90fb7 commit d6e8012
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class PathGenerator
const double time_horizon, const double lateral_time_horizon,
const double sampling_time_interval, const double min_crosswalk_user_velocity);

PredictedPath generatePathForNonVehicleObject(const TrackedObject & object);
PredictedPath generatePathForNonVehicleObject(const TrackedObject & object) const;

PredictedPath generatePathForLowSpeedVehicle(const TrackedObject & object) const;

PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object);
PredictedPath generatePathForOffLaneVehicle(const TrackedObject & object) const;

PredictedPath generatePathForOnLaneVehicle(
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit = 0.0);
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit = 0.0) const;

PredictedPath generatePathForCrosswalkUser(
const TrackedObject & object, const CrosswalkEdgePoints & reachable_crosswalk) const;
Expand Down Expand Up @@ -122,24 +122,25 @@ class PathGenerator
PredictedPath generateStraightPath(const TrackedObject & object) const;

PredictedPath generatePolynomialPath(
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0) const;

FrenetPath generateFrenetPath(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length);
const FrenetPoint & current_point, const FrenetPoint & target_point,
const double max_length) const;
Eigen::Vector3d calcLatCoefficients(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T);
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const;
Eigen::Vector2d calcLonCoefficients(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T);
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const;

PosePath interpolateReferencePath(
const PosePath & base_path, const FrenetPath & frenet_predicted_path);
const PosePath & base_path, const FrenetPath & frenet_predicted_path) const;

PredictedPath convertToPredictedPath(
const TrackedObject & object, const FrenetPath & frenet_predicted_path,
const PosePath & ref_path);
const PosePath & ref_path) const;

FrenetPoint getFrenetPoint(
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0);
const TrackedObject & object, const PosePath & ref_path, const double speed_limit = 0.0) const;
};
} // namespace map_based_prediction

Expand Down
22 changes: 12 additions & 10 deletions perception/map_based_prediction/src/path_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PathGenerator::PathGenerator(
{
}

PredictedPath PathGenerator::generatePathForNonVehicleObject(const TrackedObject & object)
PredictedPath PathGenerator::generatePathForNonVehicleObject(const TrackedObject & object) const
{
return generateStraightPath(object);
}
Expand Down Expand Up @@ -143,13 +143,13 @@ PredictedPath PathGenerator::generatePathForLowSpeedVehicle(const TrackedObject
return path;
}

PredictedPath PathGenerator::generatePathForOffLaneVehicle(const TrackedObject & object)
PredictedPath PathGenerator::generatePathForOffLaneVehicle(const TrackedObject & object) const
{
return generateStraightPath(object);
}

PredictedPath PathGenerator::generatePathForOnLaneVehicle(
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit)
const TrackedObject & object, const PosePath & ref_paths, const double speed_limit) const
{
if (ref_paths.size() < 2) {
return generateStraightPath(object);
Expand Down Expand Up @@ -178,7 +178,7 @@ PredictedPath PathGenerator::generateStraightPath(const TrackedObject & object)
}

PredictedPath PathGenerator::generatePolynomialPath(
const TrackedObject & object, const PosePath & ref_path, const double speed_limit)
const TrackedObject & object, const PosePath & ref_path, const double speed_limit) const
{
// Get current Frenet Point
const double ref_path_len = motion_utils::calcArcLength(ref_path);
Expand Down Expand Up @@ -210,7 +210,8 @@ PredictedPath PathGenerator::generatePolynomialPath(
}

FrenetPath PathGenerator::generateFrenetPath(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double max_length)
const FrenetPoint & current_point, const FrenetPoint & target_point,
const double max_length) const
{
FrenetPath path;
const double duration = time_horizon_;
Expand Down Expand Up @@ -252,7 +253,7 @@ FrenetPath PathGenerator::generateFrenetPath(
}

Eigen::Vector3d PathGenerator::calcLatCoefficients(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T)
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const
{
// Lateral Path Calculation
// Quintic polynomial for d
Expand All @@ -278,7 +279,7 @@ Eigen::Vector3d PathGenerator::calcLatCoefficients(
}

Eigen::Vector2d PathGenerator::calcLonCoefficients(
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T)
const FrenetPoint & current_point, const FrenetPoint & target_point, const double T) const
{
// Longitudinal Path Calculation
// Quadric polynomial
Expand All @@ -296,7 +297,7 @@ Eigen::Vector2d PathGenerator::calcLonCoefficients(
}

PosePath PathGenerator::interpolateReferencePath(
const PosePath & base_path, const FrenetPath & frenet_predicted_path)
const PosePath & base_path, const FrenetPath & frenet_predicted_path) const
{
PosePath interpolated_path;
const size_t interpolate_num = frenet_predicted_path.size();
Expand Down Expand Up @@ -356,7 +357,8 @@ PosePath PathGenerator::interpolateReferencePath(
}

PredictedPath PathGenerator::convertToPredictedPath(
const TrackedObject & object, const FrenetPath & frenet_predicted_path, const PosePath & ref_path)
const TrackedObject & object, const FrenetPath & frenet_predicted_path,
const PosePath & ref_path) const
{
PredictedPath predicted_path;
predicted_path.time_step = rclcpp::Duration::from_seconds(sampling_time_interval_);
Expand Down Expand Up @@ -385,7 +387,7 @@ PredictedPath PathGenerator::convertToPredictedPath(
}

FrenetPoint PathGenerator::getFrenetPoint(
const TrackedObject & object, const PosePath & ref_path, const double speed_limit)
const TrackedObject & object, const PosePath & ref_path, const double speed_limit) const
{
FrenetPoint frenet_point;
const auto obj_point = object.kinematics.pose_with_covariance.pose.position;
Expand Down

0 comments on commit d6e8012

Please sign in to comment.