Skip to content

Commit

Permalink
add bias to steer rate
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Jan 31, 2024
1 parent 6018a2c commit e4dadc5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ double SimModelDelaySteerAcc::getWz()
}
double SimModelDelaySteerAcc::getSteer()
{
return state_(IDX::STEER);
return state_(IDX::STEER) + steer_bias_;
}
void SimModelDelaySteerAcc::update(const double & dt)
{
Expand Down Expand Up @@ -112,7 +112,7 @@ Eigen::VectorXd SimModelDelaySteerAcc::calcModel(
sat(input(IDX_U::ACCX_DES), vx_rate_lim_, -vx_rate_lim_) * debug_acc_scaling_factor_;
const double steer_des =
sat(input(IDX_U::STEER_DES), steer_lim_, -steer_lim_) * debug_steer_scaling_factor_;
const double steer_diff = steer - steer_des;
const double steer_diff = getSteer() - steer_des;
const double steer_diff_with_dead_band = std::invoke([&]() {
if (steer_diff > steer_dead_band_) {
return steer_diff - steer_dead_band_;
Expand All @@ -128,7 +128,7 @@ Eigen::VectorXd SimModelDelaySteerAcc::calcModel(
Eigen::VectorXd d_state = Eigen::VectorXd::Zero(dim_x_);
d_state(IDX::X) = vel * cos(yaw);
d_state(IDX::Y) = vel * sin(yaw);
d_state(IDX::YAW) = vel * std::tan(steer + steer_bias_) / wheelbase_;
d_state(IDX::YAW) = vel * std::tan(steer) / wheelbase_;
d_state(IDX::VX) = acc;
d_state(IDX::STEER) = steer_rate;
d_state(IDX::ACCX) = -(acc - acc_des) / acc_time_constant_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ double SimModelDelaySteerAccGeared::getWz()
}
double SimModelDelaySteerAccGeared::getSteer()
{
return state_(IDX::STEER);
return state_(IDX::STEER) + steer_bias_;
}
void SimModelDelaySteerAccGeared::update(const double & dt)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ Eigen::VectorXd SimModelDelaySteerAccGeared::calcModel(
sat(input(IDX_U::ACCX_DES), vx_rate_lim_, -vx_rate_lim_) * debug_acc_scaling_factor_;
const double steer_des =
sat(input(IDX_U::STEER_DES), steer_lim_, -steer_lim_) * debug_steer_scaling_factor_;
const double steer_diff = steer - steer_des;
const double steer_diff = getSteer() - steer_des;
const double steer_diff_with_dead_band = std::invoke([&]() {
if (steer_diff > steer_dead_band_) {
return steer_diff - steer_dead_band_;
Expand All @@ -136,7 +136,7 @@ Eigen::VectorXd SimModelDelaySteerAccGeared::calcModel(
Eigen::VectorXd d_state = Eigen::VectorXd::Zero(dim_x_);
d_state(IDX::X) = vel * cos(yaw);
d_state(IDX::Y) = vel * sin(yaw);
d_state(IDX::YAW) = vel * std::tan(steer + steer_bias_) / wheelbase_;
d_state(IDX::YAW) = vel * std::tan(steer) / wheelbase_;
d_state(IDX::VX) = acc;
d_state(IDX::STEER) = steer_rate;
d_state(IDX::ACCX) = -(acc - acc_des) / acc_time_constant_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ double SimModelDelaySteerMapAccGeared::getWz()
}
double SimModelDelaySteerMapAccGeared::getSteer()
{
return state_(IDX::STEER);
return state_(IDX::STEER) + steer_bias_;
}
void SimModelDelaySteerMapAccGeared::update(const double & dt)
{
Expand Down Expand Up @@ -114,13 +114,13 @@ Eigen::VectorXd SimModelDelaySteerMapAccGeared::calcModel(
const double steer = state(IDX::STEER);
const double acc_des = std::clamp(input(IDX_U::ACCX_DES), -vx_rate_lim_, vx_rate_lim_);
const double steer_des = std::clamp(input(IDX_U::STEER_DES), -steer_lim_, steer_lim_);
double steer_rate = -(steer - steer_des) / steer_time_constant_;
double steer_rate = -(getSteer() - steer_des) / steer_time_constant_;
steer_rate = std::clamp(steer_rate, -steer_rate_lim_, steer_rate_lim_);

Eigen::VectorXd d_state = Eigen::VectorXd::Zero(dim_x_);
d_state(IDX::X) = vel * cos(yaw);
d_state(IDX::Y) = vel * sin(yaw);
d_state(IDX::YAW) = vel * std::tan(steer + steer_bias_) / wheelbase_;
d_state(IDX::YAW) = vel * std::tan(steer) / wheelbase_;
d_state(IDX::VX) = acc;
d_state(IDX::STEER) = steer_rate;
const double converted_acc =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ double SimModelDelaySteerVel::getWz()
}
double SimModelDelaySteerVel::getSteer()
{
return state_(IDX::STEER);
return state_(IDX::STEER) + steer_bias_;
}
void SimModelDelaySteerVel::update(const double & dt)
{
Expand Down Expand Up @@ -110,7 +110,7 @@ Eigen::VectorXd SimModelDelaySteerVel::calcModel(
const double delay_vx_des = sat(delay_input_vx, vx_lim_, -vx_lim_);
const double vx_rate = sat(-(vx - delay_vx_des) / vx_time_constant_, vx_rate_lim_, -vx_rate_lim_);
const double delay_steer_des = sat(delay_input_steer, steer_lim_, -steer_lim_);
const double steer_diff = steer - delay_steer_des;
const double steer_diff = getSteer() - delay_steer_des;
const double steer_diff_with_dead_band = std::invoke([&]() {
if (steer_diff > steer_dead_band_) {
return steer_diff - steer_dead_band_;
Expand All @@ -126,7 +126,7 @@ Eigen::VectorXd SimModelDelaySteerVel::calcModel(
Eigen::VectorXd d_state = Eigen::VectorXd::Zero(dim_x_);
d_state(IDX::X) = vx * cos(yaw);
d_state(IDX::Y) = vx * sin(yaw);
d_state(IDX::YAW) = vx * std::tan(steer + steer_bias_) / wheelbase_;
d_state(IDX::YAW) = vx * std::tan(steer) / wheelbase_;
d_state(IDX::VX) = vx_rate;
d_state(IDX::STEER) = steer_rate;

Expand Down

0 comments on commit e4dadc5

Please sign in to comment.