LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
profilepoint.hpp
Go to the documentation of this file.
1
7#ifndef _GEOMETRY_PROFILE_POINT_HPP_
8#define _GEOMETRY_PROFILE_POINT_HPP_
9
10#include <iostream>
11#include <string>
12#include <vector>
13
14#include "controlvector.hpp"
15#include "math/utils.hpp"
16
17namespace squiggles {
38
39 ProfilePoint() = default;
40
46 std::string to_string() const {
47 std::string wheels = "{";
48 for (auto& w : wheel_velocities) {
49 wheels += std::to_string(w);
50 wheels += ", ";
51 }
52 wheels += "}";
53 return "ProfilePoint: {" + vector.to_string() + ", wheels: " + wheels +
54 ", k: " + std::to_string(curvature) +
55 ", t: " + std::to_string(time) + "}";
56 }
57
58 std::string to_csv() const {
59 std::string wheels = "";
60 for (auto& w : wheel_velocities) {
61 wheels += ",";
62 wheels += std::to_string(w);
63 }
64 return vector.to_csv() + "," + std::to_string(curvature) + "," +
65 std::to_string(time) + wheels;
66 }
67
68 bool operator==(const ProfilePoint& other) const {
69 for (std::size_t i = 0; i < wheel_velocities.size(); ++i) {
70 if (!nearly_equal(wheel_velocities[i], other.wheel_velocities[i])) {
71 return false;
72 }
73 }
74 return vector == other.vector && nearly_equal(curvature, other.curvature) &&
75 nearly_equal(time, other.time);
76 }
77
78 friend std::ostream& operator<<(std::ostream& os, const ProfilePoint& p) {
79 return os << "ProfilePoint(ControlVector(Pose(" +
80 std::to_string(p.vector.pose.x) + "," +
81 std::to_string(p.vector.pose.y) + "," +
82 std::to_string(p.vector.pose.yaw) + ")," +
83 std::to_string(p.vector.vel) + "," +
84 std::to_string(p.vector.accel) + "," +
85 std::to_string(p.vector.jerk) + "),{" +
86 std::to_string(p.wheel_velocities[0]) + "," +
87 std::to_string(p.wheel_velocities[1]) + "}," +
88 std::to_string(p.curvature) + "," + std::to_string(p.time) +
89 "),";
90 // return os << p.to_string();
91 }
92
94 std::vector<double> wheel_velocities;
95 double curvature;
96 double time;
97};
98} // namespace squiggles
99
100#endif
std::string to_string() const
Serializes the Control Vector data for debugging.
std::string to_csv() const
double yaw
Definition pose.hpp:63
Copyright 2020 Jonathan Bayless.
bool nearly_equal(const double &a, const double &b, double epsilon=1e-5)
Definition utils.hpp:25
std::string to_string() const
Serializes the Profile Point data for debugging.
std::string to_csv() const
friend std::ostream & operator<<(std::ostream &os, const ProfilePoint &p)
ProfilePoint(ControlVector ivector, std::vector< double > iwheel_velocities, double icurvature, double itime)
Defines a state along a motion profiled path.
bool operator==(const ProfilePoint &other) const
std::vector< double > wheel_velocities