-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RJD-1388/follow_trajectory #44
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
…e polyline_trajectory_follower file to follow_trajectory Signed-off-by: Mateusz Palczuk <[email protected]>
…e polyline_trajectory_follower file to follow_trajectory Change include paths and include guards Signed-off-by: Mateusz Palczuk <[email protected]>
Add "_" suffix to PolylineTrajectoryPositioner data fields Modify distanceAlongLanelet function to take 2 different bounding boxes as arguments Add comments on what data fields are implicitly required by functions used in PolylineTrajectoryPositioner constructor Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
…at is wrong, but passes github CI test Signed-off-by: Mateusz Palczuk <[email protected]>
Rjd 1388/follow trajectory fix
Rjd 1388/follow trajectory update
…jectory Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
/// @note side effects on polyline_trajectory | ||
auto makeUpdatedEntityStatus( | ||
const ValidatedEntityStatus & validated_entity_status, | ||
const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils_ptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please always pass std::shared_ptr<hdmap_utils::HdMapUtils>
as the last argument - in the near future it will be removed, it is easier to make such changes for the last argument
@@ -30,11 +30,11 @@ namespace traffic_simulator | |||
{ | |||
namespace follow_trajectory | |||
{ | |||
struct ControllerError : public common::Error | |||
struct ControllerError : public common::SimulationError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -231,7 +231,7 @@ class FollowWaypointController | |||
max_acceleration_rate{behavior_parameter.dynamic_constraints.max_acceleration_rate}, | |||
max_deceleration{behavior_parameter.dynamic_constraints.max_deceleration}, | |||
max_deceleration_rate{behavior_parameter.dynamic_constraints.max_deceleration_rate}, | |||
target_speed{(target_speed) ? target_speed.value() : max_speed} | |||
target_speed{target_speed.value_or(max_speed)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -144,15 +144,15 @@ class EntityBase | |||
virtual void requestLaneChange(const lanelet::Id) | |||
{ | |||
/** | |||
* @note There are Entities such as MiscObjectEntity for which lane change is not possible, | |||
* @note There are Entities such as MiscObjectEntity for which lane change is not possible, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse changes in comments (even such as whitespace characters)
@@ -112,6 +112,14 @@ auto distanceToStopLine( | |||
const traffic_simulator_msgs::msg::WaypointsArray & waypoints_array, | |||
const lanelet::Id target_stop_line_id, | |||
const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils_ptr) -> std::optional<double>; | |||
|
|||
auto distanceAlongLanelet( | |||
const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils_ptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please always pass std::shared_ptr<hdmap_utils::HdMapUtils>
as the last argument - in the near future it will be removed, it is easier to make such changes for the last argument
@@ -176,7 +178,7 @@ auto FollowWaypointController::clampAcceleration( | |||
const double candidate_acceleration, const double acceleration, const double speed) const | |||
-> double | |||
{ | |||
auto [local_min_acceleration, local_max_acceleration] = | |||
const auto && [local_min_acceleration, local_max_acceleration] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto [local_min_acceleration, local_max_acceleration]
@@ -273,7 +275,7 @@ auto FollowWaypointController::getPredictedWaypointArrivalState( | |||
|
|||
// Count the distance and time of movement with constant speed, use this to prediction. | |||
if (const double const_speed_distance = remaining_distance - state.traveled_distance; | |||
const_speed_distance >= std::numeric_limits<double>::max() * const_speed_value) { | |||
const_speed_distance == std::numeric_limits<double>::infinity()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const_speed_distance >= std::numeric_limits<double>::max() * const_speed_value)
@@ -334,7 +337,7 @@ auto FollowWaypointController::getAcceleration( | |||
const double remaining_time_source, const double remaining_distance, const double acceleration, | |||
const double speed) const -> double | |||
{ | |||
const auto [local_min_acceleration, local_max_acceleration] = | |||
const auto && [local_min_acceleration, local_max_acceleration] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto && [local_min_acceleration, local_max_acceleration] =
|
||
if (const auto predicted_state_opt = getPredictedStopStateWithoutConsideringTime( | ||
candidate_acceleration, remaining_distance, acceleration, speed); | ||
predicted_state_opt) { | ||
if (const auto distance_diff = remaining_distance - predicted_state_opt->traveled_distance; | ||
(distance_diff >= 0 || min_distance_diff < 0) && | ||
if (const double distance_diff = remaining_distance - predicted_state_opt->traveled_distance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why auto
-> double
?
@@ -311,5 +312,29 @@ auto distanceToStopLine( | |||
return spline.getCollisionPointIn2D(polygon); | |||
} | |||
} | |||
|
|||
auto distanceAlongLanelet( | |||
const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils_ptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please always pass std::shared_ptr<hdmap_utils::HdMapUtils>
as the last argument - in the near future it will be removed, it is easier to make such changes for the last argument
if (const auto from_lanelet_pose = | ||
hdmap_utils_ptr->toLaneletPose(from_position, from_bounding_box, false, matching_distance); | ||
from_lanelet_pose.has_value()) { | ||
if (const auto to_lanelet_pose = | ||
hdmap_utils_ptr->toLaneletPose(to_position, to_bounding_box, false, matching_distance); | ||
to_lanelet_pose.has_value()) { | ||
if (const auto distance = hdmap_utils_ptr->getLongitudinalDistance( | ||
from_lanelet_pose.value(), to_lanelet_pose.value()); | ||
distance.has_value()) { | ||
return distance.value(); | ||
} | ||
} | ||
} | ||
return math::geometry::hypot(from_position, to_position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (const auto from_lanelet_pose = | |
hdmap_utils_ptr->toLaneletPose(from_position, from_bounding_box, false, matching_distance); | |
from_lanelet_pose.has_value()) { | |
if (const auto to_lanelet_pose = | |
hdmap_utils_ptr->toLaneletPose(to_position, to_bounding_box, false, matching_distance); | |
to_lanelet_pose.has_value()) { | |
if (const auto distance = hdmap_utils_ptr->getLongitudinalDistance( | |
from_lanelet_pose.value(), to_lanelet_pose.value()); | |
distance.has_value()) { | |
return distance.value(); | |
} | |
} | |
} | |
return math::geometry::hypot(from_position, to_position); | |
/// @note due to this hardcoded value, the method cannot be used for calculations along a crosswalk (for pedestrians) | |
constexpr auto include_crosswalk{false}; | |
if (const auto from_lanelet_pose = | |
hdmap_utils_ptr->toLaneletPose(from_position, from_bounding_box, include_crosswalk, matching_distance)) { | |
if (const auto to_lanelet_pose = | |
hdmap_utils_ptr->toLaneletPose(to_position, to_bounding_box, include_crosswalk, matching_distance)) { | |
if (const auto distance = hdmap_utils_ptr->getLongitudinalDistance( | |
from_lanelet_pose.value(), to_lanelet_pose.value()); | |
distance.has_value()) { | |
return distance.value(); | |
} | |
} | |
} | |
return math::geometry::hypot(from_position, to_position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of trouble I would not return the euclidean distance but std::optional
,
only inside FollowTrajectoryAction
I would implement if unable to calculate along the lane use euclidean
- because it is a specific approach in FTA
Abstract
This PR contains the refactor of
follow_trajectory
namespace, in particular makeUpdatedStatus function.Details
follow_trajectory
directory.ValidatedEntityStatus
serves as a simple structure that holds repeatedly used variables. Its construction checks and validates numerous conditions that were previously handled inmakeUpdatedStatus
. An instance ofValidatedEntityStatus
is passed as an argument tofollow_trajectory::makeUpdatedEntityStatus
.follow_trajectory::makeUpdatedEntityStatus
is now the new entry point of the algorithm. It replaces the recursion from the originalmakeUpdatedStatus
with a while loop, iterating over the trajectory.PolylineTrajectoryPositioner
is responsible for a single step in the aforementioned while loop. In its constructor, it calculates several variables that were previously computed by lambdas in themakeUpdatedStatus
function.PolylineTrajectoryPositioner::makeUpdatedEntityStatus
contains what remains of the originalmakeUpdatedStatus
, now focusing solely on its core logic.References
Regressions TODO