Skip to content

Commit

Permalink
Add parameter for applying offset to yaw angle
Browse files Browse the repository at this point in the history
  • Loading branch information
Haruki-Ohga committed Sep 18, 2024
1 parent ec44a6c commit 2914909
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class EKFLocalizer : public rclcpp::Node
double proc_cov_vx_d_; //!< @brief discrete process noise in d_vx=0
double proc_cov_wz_d_; //!< @brief discrete process noise in d_wz=0

/* yaw_offset */
double yaw_offset; //!< @brief wz process noise

enum IDX {
X = 0,
Y = 1,
Expand Down
3 changes: 3 additions & 0 deletions localization/ekf_localizer/launch/ekf_localizer.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<arg name="proc_stddev_vx_c" default="5.0"/>
<arg name="proc_stddev_wz_c" default="1.0"/>

<!-- yaw offset -->
<arg name="yaw_offset" default="0.0"/>

<!-- output topic name -->
<arg name="output_odom_name" default="ekf_odom"/>
<arg name="output_pose_name" default="ekf_pose"/>
Expand Down
3 changes: 3 additions & 0 deletions localization/ekf_localizer/src/ekf_localizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ EKFLocalizer::EKFLocalizer(const std::string & node_name, const rclcpp::NodeOpti
proc_stddev_yaw_bias_c_ = 0.0;
}

yaw_offset_ = declare_parameter("yaw_offset", 0.0);

/* convert to continuous to discrete */
proc_cov_vx_d_ = std::pow(proc_stddev_vx_c_ * ekf_dt_, 2.0);
proc_cov_wz_d_ = std::pow(proc_stddev_wz_c_ * ekf_dt_, 2.0);
Expand Down Expand Up @@ -332,6 +334,7 @@ void EKFLocalizer::callbackTwistWithCovariance(
geometry_msgs::msg::TwistStamped twist;
twist.header = msg->header;
twist.twist = msg->twist.twist;
twist.twist.angular.z = twist.twist.angular.z + yaw_offset_; // add yaw_offset_
current_twist_ptr_ = std::make_shared<geometry_msgs::msg::TwistStamped>(twist);
current_twist_covariance_ = msg->twist.covariance;
}
Expand Down

0 comments on commit 2914909

Please sign in to comment.