Chassis
v2.1.1
Chassisはロボコンでの足回り制御を行うためのC++ライブラリである。
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
3
#include <../snippets/Motor.h>
4
#include <
ChassisAuto.h
>
5
#include <
Odom.h
>
6
#include <
Omni.h
>
7
#include <PollingTimer.h>
8
#include <mbed.h>
9
10
#include <array>
11
#include <functional>
12
13
using namespace
rct
;
14
15
Timer
timer;
16
Odom<3>
odom{};
17
Motor
motors[3] = {{
D10
,
D11
}, {
D12
,
D13
}, {
D12
,
D13
}};
18
ChassisAuto<Omni<3>
> chassis{[](std::array<float,3>
pwm
) {
19
for
(
int
i
= 0;
i
< 3; ++
i
) {
20
motors[
i
] =
pwm
[
i
];
21
}
22
},
23
PidGain
{0.1}};
24
25
bool
check_reached
(
const
Coordinate
&
dst
,
const
Coordinate
&
pos
);
26
27
int
main() {
28
timer.start();
29
while
(1) {
30
// エンコーダ角変位の変化量を引数に渡す
31
odom.integrate({0, 0, 0});
32
auto
now
= timer.elapsed_time();
33
static
auto
pre
=
now
;
34
auto
delta
=
pre
-
now
;
35
36
Coordinate
dst
= {0, 1000, 0.0};
37
Coordinate
pos
= odom.get();
38
chassis.auto_move(
dst
,
pos
,
delta
);
39
check_reached
(
dst
,
pos
);
40
41
pre
=
now
;
42
}
43
}
44
49
bool
check_reached
(
const
Coordinate
&
dst
,
const
Coordinate
&
pos
) {
50
if
(
static
PollingTimer
wait
;
wait
(1
s
)) {
51
return
true
;
52
}
else
{
53
if
(
distance
(
dst
,
pos
) > 100)
wait
.reset();
54
return
false
;
55
}
56
}
check_reached
bool check_reached(const Coordinate &dst, const Coordinate &pos)
hoge
Definition
main.cpp:49
ChassisAuto.h
足回りの位置のPID制御を行うChassisAutoを提供する。
Odom.h
オドメトリを行う Odom クラスを提供する。
Omni.h
オムニの制御を行う Omni クラスを提供する。
rct::distance
constexpr float distance(const Coordinate &p1, const Coordinate &p2)
2つの座標間の距離を計算する。
Definition
CoordinateUnit.h:86
rct
robot control library
Definition
Chassis.h:16
rct::CoordinateUnit< 0 >
rct::Omni
N輪オムニの制御を行うクラス。
Definition
Omni.h:25
rct::PidGain
PID制御のゲイン
Definition
Pid.h:21
examples
Mbed
ChassisAuto
main.cpp
Generated by
1.9.8