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

Galactic #9

Merged
merged 5 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ find_package(yaml_cpp_vendor REQUIRED)

# Geographiclib installs FindGeographicLib.cmake to this non-standard location
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake/geographiclib/")
find_package(GeographicLib REQUIRED COMPONENTS STATIC)
find_package(GeographicLib REQUIRED)

set(library_name rl_lib)

Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<depend>geographiclib</depend>
<depend>message_filters</depend>
<depend>nav_msgs</depend>
<depend>angles</depend>
<build_depend>rclcpp</build_depend>
<build_depend>rmw_implementation</build_depend>
<depend>sensor_msgs</depend>
Expand Down
9 changes: 2 additions & 7 deletions src/ekf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <robot_localization/ekf.hpp>
#include <robot_localization/filter_common.hpp>
#include <angles/angles.h>
#include <Eigen/Dense>
#include <rclcpp/duration.hpp>
#include <vector>
Expand Down Expand Up @@ -177,13 +178,7 @@ void Ekf::correct(const Measurement & measurement)
update_indices[i] == StateMemberPitch ||
update_indices[i] == StateMemberYaw)
{
while (innovation_subset(i) < -PI) {
innovation_subset(i) += TAU;
}

while (innovation_subset(i) > PI) {
innovation_subset(i) -= TAU;
}
innovation_subset(i) = ::angles::normalize_angle(innovation_subset(i));
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/ros_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ RosFilter<T>::RosFilter(const rclcpp::NodeOptions & options)
latest_control_(),
last_diag_time_(0, 0, RCL_ROS_TIME),
last_published_stamp_(0, 0, RCL_ROS_TIME),
predict_to_current_time_(false),
last_set_pose_time_(0, 0, RCL_ROS_TIME),
latest_control_time_(0, 0, RCL_ROS_TIME),
tf_timeout_(0ns),
Expand Down Expand Up @@ -849,6 +850,8 @@ void RosFilter<T>::loadParams()
// Update frequency and sensor timeout
frequency_ = this->declare_parameter("frequency", 30.0);

predict_to_current_time_ = this->declare_parameter<bool>("predict_to_current_time", false);

double sensor_timeout = this->declare_parameter("sensor_timeout", 1.0 / frequency_);
filter_.setSensorTimeout(rclcpp::Duration::from_seconds(sensor_timeout));

Expand Down Expand Up @@ -2582,9 +2585,10 @@ bool RosFilter<T>::prepareAcceleration(
// from filter state to transform and remove acceleration
const Eigen::VectorXd & state = filter_.getState();
tf2::Matrix3x3 stateTmp;
stateTmp.setRPY(state(StateMemberRoll),
state(StateMemberPitch),
state(StateMemberYaw));
stateTmp.setRPY(
state(StateMemberRoll),
state(StateMemberPitch),
state(StateMemberYaw));

// transform state orientation to IMU frame
tf2::Transform imuFrameTrans;
Expand Down Expand Up @@ -3341,7 +3345,7 @@ bool RosFilter<T>::revertTo(const rclcpp::Time & time)
// If we have a valid reversion state, revert
if (last_history_state) {
// Reset filter to the latest state from the queue.
const FilterStatePtr & state = filter_state_history_.back();
const FilterStatePtr & state = last_history_state;
filter_.setState(state->state_);
filter_.setEstimateErrorCovariance(state->estimate_error_covariance_);
filter_.setLastMeasurementTime(state->last_measurement_time_);
Expand Down
9 changes: 2 additions & 7 deletions src/ukf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <robot_localization/filter_common.hpp>
#include <robot_localization/ukf.hpp>
#include <angles/angles.h>
#include <Eigen/Cholesky>
#include <vector>

Expand Down Expand Up @@ -244,13 +245,7 @@ void Ukf::correct(const Measurement & measurement)
update_indices[i] == StateMemberPitch ||
update_indices[i] == StateMemberYaw)
{
while (innovation_subset(i) < -PI) {
innovation_subset(i) += TAU;
}

while (innovation_subset(i) > PI) {
innovation_subset(i) -= TAU;
}
innovation_subset(i) = ::angles::normalize_angle(innovation_subset(i));
}
}

Expand Down