-
Notifications
You must be signed in to change notification settings - Fork 9
/
tracking.hpp
39 lines (35 loc) · 1.08 KB
/
tracking.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef TRACKING_HPP
#define TRACKING_HPP
#include <functional>
#include "pose.h"
#include <sys/time.h>
#include "trajectory.hpp"
typedef double(*ParamFunc)(double);
// for tracking a trajectory.
// tracker should maintain its own time!(?) no, ControllerWrapper does it now.
// NOTE: error coordinates are in cm!
class Tracker {
Trajectory *traj;
struct Error {
double e1, e2, e3;
Error():e1(0), e2(0), e3(0) {}
Error(Pose ref, Pose p) {
Pose diff = ref - p;
e1 = cos(p.theta())*diff.x() + sin(p.theta())*diff.y();
e2 = -sin(p.theta())*diff.x() + cos(p.theta())*diff.y();
e3 = diff.theta();
e1 = e1/Constants::fieldXConvert;
e2 = e2/Constants::fieldXConvert;
// error coordinates are in cm!!
}
};
public:
Tracker() {}
Tracker(Trajectory *tr): traj(tr) {}
void setTraj(Trajectory *tr) {
traj = tr;
}
MiscData genControls(Pose s, int &vl, int &vr, int prevVl, int prevVr, double t);
Pose getNewStartPose(double t);
};
#endif // TRACKING_HPP