Skip to content

Commit

Permalink
feat(ekf_localizer): tf publisher as an option (autowarefoundation#6004)
Browse files Browse the repository at this point in the history
Signed-off-by: amadeuszsz <amadeusz.szymko@put.poznan.pl>
  • Loading branch information
amadeuszsz authored and karishma1911 committed May 26, 2024
1 parent 9b94405 commit 333e978
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions localization/ekf_localizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ The parameters are set in `launch/ekf_localizer.launch` .
| show_debug_info | bool | Flag to display debug info | false |
| predict_frequency | double | Frequency for filtering and publishing [Hz] | 50.0 |
| tf_rate | double | Frequency for tf broadcasting [Hz] | 10.0 |
| publish_tf | bool | Whether to publish tf | true |
| extend_state_step | int | Max delay step which can be dealt with in EKF. Large number increases computational cost. | 50 |
| enable_yaw_bias_estimation | bool | Flag to enable yaw bias estimation | true |

Expand Down
1 change: 1 addition & 0 deletions localization/ekf_localizer/config/ekf_localizer.param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
enable_yaw_bias_estimation: true
predict_frequency: 50.0
tf_rate: 50.0
publish_tf: true
extend_state_step: 50

# for Pose measurement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HyperParameters
ekf_rate(node->declare_parameter("predict_frequency", 50.0)),
ekf_dt(1.0 / std::max(ekf_rate, 0.1)),
tf_rate_(node->declare_parameter("tf_rate", 10.0)),
publish_tf_(node->declare_parameter("publish_tf", true)),
enable_yaw_bias_estimation(node->declare_parameter("enable_yaw_bias_estimation", true)),
extend_state_step(node->declare_parameter("extend_state_step", 50)),
pose_frame_id(node->declare_parameter("pose_frame_id", std::string("map"))),
Expand Down Expand Up @@ -60,6 +61,7 @@ class HyperParameters
const double ekf_rate;
const double ekf_dt;
const double tf_rate_;
const bool publish_tf_;
const bool enable_yaw_bias_estimation;
const int extend_state_step;
const std::string pose_frame_id;
Expand Down
8 changes: 5 additions & 3 deletions localization/ekf_localizer/src/ekf_localizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ EKFLocalizer::EKFLocalizer(const std::string & node_name, const rclcpp::NodeOpti
this, get_clock(), rclcpp::Duration::from_seconds(ekf_dt_),
std::bind(&EKFLocalizer::timerCallback, this));

timer_tf_ = rclcpp::create_timer(
this, get_clock(), rclcpp::Rate(params_.tf_rate_).period(),
std::bind(&EKFLocalizer::timerTFCallback, this));
if (params_.publish_tf_) {
timer_tf_ = rclcpp::create_timer(
this, get_clock(), rclcpp::Rate(params_.tf_rate_).period(),
std::bind(&EKFLocalizer::timerTFCallback, this));
}

pub_pose_ = create_publisher<geometry_msgs::msg::PoseStamped>("ekf_pose", 1);
pub_pose_cov_ =
Expand Down

0 comments on commit 333e978

Please sign in to comment.