-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfield_sample.cpp
56 lines (49 loc) · 1.1 KB
/
field_sample.cpp
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
#include "field_sample.hpp"
#include "utils.hpp"
field_sample::field_sample(nsecs_t timestamp)
: timestamp(timestamp)
, ball_set(false)
{
}
field_sample::~field_sample()
{
}
void field_sample::add_robot (bot_sample sample)
{
robots.insert(std::make_pair(sample.get_id(), sample));
}
void field_sample::add_ball (ball_sample sample)
{
this->ball = sample;
this->ball_set = true;
}
bool field_sample::get_robot(e_robot id, const bot_sample* &sample) const
{
if (robots.count(id) != 0) {
sample = &robots.at(id);
return true;
}
return false;
}
bool field_sample::get_ball (const ball_sample* &sample) const
{
if (ball_set)
sample = &this->ball;
return ball_set;
}
int field_sample::get_sampled_bots_count() const
{
return (int)robots.size();
}
bool field_sample::get_bot_sampled(e_robot rid) const
{
return robots.count(rid) != 0;
}
bool field_sample::get_ball_sampled() const
{
return ball_set;
}
nsecs_t field_sample::get_timestamp() const
{
return this->timestamp;
}