-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure.h
95 lines (77 loc) · 2.27 KB
/
measure.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef COG_ESTIMATOR_MEASURE_H_
#define COG_ESTIMATOR_MEASURE_H_
#include "cog_estimator.h"
namespace measure {
static constexpr uint_fast8_t num_sensors = 8;
// definition of sensor ports
/* Previously defined as A B C D E F G H */
constexpr uint_fast8_t dats[num_sensors] = {13, 5, 7, 11, A0, A2, 3, 9 };
constexpr uint_fast8_t clks[num_sensors] = {2, 6, 8, 12, A1, A3, 4, 10};
Cog_estimator* R_estimator = {};
Cog_estimator* L_estimator = {};
void setup() {
R_estimator = new Cog_estimator(
new Load_cell(dats[0], clks[0]),
new Load_cell(dats[1], clks[1]),
new Load_cell(dats[2], clks[2]),
new Load_cell(dats[3], clks[3])
);
L_estimator = new Cog_estimator(
new Load_cell(dats[4], clks[4]),
new Load_cell(dats[5], clks[5]),
new Load_cell(dats[6], clks[6]),
new Load_cell(dats[7], clks[7])
);
}
void draw_com() {
int sizx = 10;//>=2
int sizy = 10;//>=2
float valSum = 0;
float Gxl;
float Gyl;
float Gxr;
float Gyr;
valSum += R_estimator->get_center_of_gravity(&Gxr, &Gyr);
valSum += L_estimator->get_center_of_gravity(&Gxl, &Gyl);
int GxlPoint = Gxl * sizx / 2 + sizx / 2;
int GylPoint = Gyl * sizx / 2 + sizy / 2;
int GxrPoint = -Gxr * sizx / 2 + sizx / 2;
int GyrPoint = Gyr * sizx / 2 + sizy / 2;
/* for (int i = 0; i < sizx - 2; i++)
print_c("");*/
strm::cout << "left front right" << strm::endl;
for (int i = sizy; i > 0; i--) //列の管理
{
for (int j = 0; j < sizx; j++)//左脚行の描画
{
if (j == GxlPoint)
{
if (i == GylPoint)
strm::cout << "*";
else
strm::cout << "-";
} else
{
strm::cout << "-";
}
}
strm::cout << " ";
for (int j = 0; j < sizx; j++)//右脚行の描画
{
if (j == GxrPoint)
{
if (i == GyrPoint)
strm::cout << "*";
else
strm::cout << "-";
} else
{
strm::cout << "-";
}
}
strm::cout << strm::endl;
}
strm::cout << Gxl << "\t" << Gyl << "\t" << Gxr << "\t" << Gyr << "\t" << valSum << strm::endl << strm::endl << strm::endl;
}
};
#endif