Skip to content

Commit 77597fb

Browse files
committed
comment on lateral acc calculation function
1 parent a143e43 commit 77597fb

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

bark/commons/transformation/frenet_state.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct FrenetStateDifference : public FrenetState {
5151
// - positive lateral difference if frenet_state2 is in "left" of frenet_state1
5252
// - positive long and velocities diff if frenet state 2 is "faster" than frenet state1
5353
// - positive angle difference if frenet state2 is turned more left than frenet state 1
54+
// - boolean flags lat_zeroed and lon_zeroed indicate if the lateral/longitudinal shape-based distance is zero
55+
// giving that the calculated distances actually represent a state-based distance
5456
FrenetStateDifference() : FrenetState(), from(), to(), lat_zeroed(false), lon_zeroed(false) {}
5557
FrenetStateDifference(const FrenetState& frenet_state1, const bark::geometry::Polygon& polygon1,
5658
const FrenetState& frenet_state2, const bark::geometry::Polygon& polygon2);

bark/models/dynamic/single_track.hpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,34 @@ class SingleTrackModel : public DynamicModel {
8989
return acceleration_limits_.lat_acc_max;
9090
}
9191

92+
/**
93+
* @brief Calculates maximum possible lateral evasive acceleration away from center line of a lane
94+
* assuming single track vehicle dynamics
95+
*
96+
* @param v velocity of vehicle in global coordinate system
97+
* @param theta orientation of vehicle in global coordinate system
98+
* @param tangent_angle angle of center line in global coordinate system, assumed to be constant over time
99+
* @param a_total_max maximum possible acceleration of vehicle into direction of orientation
100+
* @param on_left_of_center_line to calculate evasive lateral maximum acceleration, flag indicates on which side
101+
* of center line the vehicle is
102+
* @return double maximum possible lateral evasive acceleration
103+
*/
92104
double CalculateLatAccelerationMaxAtFrenetAngle(const double &v, const double& theta,
93105
const double& tangent_angle,
94-
const double a_long_max,
106+
const double a_total_max,
95107
bool on_left_of_center_line) const {
96108
const auto max_acc_lat_dyn = GetLatAccelerationMax();
97109
const double delta_max = std::atan2(max_acc_lat_dyn * wheel_base_, v * v);
98110
double delta_max_evasive;
99111
const double abs_angle_diff = std::abs(bark::geometry::SignedAngleDiff(theta, tangent_angle));
100-
const double evasive_sign = abs_angle_diff < bark::geometry::B_PI_2;
101112
if ((on_left_of_center_line && abs_angle_diff < bark::geometry::B_PI_2) ||
102113
(!on_left_of_center_line && abs_angle_diff > bark::geometry::B_PI_2)) {
103114
delta_max_evasive = delta_max;
104115
} else {
105116
delta_max_evasive = delta_max;
106117
}
107118
const double max_lat_acc_from_steering = v*v*sin(delta_max_evasive)/wheel_base_*cos(tangent_angle+theta);
108-
const double max_lat_acc_from_long_acc = std::abs(a_long_max)*(sin(tangent_angle-theta));
119+
const double max_lat_acc_from_long_acc = std::abs(a_total_max)*(sin(tangent_angle-theta));
109120
const double max_lat_acc = max_lat_acc_from_long_acc-max_lat_acc_from_steering;
110121
return std::abs(max_lat_acc);
111122
}

bark/world/evaluation/ltl/label_functions/safe_distance_label_function.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ double SafeDistanceLabelFunction::CalcSafeDistance3(const double v_r,
213213
bool SafeDistanceLabelFunction::CheckSafeDistanceLateral(FrontRearAgents& fr_agents, const AgentPtr& ego_agent) const {
214214
auto GetMaxAccLat = [](const AgentPtr& agent,
215215
const double& road_angle,
216-
const double& max_long_acc,
216+
const double& max_total_acc,
217217
const bool& on_left_side_of_center_line) {
218218
auto single_track = std::dynamic_pointer_cast<models::dynamic::SingleTrackModel>(
219219
agent->GetDynamicModel());
@@ -222,7 +222,7 @@ bool SafeDistanceLabelFunction::CheckSafeDistanceLateral(FrontRearAgents& fr_age
222222
const double a_max_lat = single_track->CalculateLatAccelerationMaxAtFrenetAngle(
223223
state(StateDefinition::VEL_POSITION),
224224
state(StateDefinition::THETA_POSITION),
225-
road_angle, max_long_acc,
225+
road_angle, max_total_acc,
226226
on_left_side_of_center_line);
227227
return a_max_lat;
228228
};

0 commit comments

Comments
 (0)