Skip to content

Commit

Permalink
rename prev variable
Browse files Browse the repository at this point in the history
Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
  • Loading branch information
TakaHoribe committed Sep 7, 2022
1 parent a0fda5b commit a639e4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TRAJECTORY_FOLLOWER_PUBLIC PidLongitudinalController : public Longitudinal

// pointers for ros topic
nav_msgs::msg::Odometry::ConstSharedPtr m_current_kinematic_state_ptr{nullptr};
nav_msgs::msg::Odometry::ConstSharedPtr m_prev_velocity_ptr{nullptr};
nav_msgs::msg::Odometry::ConstSharedPtr m_prev_kienmatic_state_ptr{nullptr};
autoware_auto_planning_msgs::msg::Trajectory::ConstSharedPtr m_trajectory_ptr{nullptr};

// vehicle info
Expand Down
10 changes: 5 additions & 5 deletions control/trajectory_follower/src/pid_longitudinal_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void PidLongitudinalController::setKinematicState(const nav_msgs::msg::Odometry:
if (!msg) return;

if (m_current_kinematic_state_ptr) {
m_prev_velocity_ptr = m_current_kinematic_state_ptr;
m_prev_kienmatic_state_ptr = m_current_kinematic_state_ptr;
}
m_current_kinematic_state_ptr = msg;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ rcl_interfaces::msg::SetParametersResult PidLongitudinalController::paramCallbac
boost::optional<LongitudinalOutput> PidLongitudinalController::run()
{
// wait for initial pointers
if (!m_current_kinematic_state_ptr || !m_prev_velocity_ptr || !m_trajectory_ptr) {
if (!m_current_kinematic_state_ptr || !m_prev_kienmatic_state_ptr || !m_trajectory_ptr) {
return boost::none;
}

Expand Down Expand Up @@ -701,11 +701,11 @@ float64_t PidLongitudinalController::getDt()

PidLongitudinalController::Motion PidLongitudinalController::getCurrentMotion() const
{
const float64_t dv =
m_current_kinematic_state_ptr->twist.twist.linear.x - m_prev_velocity_ptr->twist.twist.linear.x;
const float64_t dv = m_current_kinematic_state_ptr->twist.twist.linear.x -
m_prev_kienmatic_state_ptr->twist.twist.linear.x;
const float64_t dt = std::max(
(rclcpp::Time(m_current_kinematic_state_ptr->header.stamp) -
rclcpp::Time(m_prev_velocity_ptr->header.stamp))
rclcpp::Time(m_prev_kienmatic_state_ptr->header.stamp))
.seconds(),
1e-03);
const float64_t accel = dv / dt;
Expand Down

0 comments on commit a639e4b

Please sign in to comment.