libstp
Robotics library for Botball
Loading...
Searching...
No Matches
angle_utils.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <Eigen/Geometry>
4
#include <cmath>
5
6
namespace
libstp
{
7
namespace
odometry
{
8
9
inline
double
wrapAngle
(
double
angle_rad) {
10
double
wrapped = std::fmod(angle_rad + M_PI, 2.0 * M_PI);
11
if
(wrapped < 0.0) {
12
wrapped += 2.0 * M_PI;
13
}
14
return
wrapped - M_PI;
15
}
16
17
inline
double
angularError
(
double
current_rad,
double
target_rad) {
18
return
wrapAngle
(target_rad - current_rad);
19
}
20
21
inline
double
extractHeading
(
const
Eigen::Quaternionf& orientation) {
22
const
Eigen::Vector3f forward = orientation.normalized() * Eigen::Vector3f::UnitX();
23
return
std::atan2(
static_cast<
double
>
(forward.y()),
24
static_cast<
double
>
(forward.x()));
25
}
26
27
}
// namespace odometry
28
}
// namespace libstp
libstp::odometry
Definition
angle_utils.hpp:7
libstp::odometry::angularError
double angularError(double current_rad, double target_rad)
Definition
angle_utils.hpp:17
libstp::odometry::wrapAngle
double wrapAngle(double angle_rad)
Definition
angle_utils.hpp:9
libstp::odometry::extractHeading
double extractHeading(const Eigen::Quaternionf &orientation)
Definition
angle_utils.hpp:21
libstp
Definition
algorithm.hpp:6
modules
libstp-hal
include
hal
angle_utils.hpp
Generated by
1.15.0