-
Notifications
You must be signed in to change notification settings - Fork 4
/
light_sensor.hpp
48 lines (46 loc) · 1.12 KB
/
light_sensor.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
40
41
42
43
44
45
46
47
48
#ifndef FASTSIM_LIGHT_SENSOR_HPP_
#define FASTSIM_LIGHT_SENSOR_HPP_
#include <boost/shared_ptr.hpp>
#include "posture.hpp"
#include "map.hpp"
namespace fastsim {
/// detect an colored illuminated switch in the given direction
/// (angle) and within the angular range. There is no range limit.
/// light sensors DONT'T SEE TROUGH OBSTACLES
class LightSensor {
public:
LightSensor(int color, float angle, float range) :
_color(color), _angle(angle), _range(range),
_activated(false),_num(0) {
}
int update(const Posture& pos,
const boost::shared_ptr<Map>& map);
int get_color() const {
return _color;
}
float get_angle() const {
return _angle;
}
float get_range() const {
return _range;
}
bool get_activated() const {
return _activated;
}
unsigned int get_num() const {
return _num;
}
protected:
// the "color" (i.e. light identifier) detected
int _color;
//
float _angle;
//
float _range;
//
bool _activated;
// sensor number (for display only)
unsigned int _num;
};
}
#endif