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
13using namespace rct;
14
15Timer timer;
16Odom<3> odom{};
17Motor motors[3] = {{D10, D11}, {D12, D13}, {D12, D13}};
18ChassisAuto<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
25bool check_reached(const Coordinate& dst, const Coordinate& pos);
26
27int 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);
40
41 pre = now;
42 }
43}
44
50 if(static PollingTimer wait; wait(1s)) {
51 return true;
52 } else {
53 if(distance(dst, pos) > 100) wait.reset();
54 return false;
55 }
56}
bool check_reached(const Coordinate &dst, const Coordinate &pos)
hoge
Definition main.cpp:49
足回りの位置のPID制御を行うChassisAutoを提供する。
オドメトリを行う Odom クラスを提供する。
オムニの制御を行う Omni クラスを提供する。
constexpr float distance(const Coordinate &p1, const Coordinate &p2)
2つの座標間の距離を計算する。
robot control library
Definition Chassis.h:16
N輪オムニの制御を行うクラス。
Definition Omni.h:25
PID制御のゲイン
Definition Pid.h:21