Skip to content

Commit

Permalink
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
Browse files Browse the repository at this point in the history
…e-feature
  • Loading branch information
mkquda committed Dec 23, 2024
2 parents 349850b + 29d14e3 commit 79338e2
Show file tree
Hide file tree
Showing 28 changed files with 673 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/*
* Representation
* k : reference curvature (input)
* e : lateral error
* th : heading angle error
* steer : steering angle
Expand All @@ -32,10 +33,12 @@
* dx3/dt = -(x3 - u) / tau
*
* Linearized model around reference point (v = v_r, th = th_r, steer = steer_r)
* [0, vr, 0] [ 0] [ 0]
* dx/dt = [0, 0, vr/W/cos(steer_r)^2] * x + [ 0] * u + [-vr*steer_r/W/cos(steer_r)^2]
* [0, 0, 1/tau] [1/tau] [ 0]
* [0, vr, 0] [ 0] [ 0]
* dx/dt = [0, 0, B] * x + [ 0] * u + [-vr*k + A - B*steer_r]
* [0, 0, -1/tau] [1/tau] [ 0]
*
* where A = vr*tan(steer_r)/W
* B = vr/(W*cos(steer_r)^2) (partial derivative of A with respect to steer_r)
*/

#ifndef AUTOWARE__MPC_LATERAL_CONTROLLER__VEHICLE_MODEL__VEHICLE_MODEL_BICYCLE_KINEMATICS_HPP_
Expand Down
2 changes: 2 additions & 0 deletions control/autoware_pid_longitudinal_controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ There are two sources of the slope information, which can be switched by a param
- Cons: z-coordinates of high-precision map is needed.
- Cons: Does not support free space planning (for now)

We also offer the options to switch between these, depending on driving conditions.

**Notation:** This function works correctly only in a vehicle system that does not have acceleration feedback in the low-level control system.

This compensation adds gravity correction to the target acceleration, resulting in an output value that is no longer equal to the target acceleration that the autonomous driving system desires. Therefore, it conflicts with the role of the acceleration feedback in the low-level controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

# slope compensation
lpf_pitch_gain: 0.95
slope_source: "raw_pitch" # raw_pitch, trajectory_pitch or trajectory_adaptive
slope_source: "trajectory_goal_adaptive" # raw_pitch, trajectory_pitch, trajectory_adaptive or trajectory_goal_adaptive
adaptive_trajectory_velocity_th: 1.0
max_pitch_rad: 0.1
min_pitch_rad: -0.1
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
double m_max_acc_cmd_diff;

// slope compensation
enum class SlopeSource { RAW_PITCH = 0, TRAJECTORY_PITCH, TRAJECTORY_ADAPTIVE };
enum class SlopeSource {
RAW_PITCH = 0,
TRAJECTORY_PITCH,
TRAJECTORY_ADAPTIVE,
TRAJECTORY_GOAL_ADAPTIVE
};
SlopeSource m_slope_source{SlopeSource::RAW_PITCH};
double m_adaptive_trajectory_velocity_th;
std::shared_ptr<LowpassFilter1d> m_lpf_pitch{nullptr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ PidLongitudinalController::PidLongitudinalController(
m_slope_source = SlopeSource::TRAJECTORY_PITCH;
} else if (slope_source == "trajectory_adaptive") {
m_slope_source = SlopeSource::TRAJECTORY_ADAPTIVE;
} else if (slope_source == "trajectory_goal_adaptive") {
m_slope_source = SlopeSource::TRAJECTORY_GOAL_ADAPTIVE;
} else {
RCLCPP_ERROR(logger_, "Slope source is not valid. Using raw_pitch option as default");
m_slope_source = SlopeSource::RAW_PITCH;
Expand Down Expand Up @@ -529,35 +531,44 @@ PidLongitudinalController::ControlData PidLongitudinalController::getControlData
// NOTE: getPitchByTraj() calculates the pitch angle as defined in
// ../media/slope_definition.drawio.svg while getPitchByPose() is not, so `raw_pitch` is reversed
const double raw_pitch = (-1.0) * longitudinal_utils::getPitchByPose(current_pose.orientation);
m_lpf_pitch->filter(raw_pitch);
const double traj_pitch = longitudinal_utils::getPitchByTraj(
control_data.interpolated_traj, control_data.target_idx, m_wheel_base);

if (m_slope_source == SlopeSource::RAW_PITCH) {
control_data.slope_angle = m_lpf_pitch->filter(raw_pitch);
control_data.slope_angle = m_lpf_pitch->getValue();
} else if (m_slope_source == SlopeSource::TRAJECTORY_PITCH) {
control_data.slope_angle = traj_pitch;
} else if (m_slope_source == SlopeSource::TRAJECTORY_ADAPTIVE) {
} else if (
m_slope_source == SlopeSource::TRAJECTORY_ADAPTIVE ||
m_slope_source == SlopeSource::TRAJECTORY_GOAL_ADAPTIVE) {
// if velocity is high, use target idx for slope, otherwise, use raw_pitch
if (control_data.current_motion.vel > m_adaptive_trajectory_velocity_th) {
control_data.slope_angle = traj_pitch;
m_lpf_pitch->filter(raw_pitch);
} else {
control_data.slope_angle = m_lpf_pitch->filter(raw_pitch);
}
const bool is_vel_slow = control_data.current_motion.vel < m_adaptive_trajectory_velocity_th &&
m_slope_source == SlopeSource::TRAJECTORY_ADAPTIVE;

const double goal_dist = autoware::motion_utils::calcSignedArcLength(
control_data.interpolated_traj.points, current_pose.position,
control_data.interpolated_traj.points.size() - 1);
const bool is_close_to_trajectory_end =
goal_dist < m_wheel_base && m_slope_source == SlopeSource::TRAJECTORY_GOAL_ADAPTIVE;

control_data.slope_angle =
(is_close_to_trajectory_end || is_vel_slow) ? m_lpf_pitch->getValue() : traj_pitch;

if (m_previous_slope_angle.has_value()) {
constexpr double gravity_const = 9.8;
control_data.slope_angle = std::clamp(
control_data.slope_angle,
m_previous_slope_angle.value() + m_min_jerk * control_data.dt / gravity_const,
m_previous_slope_angle.value() + m_max_jerk * control_data.dt / gravity_const);
}
m_previous_slope_angle = control_data.slope_angle;
} else {
RCLCPP_ERROR_THROTTLE(
logger_, *clock_, 3000, "Slope source is not valid. Using raw_pitch option as default");
control_data.slope_angle = m_lpf_pitch->filter(raw_pitch);
control_data.slope_angle = m_lpf_pitch->getValue();
}

m_previous_slope_angle = control_data.slope_angle;
updatePitchDebugValues(control_data.slope_angle, traj_pitch, raw_pitch, m_lpf_pitch->getValue());

return control_data;
Expand Down
Loading

0 comments on commit 79338e2

Please sign in to comment.