-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcam_offset.cpp
63 lines (58 loc) · 1.8 KB
/
cam_offset.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
57
58
59
60
61
62
63
#include <cam_offset.h>
#include <cstdio>
using namespace std;
float CamOffset::headPitch=0;
float CamOffset::headRoll=0;
int CamOffset::lowerCamOffsetX=0;
int CamOffset::lowerCamOffsetY=0;
int CamOffset::lowerCamOffsetCnt=0;
float CamOffset::bodyPitch=0;
float CamOffset::bodyRoll=0;
float CamOffset::deltaPitch[30];
float CamOffset::deltaRoll[30];
int CamOffset::deltaIdx=0;
void CamOffset::init(){
bool paramsRead=false;
FILE *fp=fopen("camOffset_v2.txt","r");
if(fp!=nullptr){
int read=fscanf(fp,"headPitch: %f\n"
"headRoll: %f\n"
"bodyPitch: %f\n"
"bodyRoll: %f\n"
"lowerCamOffsetX: %d\n"
"lowerCamOffsetY: %d",
&headPitch,&headRoll,&bodyPitch,&bodyRoll,&lowerCamOffsetX,&lowerCamOffsetY);
if(read==6){
paramsRead=true;
}
fclose(fp);
}
if(!paramsRead){
headPitch=0;
headRoll=0;
bodyPitch=0;
bodyRoll=0;
lowerCamOffsetX=0;
lowerCamOffsetY=0;
lowerCamOffsetCnt=0;
printf("-----------------------------------------\n"
"| |\n"
"| NO CAM OFFSETS! |\n"
"| USE THE CALIBRATION AGENT! |\n"
"| |\n"
"-----------------------------------------\n");
}
}
void CamOffset::write(){
FILE *fp=fopen(".camOffset_v2.txt","w");
fprintf(fp,"headPitch: %f\n"
"headRoll: %f\n"
"bodyPitch: %f\n"
"bodyRoll: %f\n"
"lowerCamOffsetX: %d\n"
"lowerCamOffsetY: %d",
headPitch,headRoll,bodyPitch,bodyRoll,lowerCamOffsetX,lowerCamOffsetY);
fflush(fp);
fclose(fp);
rename(".camOffset_v2.txt","camOffset_v2.txt");
}