Skip to content

Commit

Permalink
change ff constant calculation
Browse files Browse the repository at this point in the history
ds
  • Loading branch information
brkay54 committed Sep 18, 2023
1 parent 9b6cec3 commit 92bcd47
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,8 @@ double PidLongitudinalController::applyVelocityFeedback(const ControlData & cont
const double current_vel_abs = std::fabs(control_data.current_motion.vel);
const double target_vel_abs = std::fabs(
control_data.interpolated_traj.points.at(control_data.target_idx).longitudinal_velocity_mps);
const double current_target_vel_abs = std::fabs(
control_data.interpolated_traj.points.at(control_data.nearest_idx).longitudinal_velocity_mps);
const bool is_under_control = m_current_operation_mode.mode == OperationModeState::AUTONOMOUS;
const bool enable_integration =
(current_vel_abs > m_current_vel_threshold_pid_integrate) && is_under_control;
Expand All @@ -987,8 +989,11 @@ double PidLongitudinalController::applyVelocityFeedback(const ControlData & cont
// deviation will be bigger.
constexpr double ff_scale_max = 2.0; // for safety
constexpr double ff_scale_min = 0.5; // for safety
const double ff_scale =
std::clamp(current_vel_abs / std::max(target_vel_abs, 0.1), ff_scale_min, ff_scale_max);
const double ff_scale = std::clamp(
1.0 + (abs(current_target_vel_abs - abs(control_data.current_motion.vel)) /
std::max(current_target_vel_abs, 0.1)),
ff_scale_min, ff_scale_max);

const double ff_acc =
control_data.interpolated_traj.points.at(control_data.target_idx).acceleration_mps2 * ff_scale;

Expand Down

0 comments on commit 92bcd47

Please sign in to comment.