-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncNetwork.cpp
59 lines (51 loc) · 1.52 KB
/
syncNetwork.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
#include "SyncNetwork.hpp"
int SyncNetwork::InitNetwork () {
for (int i=0; i<271; i++) {
m_nScannerData[i] = 0;
}
for (int i=0; i<4; i++) {
m_nOdometryticks[i] = 0;
}
for (int i=0; i<4; i++) {
m_nMotorPower[i] = 0;
}
m_fCalculatedDrivingDirection = 0.0;
m_fTargetDrivingDirection = 0.0;
m_fVoltage = 0.0;
m_nLoopTicks = 0;
m_bWasUpdated = false;
m_nUpdateCounter = 0;
return (Network.NetworkInit());
}
int SyncNetwork::Connect () {
return (Network.Connect());
}
void SyncNetwork::UpdateData () {
if (Network.Recv () != -1) {
for (int i=0; i<4; i++) {
m_nOdometryticks[i] = Network.GetData ();
}
for (int i=0; i<271; i++) {
m_nScannerData[i] = static_cast <int> (Network.GetData () / 10.0);
}
for (int i=0; i<4; i++) {
m_nMotorPower[i] = Network.GetData ();
}
m_fCalculatedDrivingDirection = static_cast<float> (Network.GetData ());
m_fCalculatedDrivingDirection /= 100;
m_fCalculatedDrivingDirection -= 90;
m_fTargetDrivingDirection = static_cast<float> (Network.GetData ());
m_fTargetDrivingDirection /= 100;
m_fTargetDrivingDirection -= 90;
m_fVoltage = (static_cast<float> (Network.GetData ()));
m_fVoltage /= 100;
m_nLoopTicks = (Network.GetData ()*10000);
OdometryPositionData.nX = Network.GetData ()-15000;
OdometryPositionData.nY = Network.GetData ()-15000;
OdometryPositionData.fTheta = static_cast<float> (Network.GetData ());
OdometryPositionData.fTheta = (OdometryPositionData.fTheta/1000)-10;
m_bWasUpdated = true;
m_nUpdateCounter ++;
}
//Network.Clear();
}