Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_pose_covariance_modifier): add new node to early fuse gnss and ndt poses #6570

Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ba6ef4f
feat(autoware_pose_covariance_modifier_node): add new node to early f…
Mar 14, 2024
ae60c63
don't change ekf input, change the ndt output name
Mar 14, 2024
3954f20
style(pre-commit): autofix
pre-commit-ci[bot] Mar 14, 2024
ef931ab
fix topic names
meliketanrikulu Mar 14, 2024
070540e
set default false
meliketanrikulu Mar 15, 2024
4aa592d
check position rmse for z
meliketanrikulu Mar 19, 2024
40d6f01
updates after review
meliketanrikulu Apr 2, 2024
7ad97b0
update proposal architecture
meliketanrikulu Apr 2, 2024
7a20279
reduce the reliability of position z
meliketanrikulu Apr 16, 2024
3e4e3f3
set debug param false
meliketanrikulu Apr 17, 2024
f75c1d1
update ndt_covariance_modifier function
meliketanrikulu Apr 19, 2024
2160f0d
add try catch for declarations
meliketanrikulu Apr 19, 2024
8922d85
update README.md
meliketanrikulu Apr 19, 2024
7595500
style(pre-commit): autofix
pre-commit-ci[bot] Apr 19, 2024
dbf8491
move use_autoware_pose_covariance_modifier block in use_ndt_pose
meliketanrikulu Apr 23, 2024
3a6452f
use gnss pose term instead of trusted pose
meliketanrikulu Apr 23, 2024
a4a26bd
rename new_pose_estimator_pub
meliketanrikulu Apr 23, 2024
f4800db
update pose_source equations
meliketanrikulu Apr 23, 2024
d4dff92
fix pose_twist_estimator notation problem
meliketanrikulu Apr 23, 2024
96e5fe6
delete default parameter values and fix camel case
meliketanrikulu Apr 24, 2024
044df72
style(pre-commit): autofix
pre-commit-ci[bot] Apr 24, 2024
7251948
update diagram
meliketanrikulu Apr 24, 2024
77bdca4
Explain the part where NDT error is calculated according to GNSS
meliketanrikulu Apr 24, 2024
322c468
add json files for parameters
meliketanrikulu Apr 24, 2024
d24ad60
Update .prettierrc.yaml
meliketanrikulu Apr 24, 2024
4e5d57a
style(pre-commit): autofix
pre-commit-ci[bot] Apr 24, 2024
0a04598
use stddev instead of rmse
meliketanrikulu Apr 24, 2024
39101a7
use stddev instead of error
meliketanrikulu Apr 25, 2024
57eac65
style(pre-commit): autofix
pre-commit-ci[bot] Apr 25, 2024
48c98ad
update formulas definitions
meliketanrikulu Apr 25, 2024
4f8ceec
update return statement position
meliketanrikulu Apr 25, 2024
ac98abf
Revert "Update .prettierrc.yaml"
meliketanrikulu Apr 25, 2024
943d5bc
Add detailed explanations to README.md
meliketanrikulu Apr 25, 2024
01aadac
attempt to simplify
May 2, 2024
22408e9
style(pre-commit): autofix
pre-commit-ci[bot] May 2, 2024
39fb633
improve the readme
May 3, 2024
54bb564
style(pre-commit): autofix
pre-commit-ci[bot] May 3, 2024
e43c42e
readme
May 3, 2024
74f7f7a
readme tables
May 3, 2024
83e4059
update readme
May 3, 2024
3f4569e
update media
meliketanrikulu May 3, 2024
bde4b82
style(pre-commit): autofix
pre-commit-ci[bot] May 3, 2024
ddcf447
update the tables
May 3, 2024
976ed0a
update media
meliketanrikulu May 3, 2024
0104b4b
interpolation update
May 3, 2024
1ef51b4
style(pre-commit): autofix
pre-commit-ci[bot] May 3, 2024
20e3986
cpp-changes
May 3, 2024
a5a0e28
change everything
May 6, 2024
c48e10b
style(pre-commit): autofix
pre-commit-ci[bot] May 6, 2024
7677df1
concat namespaces
May 6, 2024
b59ef07
test mermaid diagrams
May 6, 2024
8088cba
illustration
May 6, 2024
44bf00f
style(pre-commit): autofix
pre-commit-ci[bot] May 6, 2024
b0e967b
comment
May 6, 2024
331ff8f
style(pre-commit): autofix
pre-commit-ci[bot] May 6, 2024
ca1648b
clean up
May 6, 2024
32f1e3d
remove unused string
May 6, 2024
8135dc0
add ndt stddev bounds as parameter and update launch dir
meliketanrikulu May 7, 2024
64119d3
fix pose_source comparison problem
meliketanrikulu May 7, 2024
0d99ad5
fix duplicate debug part in NDT callback
meliketanrikulu May 7, 2024
1887611
update comments and readme
May 8, 2024
77cbdfb
fix pub topic names
May 8, 2024
2efbb92
style(pre-commit): autofix
pre-commit-ci[bot] May 8, 2024
4d75ad4
update node name in launch to fit new guidelines
May 8, 2024
bf40cca
fix CI
meliketanrikulu May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updates after review
Signed-off-by: meliketanrikulu <melike@leodrive.ai>
meliketanrikulu authored and xmfcx committed May 8, 2024
commit 40d6f0182f28ca2d5c6c751f48bb6c4a6d217717
Original file line number Diff line number Diff line change
@@ -10,5 +10,8 @@
# Threshold value for yaw error
yaw_error_deg_threshold: 0.3 #degrees

# Acceptable delay duration for trusted pose data [sec]
trusted_pose_timeout_sec: 1.0 #seconds

debug:
enable_debug_topics: true
Original file line number Diff line number Diff line change
@@ -17,25 +17,28 @@
#include <rclcpp/rclcpp.hpp>

AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode()
: Node("AutowarePoseCovarianceModifierNode")
: Node("AutowarePoseCovarianceModifierNode"),
trustedPoseLastReceivedTime_(this->now()),
pose_source_(AutowarePoseCovarianceModifierNode::PoseSource::NDT)
{
gnss_error_reliable_max_ =
this->declare_parameter<double>("error_thresholds.gnss_error_reliable_max", 0.10);
gnss_error_unreliable_min_ =
this->declare_parameter<double>("error_thresholds.gnss_error_unreliable_min", 0.25);
yaw_error_deg_threshold_ =
this->declare_parameter<double>("error_thresholds.yaw_error_deg_threshold", 0.3);
trusted_pose_timeout_sec_ = this->declare_parameter<double>("trusted_pose_timeout_sec", 1.0);
debug_ = this->declare_parameter<bool>("debug.enable_debug_topics", false);

trusted_pose_with_cov_sub_ =
this->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"input_trusted_pose_with_cov_topic", 10000,
"input_trusted_pose_with_cov_topic", 10,
std::bind(
&AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback, this,
std::placeholders::_1));

ndt_pose_with_cov_sub_ = this->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"input_ndt_pose_with_cov_topic", 10000,
"input_ndt_pose_with_cov_topic", 10,
std::bind(
&AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback, this,
std::placeholders::_1));
@@ -51,12 +54,12 @@ AutowarePoseCovarianceModifierNode::AutowarePoseCovarianceModifierNode()
"/autoware_pose_covariance_modifier/output/gnss_position_rmse", 10);
}
}
void AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout()
void AutowarePoseCovarianceModifierNode::check_trusted_pose_timeout()
{
auto timeDiff = this->now() - trustedPoseCallbackTime;
if (timeDiff.seconds() > 1.0) {
auto time_diff = this->now() - trustedPoseLastReceivedTime_;
if (time_diff.seconds() > trusted_pose_timeout_sec_) {
RCLCPP_WARN(this->get_logger(), "Trusted Pose Timeout");
pose_source_ = static_cast<int>(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
pose_source_ = AutowarePoseCovarianceModifierNode::PoseSource::NDT;
std_msgs::msg::String selected_pose_type;
selected_pose_type.data = "NDT";
pose_source_pub_->publish(selected_pose_type);
@@ -67,100 +70,106 @@ std::array<double, 36> AutowarePoseCovarianceModifierNode::ndt_covariance_modifi
std::array<double, 36> & in_ndt_covariance)
{
std::array<double, 36> ndt_covariance = in_ndt_covariance;

/*
* ndt_min_rmse_meters = in_ndt_rmse
* ndt_max_rmse_meters = in_ndt_rmse * 2
* ndt_rmse = ndt_max_rmse_meters - (gnss_rmse * (ndt_max_rmse_meters - ndt_min_rmse_meters) /
* normalization_coeff)
* ndt_rmse = (ndt_max_rmse_meters - gnss_rmse) * (ndt_min_rmse_meters) / 0.1
*/
double normalization_coeff = 0.1;
ndt_covariance[0] = std::pow(
((std::sqrt(in_ndt_covariance[0]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[0])) *
(std::sqrt(in_ndt_covariance[0])) / normalization_coeff,

ndt_covariance[X_POS_IDX_] = std::pow(
((std::sqrt(in_ndt_covariance[X_POS_IDX_]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[X_POS_IDX_])) *
(std::sqrt(in_ndt_covariance[X_POS_IDX_])) / 0.1,
2);
ndt_covariance[7] = std::pow(
((std::sqrt(in_ndt_covariance[7]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[7])) *
(std::sqrt(in_ndt_covariance[7])) / normalization_coeff,
ndt_covariance[Y_POS_IDX_] = std::pow(
((std::sqrt(in_ndt_covariance[Y_POS_IDX_]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[Y_POS_IDX_])) *
(std::sqrt(in_ndt_covariance[Y_POS_IDX_])) / 0.1,
2);
ndt_covariance[14] = std::pow(
((std::sqrt(in_ndt_covariance[14]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[14])) *
(std::sqrt(in_ndt_covariance[14])) / normalization_coeff,
ndt_covariance[Z_POS_IDX_] = std::pow(
((std::sqrt(in_ndt_covariance[Z_POS_IDX_]) * 2) -
std::sqrt(trusted_source_pose_with_cov.pose.covariance[Z_POS_IDX_])) *
(std::sqrt(in_ndt_covariance[Z_POS_IDX_])) / 0.1,
2);

ndt_covariance[0] = std::max(ndt_covariance[0], in_ndt_covariance[0]);
ndt_covariance[7] = std::max(ndt_covariance[7], in_ndt_covariance[7]);
ndt_covariance[14] = std::max(ndt_covariance[14], in_ndt_covariance[14]);
ndt_covariance[X_POS_IDX_] = std::max(ndt_covariance[X_POS_IDX_], in_ndt_covariance[X_POS_IDX_]);
ndt_covariance[Y_POS_IDX_] = std::max(ndt_covariance[Y_POS_IDX_], in_ndt_covariance[Y_POS_IDX_]);
ndt_covariance[Z_POS_IDX_] = std::max(ndt_covariance[Z_POS_IDX_], in_ndt_covariance[Z_POS_IDX_]);

return ndt_covariance;
}
void AutowarePoseCovarianceModifierNode::ndt_pose_with_cov_callback(
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr & msg)
{
AutowarePoseCovarianceModifierNode::checkTrustedPoseTimeout();
AutowarePoseCovarianceModifierNode::check_trusted_pose_timeout();

std::array<double, 36> ndt_covariance_in_ = msg->pose.covariance;
std::array<double, 36> out_ndt_covariance_ =
pose_source_ == 1 ? ndt_covariance_modifier(ndt_covariance_in_) : ndt_covariance_in_;
std::array<double, 36> ndt_covariance_in = msg->pose.covariance;
std::array<double, 36> out_ndt_covariance =
pose_source_ == AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT
? ndt_covariance_modifier(ndt_covariance_in)
: ndt_covariance_in;

geometry_msgs::msg::PoseWithCovarianceStamped ndt_pose_with_covariance = *msg;
ndt_pose_with_covariance.pose.covariance = out_ndt_covariance_;
if (pose_source_ != 0) {
ndt_pose_with_covariance.pose.covariance = out_ndt_covariance;
if (pose_source_ != AutowarePoseCovarianceModifierNode::PoseSource::GNSS) {
new_pose_estimator_pub_->publish(ndt_pose_with_covariance);
if (debug_) {
std_msgs::msg::Float32 out_ndt_rmse;
out_ndt_rmse.data = (std::sqrt(ndt_pose_with_covariance.pose.covariance[0]) +
std::sqrt(ndt_pose_with_covariance.pose.covariance[7])) /
2;

out_ndt_rmse.data = static_cast<float>(
(std::sqrt(ndt_pose_with_covariance.pose.covariance[X_POS_IDX_]) +
std::sqrt(ndt_pose_with_covariance.pose.covariance[Y_POS_IDX_])) /
2);
out_ndt_position_rmse_pub_->publish(out_ndt_rmse);
}
}
}
void AutowarePoseCovarianceModifierNode::trusted_pose_with_cov_callback(
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr & msg)
{
trustedPoseCallbackTime = this->now();
trustedPoseLastReceivedTime_ = this->now();
trusted_source_pose_with_cov = *msg;

// double trusted_pose_average_rmse_xy;
// double trusted_pose_yaw_rmse_in_degrees;
double trusted_pose_average_rmse_xy = (std::sqrt(trusted_source_pose_with_cov.pose.covariance[0]) +
std::sqrt(trusted_source_pose_with_cov.pose.covariance[7])) /
2;
double trusted_pose_average_rmse_xy =
(std::sqrt(trusted_source_pose_with_cov.pose.covariance[X_POS_IDX_]) +
std::sqrt(trusted_source_pose_with_cov.pose.covariance[Y_POS_IDX_])) /
2;

double trusted_pose_rmse_z = std::sqrt(trusted_source_pose_with_cov.pose.covariance[0]);
double trusted_pose_yaw_rmse_in_degrees =
std::sqrt(trusted_source_pose_with_cov.pose.covariance[35]) * 180 / M_PI;
double trusted_pose_rmse_z = std::sqrt(trusted_source_pose_with_cov.pose.covariance[Z_POS_IDX_]);
double trusted_pose_yaw_rmse_in_degrees =
std::sqrt(trusted_source_pose_with_cov.pose.covariance[YAW_POS_IDX_]) * 180 / M_PI;

selectPositionSource(trusted_pose_average_rmse_xy, trusted_pose_yaw_rmse_in_degrees,trusted_pose_rmse_z);
update_pose_source_based_on_rmse(
trusted_pose_average_rmse_xy, trusted_pose_rmse_z, trusted_pose_yaw_rmse_in_degrees);

if (pose_source_ != 2) {
if (pose_source_ != AutowarePoseCovarianceModifierNode::PoseSource::NDT) {
new_pose_estimator_pub_->publish(trusted_source_pose_with_cov);
if (debug_) {
std_msgs::msg::Float32 out_gnss_rmse;
out_gnss_rmse.data = trusted_pose_average_rmse_xy;
out_gnss_rmse.data = static_cast<float>(trusted_pose_average_rmse_xy);
out_gnss_position_rmse_pub_->publish(out_gnss_rmse);
}
}
}

void AutowarePoseCovarianceModifierNode::selectPositionSource(
double trusted_pose_average_rmse_xy, double trusted_pose_yaw_rmse_in_degrees, double trusted_pose_rmse_z)
void AutowarePoseCovarianceModifierNode::update_pose_source_based_on_rmse(
double trusted_pose_average_rmse_xy, double trusted_pose_rmse_z,
double trusted_pose_yaw_rmse_in_degrees)
{
std_msgs::msg::String selected_pose_type;
if (
trusted_pose_average_rmse_xy <= gnss_error_reliable_max_ &&
trusted_pose_yaw_rmse_in_degrees < yaw_error_deg_threshold_ && trusted_pose_rmse_z < gnss_error_reliable_max_) {
pose_source_ = static_cast<int>(AutowarePoseCovarianceModifierNode::PoseSource::GNSS);
trusted_pose_yaw_rmse_in_degrees < yaw_error_deg_threshold_ &&
trusted_pose_rmse_z < gnss_error_reliable_max_) {
pose_source_ = AutowarePoseCovarianceModifierNode::PoseSource::GNSS;
selected_pose_type.data = "GNSS";
} else if (trusted_pose_average_rmse_xy <= gnss_error_unreliable_min_ && trusted_pose_rmse_z < gnss_error_unreliable_min_) {
pose_source_ = static_cast<int>(AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT);
} else if (
trusted_pose_average_rmse_xy <= gnss_error_unreliable_min_ &&
trusted_pose_rmse_z < gnss_error_unreliable_min_) {
pose_source_ = AutowarePoseCovarianceModifierNode::PoseSource::GNSS_NDT;
selected_pose_type.data = "GNSS + NDT";
} else {
pose_source_ = static_cast<int>(AutowarePoseCovarianceModifierNode::PoseSource::NDT);
pose_source_ = AutowarePoseCovarianceModifierNode::PoseSource::NDT;
selected_pose_type.data = "NDT";
}
pose_source_pub_->publish(selected_pose_type);
Original file line number Diff line number Diff line change
@@ -44,23 +44,32 @@ class AutowarePoseCovarianceModifierNode : public rclcpp::Node
std::array<double, 36> ndt_covariance_modifier(std::array<double, 36> & in_ndt_covariance);
geometry_msgs::msg::PoseWithCovarianceStamped trusted_source_pose_with_cov;

void checkTrustedPoseTimeout();
void check_trusted_pose_timeout();

private:
void selectPositionSource(
double trusted_pose_average_rmse_xy, double trusted_pose_yaw_rmse_in_degrees, double trusted_pose_average_rmse_z);
void update_pose_source_based_on_rmse(
double trusted_pose_average_rmse_xy, double trusted_pose_rmse_z,
double trusted_pose_yaw_rmse_in_degrees);

enum class PoseSource {
GNSS = 0,
GNSS_NDT = 1,
NDT = 2,
};
void publishPoseSource();
int pose_source_;
rclcpp::Time trustedPoseCallbackTime;

rclcpp::Time trustedPoseLastReceivedTime_;

PoseSource pose_source_;

double gnss_error_reliable_max_, gnss_error_unreliable_min_, yaw_error_deg_threshold_;
double trusted_pose_timeout_sec_;
bool debug_;

// covariance matrix indexes
const int X_POS_IDX_ = 0;
const int Y_POS_IDX_ = 7;
const int Z_POS_IDX_ = 14;
const int YAW_POS_IDX_ = 35;
};

#endif // AUTOWARE_POSE_COVARIANCE_MODIFIER_NODE_HPP_