-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrobot.hpp
More file actions
68 lines (53 loc) · 1.99 KB
/
robot.hpp
File metadata and controls
68 lines (53 loc) · 1.99 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef ROBOT_HPP_INCLUDED
#define ROBOT_HPP_INCLUDED
#include <vector>
#include <random>
#include <cmath>
#include <functional>
// random generator for particle initialization
extern std::default_random_engine generator;
extern std::uniform_real_distribution<double> uniform;
extern std::normal_distribution<double> gaussian;
extern std::normal_distribution<double> gaussian_move;
// GLOBAL
typedef struct {
double x, y;
} Point;
extern std::vector<Point> landmarks;
// MODULO ========================================================================================
/* C++ '%' doesn't work the way I want with negative numbers */
inline double modulo (double numerator, double denominator) {
return (fmod((fmod(numerator, denominator) + denominator), denominator));
}
// CLASS ROBOT ===================================================================================
class Robot {
public:
// Constructor
Robot() {}
Robot(int _size) : _world_size(_size) {}
// Accessors
const double x() const { return _x; }
const double y() const { return _y; }
const double weight() const { return _weight; }
const int size() const { return _world_size; }
const std::vector<double> location() const {
std::vector<double> location = {_x, _y, _orientation};
return location;
}
// Calculations
void sense(std::vector<double> &measurements);
// Modifiers
void setNoise(double FN, double TN, double SN);
void move(double forward_cmd, double turn_cmd);
void measurement_prob(const std::vector<double> &measurements);
private:
int _world_size;
double _x = _world_size * uniform(generator);
double _y = _world_size * uniform(generator);
double _orientation = 2 * M_PI * uniform(generator);
double _forward_noise = 0.0;
double _turn_noise = 0.0;
double _sense_noise = 0.0;
double _weight = 0.0; // importance weight; calculated after robot sensor updates
};
#endif // ROBOT_HPP_INCLUDED