LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
pose.hpp
Go to the documentation of this file.
1
7#ifndef _GEOMETRY_POSE_HPP_
8#define _GEOMETRY_POSE_HPP_
9
10#include <cmath>
11#include <string>
12
13#include "math/utils.hpp"
14
15namespace squiggles {
16class Pose {
17 public:
25 Pose(double ix, double iy, double iyaw) : x(ix), y(iy), yaw(iyaw) {}
26
27 Pose() = default;
28
36 double dist(const Pose& other) const {
37 return std::sqrt((x - other.x) * (x - other.x) +
38 (y - other.y) * (y - other.y));
39 }
40
46 std::string to_string() const {
47 return "Pose: {x: " + std::to_string(x) + ", y: " + std::to_string(y) +
48 ", yaw: " + std::to_string(yaw) + "}";
49 }
50
51 std::string to_csv() const {
52 return std::to_string(x) + "," + std::to_string(y) + "," +
53 std::to_string(yaw);
54 }
55
56 bool operator==(const Pose& other) const {
57 return nearly_equal(x, other.x) && nearly_equal(y, other.y) &&
58 nearly_equal(yaw, other.yaw);
59 }
60
61 double x;
62 double y;
63 double yaw;
64};
65} // namespace squiggles
66
67#endif
bool operator==(const Pose &other) const
Definition pose.hpp:56
std::string to_csv() const
Definition pose.hpp:51
double yaw
Definition pose.hpp:63
double dist(const Pose &other) const
Calculates the Euclidean distance between this pose and another.
Definition pose.hpp:36
Pose(double ix, double iy, double iyaw)
Specifies a point and heading in 2D space.
Definition pose.hpp:25
std::string to_string() const
Serializes the Pose data for debugging.
Definition pose.hpp:46
Pose()=default
Copyright 2020 Jonathan Bayless.
bool nearly_equal(const double &a, const double &b, double epsilon=1e-5)
Definition utils.hpp:25