-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSwarmBot.h
80 lines (71 loc) · 1.14 KB
/
SwarmBot.h
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
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef SWARMBOT_H
#define SWARMBOT_H
#include <bits/stdc++.h>
using namespace std;
typedef struct
{
int x;
int y;
}Points;
class SwarmBot{
public :
int BotID;
float x;
float y;
float theta;
SwarmBot(int id){
x=0;
y=0;
theta=0;
BotID=id;
}
SwarmBot(int id,int x1, int x2){
x=x1;
y=x2;
theta=0.0;
BotID=id;
}
SwarmBot(){
x=0;
y=0;
theta=0;
BotID=0;
}
};
void writeSwarmBot(SwarmBot v){
fstream fs;
fs.open("POSE.txt",ios::app);
fs.write((char*)&v,sizeof(SwarmBot));
fs.close();
}
void destination(Points p){
fstream fs;
fs.open("Dest.txt",ios::app);
fs.write((char*)&p,sizeof(Points));
fs.close();
}
vector<SwarmBot> getSwarmBots(){
vector<SwarmBot> bots;
SwarmBot v;
fstream fs;
fs.open("POSE.txt");
while(!fs.eof()){
fs.read((char*)&v,sizeof(SwarmBot));
bots.push_back(v);
}
fs.close();
return bots;
}
vector<Points> getAllDest(){
vector<Points> pts;
Points p;
fstream fs;
fs.open("Dest.txt");
while(!fs.eof()){
fs.read((char*)&p,sizeof(Points));
pts.push_back(p);
}
fs.close();
return pts;
}
#endif