Skip to content

Commit f25396f

Browse files
authored
refactor(pose_instability_detector): apply static analysis (#7476)
refactor based on linter Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com>
1 parent a78482e commit f25396f

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

localization/pose_instability_detector/include/autoware/pose_instability_detector/pose_instability_detector.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class PoseInstabilityDetector : public rclcpp::Node
5050
};
5151

5252
explicit PoseInstabilityDetector(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
53-
ThresholdValues calculate_threshold(double interval_sec);
54-
void dead_reckon(
53+
ThresholdValues calculate_threshold(double interval_sec) const;
54+
static void dead_reckon(
5555
PoseStamped::SharedPtr & initial_pose, const rclcpp::Time & end_time,
5656
const std::deque<TwistWithCovarianceStamped> & twist_deque, Pose::SharedPtr & estimated_pose);
5757

@@ -60,7 +60,7 @@ class PoseInstabilityDetector : public rclcpp::Node
6060
void callback_twist(TwistWithCovarianceStamped::ConstSharedPtr twist_msg_ptr);
6161
void callback_timer();
6262

63-
std::deque<TwistWithCovarianceStamped> clip_out_necessary_twist(
63+
static std::deque<TwistWithCovarianceStamped> clip_out_necessary_twist(
6464
const std::deque<TwistWithCovarianceStamped> & twist_buffer, const rclcpp::Time & start_time,
6565
const rclcpp::Time & end_time);
6666

@@ -76,8 +76,6 @@ class PoseInstabilityDetector : public rclcpp::Node
7676
// parameters
7777
const double timer_period_; // [sec]
7878

79-
ThresholdValues threshold_values_;
80-
8179
const double heading_velocity_maximum_; // [m/s]
8280
const double heading_velocity_scale_factor_tolerance_; // [%]
8381

localization/pose_instability_detector/src/pose_instability_detector.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,21 @@ void PoseInstabilityDetector::callback_timer()
118118
prev_pose->header = prev_odometry_->header;
119119
prev_pose->pose = prev_odometry_->pose.pose;
120120

121-
Pose::SharedPtr DR_pose = std::make_shared<Pose>();
122-
dead_reckon(prev_pose, latest_odometry_time, twist_buffer_, DR_pose);
121+
Pose::SharedPtr dr_pose = std::make_shared<Pose>();
122+
dead_reckon(prev_pose, latest_odometry_time, twist_buffer_, dr_pose);
123123

124124
// compare dead reckoning pose and latest_odometry_
125125
const Pose latest_ekf_pose = latest_odometry_->pose.pose;
126-
const Pose ekf_to_DR = tier4_autoware_utils::inverseTransformPose(*DR_pose, latest_ekf_pose);
127-
const geometry_msgs::msg::Point pos = ekf_to_DR.position;
128-
const auto [ang_x, ang_y, ang_z] = quat_to_rpy(ekf_to_DR.orientation);
126+
const Pose ekf_to_dr = tier4_autoware_utils::inverseTransformPose(*dr_pose, latest_ekf_pose);
127+
const geometry_msgs::msg::Point pos = ekf_to_dr.position;
128+
const auto [ang_x, ang_y, ang_z] = quat_to_rpy(ekf_to_dr.orientation);
129129
const std::vector<double> values = {pos.x, pos.y, pos.z, ang_x, ang_y, ang_z};
130130

131131
// publish diff_pose for debug
132132
PoseStamped diff_pose;
133133
diff_pose.header.stamp = latest_odometry_time;
134134
diff_pose.header.frame_id = "base_link";
135-
diff_pose.pose = ekf_to_DR;
135+
diff_pose.pose = ekf_to_dr;
136136
diff_pose_pub_->publish(diff_pose);
137137

138138
// publish diagnostics
@@ -178,7 +178,7 @@ void PoseInstabilityDetector::callback_timer()
178178
}
179179

180180
PoseInstabilityDetector::ThresholdValues PoseInstabilityDetector::calculate_threshold(
181-
double interval_sec)
181+
double interval_sec) const
182182
{
183183
// Calculate maximum longitudinal difference
184184
const double longitudinal_difference =
@@ -229,7 +229,7 @@ PoseInstabilityDetector::ThresholdValues PoseInstabilityDetector::calculate_thre
229229
const double yaw_difference = roll_difference;
230230

231231
// Set thresholds
232-
ThresholdValues result_values;
232+
ThresholdValues result_values{};
233233
result_values.position_x = longitudinal_difference + pose_estimator_longitudinal_tolerance_;
234234
result_values.position_y = lateral_difference + pose_estimator_lateral_tolerance_;
235235
result_values.position_z = vertical_difference + pose_estimator_vertical_tolerance_;

0 commit comments

Comments
 (0)