Skip to content

Commit f5d08a2

Browse files
ayrton04sybrenkappert
authored andcommitted
Fixing angular acceleration initialisation (#945)
1 parent 434b200 commit f5d08a2

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

include/robot_localization/ros_filter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ class RosFilter : public rclcpp::Node
690690

691691
//! @brief Covariance of the calculated angular acceleration
692692
//!
693-
Eigen::MatrixXd angular_acceleration_cov_;
693+
Eigen::Matrix3d angular_acceleration_cov_;
694694

695695
//! @brief Stores the first measurement from each topic for relative
696696
//! measurements

src/ros_filter.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,21 @@ void RosFilter<T>::reset()
164164
filter_state_history_.clear();
165165
measurement_history_.clear();
166166

167+
angular_acceleration_.setZero();
168+
angular_acceleration_cov_.setIdentity();
169+
angular_acceleration_cov_ *= 0.01;
170+
171+
last_state_twist_rot_.setZero();
172+
167173
// Also set the last set pose time, so we ignore all messages
168174
// that occur before it
169175
last_set_pose_time_ = rclcpp::Time(0, 0, RCL_ROS_TIME);
170176
last_diag_time_ = rclcpp::Time(0, 0, RCL_ROS_TIME);
171177
latest_control_time_ = rclcpp::Time(0, 0, RCL_ROS_TIME);
172178
last_published_stamp_ = rclcpp::Time(0, 0, RCL_ROS_TIME);
173179

180+
last_diff_time_ = this->now().seconds();
181+
174182
// clear tf buffer to avoid TF_OLD_DATA errors
175183
tf_buffer_->clear();
176184

@@ -731,6 +739,10 @@ void RosFilter<T>::integrateMeasurements(const rclcpp::Time & current_time)
731739
restored_measurement_count--;
732740
}
733741

742+
auto previous_state = filter_.getState();
743+
auto previous_covar = filter_.getEstimateErrorCovariance();
744+
auto last_measurement_time = filter_.getLastMeasurementTime();
745+
734746
// This will call predict and, if necessary, correct
735747
filter_.processMeasurement(*(measurement.get()));
736748

@@ -1777,9 +1789,6 @@ void RosFilter<T>::loadParams()
17771789
}
17781790
} while (more_params);
17791791

1780-
angular_acceleration_cov_.resize(ORIENTATION_SIZE, ORIENTATION_SIZE);
1781-
angular_acceleration_cov_.setZero();
1782-
17831792
// Now that we've checked if IMU linear acceleration is being used, we can
17841793
// determine our final control parameters
17851794
if (use_control_ && std::accumulate(
@@ -2073,6 +2082,12 @@ void RosFilter<T>::initialize()
20732082
this->get_clock()->wait_until_started();
20742083
}
20752084

2085+
angular_acceleration_.setZero();
2086+
angular_acceleration_cov_.setIdentity();
2087+
angular_acceleration_cov_ *= 1e-6;
2088+
2089+
last_state_twist_rot_.setZero();
2090+
20762091
diagnostic_updater_ = std::make_unique<diagnostic_updater::Updater>(
20772092
shared_from_this());
20782093
diagnostic_updater_->setHardwareID("none");
@@ -2100,6 +2115,7 @@ void RosFilter<T>::initialize()
21002115
&max_frequency_, 0.1, 10));
21012116

21022117
last_diag_time_ = this->now();
2118+
last_diff_time_ = this->now().seconds();
21032119

21042120
// Clear out the transforms
21052121
world_base_link_trans_msg_.transform =

0 commit comments

Comments
 (0)