Skip to content

Commit 0c93dde

Browse files
firemarkayrton04
authored andcommitted
Using angles library to normalize angles (#739)
* Using angles library for innovation angle normalization
1 parent cfcb668 commit 0c93dde

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<depend>geographiclib</depend>
2929
<depend>message_filters</depend>
3030
<depend>nav_msgs</depend>
31+
<depend>angles</depend>
3132
<build_depend>rclcpp</build_depend>
3233
<build_depend>rmw_implementation</build_depend>
3334
<depend>sensor_msgs</depend>

src/ekf.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <robot_localization/ekf.hpp>
3535
#include <robot_localization/filter_common.hpp>
36+
#include <angles/angles.h>
3637
#include <Eigen/Dense>
3738
#include <rclcpp/duration.hpp>
3839
#include <vector>
@@ -177,13 +178,7 @@ void Ekf::correct(const Measurement & measurement)
177178
update_indices[i] == StateMemberPitch ||
178179
update_indices[i] == StateMemberYaw)
179180
{
180-
while (innovation_subset(i) < -PI) {
181-
innovation_subset(i) += TAU;
182-
}
183-
184-
while (innovation_subset(i) > PI) {
185-
innovation_subset(i) -= TAU;
186-
}
181+
innovation_subset(i) = ::angles::normalize_angle(innovation_subset(i));
187182
}
188183
}
189184

src/ukf.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <robot_localization/filter_common.hpp>
3434
#include <robot_localization/ukf.hpp>
35+
#include <angles/angles.h>
3536
#include <Eigen/Cholesky>
3637
#include <vector>
3738

@@ -244,13 +245,7 @@ void Ukf::correct(const Measurement & measurement)
244245
update_indices[i] == StateMemberPitch ||
245246
update_indices[i] == StateMemberYaw)
246247
{
247-
while (innovation_subset(i) < -PI) {
248-
innovation_subset(i) += TAU;
249-
}
250-
251-
while (innovation_subset(i) > PI) {
252-
innovation_subset(i) -= TAU;
253-
}
248+
innovation_subset(i) = ::angles::normalize_angle(innovation_subset(i));
254249
}
255250
}
256251

0 commit comments

Comments
 (0)