-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ekf_localizer): isolate ekf into independent module (#5424)
* refactor(ekf_localizer): use struct for diag info Signed-off-by: kminoda <koji.minoda@tier4.jp> * fix Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * update Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * move diag_info to ekf_localizer.hpp Signed-off-by: kminoda <koji.minoda@tier4.jp> * remove diag.hpp Signed-off-by: kminoda <koji.minoda@tier4.jp> * refactor(ekf_localizer): remote current_ekf_pose and so on Signed-off-by: kminoda <koji.minoda@tier4.jp> * fix(ekf_localizer): remove unnecessary publishers Signed-off-by: kminoda <koji.minoda@tier4.jp> * still build failes due to one current_ekf_twist_ Signed-off-by: kminoda <koji.minoda@tier4.jp> * now works Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * refactor(ekf_localizer): isolate ekf into module Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * update Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * remove commentou Signed-off-by: kminoda <koji.minoda@tier4.jp> * minor fix Signed-off-by: kminoda <koji.minoda@tier4.jp> * remove unnecessary headers Signed-off-by: kminoda <koji.minoda@tier4.jp> * update print logs Signed-off-by: kminoda <koji.minoda@tier4.jp> * include memory Signed-off-by: kminoda <koji.minoda@tier4.jp> * ekf_ to kalman_filter_ Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix * remove duplicated struct declaration Signed-off-by: kminoda <koji.minoda@tier4.jp> * reflected comments Signed-off-by: kminoda <koji.minoda@tier4.jp> * style(pre-commit): autofix --------- Signed-off-by: kminoda <koji.minoda@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c7aa19e
commit b73330b
Showing
5 changed files
with
454 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
localization/ekf_localizer/include/ekf_localizer/ekf_module.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright 2018-2019 Autoware Foundation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef EKF_LOCALIZER__EKF_MODULE_HPP_ | ||
#define EKF_LOCALIZER__EKF_MODULE_HPP_ | ||
|
||
#include "ekf_localizer/hyper_parameters.hpp" | ||
#include "ekf_localizer/state_index.hpp" | ||
#include "ekf_localizer/warning.hpp" | ||
|
||
#include <kalman_filter/kalman_filter.hpp> | ||
#include <kalman_filter/time_delay_kalman_filter.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <geometry_msgs/msg/pose_stamped.hpp> | ||
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp> | ||
#include <geometry_msgs/msg/transform_stamped.hpp> | ||
#include <geometry_msgs/msg/twist_stamped.hpp> | ||
#include <geometry_msgs/msg/twist_with_covariance_stamped.hpp> | ||
|
||
#include <memory> | ||
|
||
struct EKFDiagnosticInfo | ||
{ | ||
EKFDiagnosticInfo() | ||
: no_update_count(0), | ||
queue_size(0), | ||
is_passed_delay_gate(true), | ||
delay_time(0), | ||
delay_time_threshold(0), | ||
is_passed_mahalanobis_gate(true), | ||
mahalanobis_distance(0) | ||
{ | ||
} | ||
|
||
size_t no_update_count; | ||
size_t queue_size; | ||
bool is_passed_delay_gate; | ||
double delay_time; | ||
double delay_time_threshold; | ||
bool is_passed_mahalanobis_gate; | ||
double mahalanobis_distance; | ||
}; | ||
|
||
class EKFModule | ||
{ | ||
private: | ||
using PoseWithCovariance = geometry_msgs::msg::PoseWithCovarianceStamped; | ||
using TwistWithCovariance = geometry_msgs::msg::TwistWithCovarianceStamped; | ||
using Pose = geometry_msgs::msg::PoseStamped; | ||
using Twist = geometry_msgs::msg::TwistStamped; | ||
|
||
public: | ||
EKFModule(std::shared_ptr<Warning> warning, const HyperParameters params); | ||
|
||
void initialize( | ||
const PoseWithCovariance & initial_pose, | ||
const geometry_msgs::msg::TransformStamped & transform); | ||
|
||
geometry_msgs::msg::PoseStamped getCurrentPose( | ||
const rclcpp::Time & current_time, const double z, const double roll, const double pitch, | ||
bool get_biased_yaw) const; | ||
geometry_msgs::msg::TwistStamped getCurrentTwist(const rclcpp::Time & current_time) const; | ||
double getYawBias() const; | ||
std::array<double, 36> getCurrentPoseCovariance() const; | ||
std::array<double, 36> getCurrentTwistCovariance() const; | ||
|
||
void predictWithDelay(const double dt); | ||
bool measurementUpdatePose( | ||
const PoseWithCovariance & pose, const double dt, const rclcpp::Time & t_curr, | ||
EKFDiagnosticInfo & pose_diag_info); | ||
bool measurementUpdateTwist( | ||
const TwistWithCovariance & twist, const double dt, const rclcpp::Time & t_curr, | ||
EKFDiagnosticInfo & twist_diag_info); | ||
geometry_msgs::msg::PoseWithCovarianceStamped compensatePoseWithZDelay( | ||
const PoseWithCovariance & pose, const double delay_time); | ||
|
||
private: | ||
TimeDelayKalmanFilter kalman_filter_; | ||
|
||
std::shared_ptr<Warning> warning_; | ||
const int dim_x_; | ||
const HyperParameters params_; | ||
}; | ||
|
||
#endif // EKF_LOCALIZER__EKF_MODULE_HPP_ |
Oops, something went wrong.