aaaaa

Dependencies:   mbed Servo

Committer:
t_yamamoto
Date:
Sat Jan 13 13:33:09 2018 +0000
Revision:
0:562021ed1ba9
Child:
1:e73cf2469f83
NaganoNCT-MainBoardNRP2018

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:562021ed1ba9 1 #include "Process.h"
t_yamamoto 0:562021ed1ba9 2
t_yamamoto 0:562021ed1ba9 3 #include "mbed.h"
t_yamamoto 0:562021ed1ba9 4 #include "../../Communication/XBee/XBee.h"
t_yamamoto 0:562021ed1ba9 5 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:562021ed1ba9 6 #include "../../Output/Motor/Motor.h"
t_yamamoto 0:562021ed1ba9 7 //_____________________
t_yamamoto 0:562021ed1ba9 8 /*---------------- HOW TO WRITE ----------------/
t_yamamoto 0:562021ed1ba9 9
t_yamamoto 0:562021ed1ba9 10 ・motor の割り当てを決める
t_yamamoto 0:562021ed1ba9 11 #define TIRE_L 1
t_yamamoto 0:562021ed1ba9 12
t_yamamoto 0:562021ed1ba9 13 ・リミットスイッチの割り当てを決める
t_yamamoto 0:562021ed1ba9 14 #define ARM_L 1
t_yamamoto 0:562021ed1ba9 15
t_yamamoto 0:562021ed1ba9 16 ・他にも自由に定義してもいいです (pwmとか)
t_yamamoto 0:562021ed1ba9 17
t_yamamoto 0:562021ed1ba9 18 /---------------- HOW TO WRITE ----------------*/
t_yamamoto 0:562021ed1ba9 19 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 20
t_yamamoto 0:562021ed1ba9 21
t_yamamoto 0:562021ed1ba9 22
t_yamamoto 0:562021ed1ba9 23
t_yamamoto 0:562021ed1ba9 24
t_yamamoto 0:562021ed1ba9 25
t_yamamoto 0:562021ed1ba9 26
t_yamamoto 0:562021ed1ba9 27
t_yamamoto 0:562021ed1ba9 28 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
t_yamamoto 0:562021ed1ba9 29 //_____________________
t_yamamoto 0:562021ed1ba9 30
t_yamamoto 0:562021ed1ba9 31 // #define USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 32 #ifdef USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 33 Serial pc(SERIAL_TX, SERIAL_RX);
t_yamamoto 0:562021ed1ba9 34 #endif
t_yamamoto 0:562021ed1ba9 35 XBEE::ControllerData *controller;
t_yamamoto 0:562021ed1ba9 36 MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:562021ed1ba9 37
t_yamamoto 0:562021ed1ba9 38 using namespace SWITCH;
t_yamamoto 0:562021ed1ba9 39
t_yamamoto 0:562021ed1ba9 40 void SystemProcess(void) {
t_yamamoto 0:562021ed1ba9 41 while(true) {
t_yamamoto 0:562021ed1ba9 42 controller = XBEE::Controller::GetData();
t_yamamoto 0:562021ed1ba9 43 //____________________________
t_yamamoto 0:562021ed1ba9 44 /*------------------------ HOW TO WRITE ------------------------/
t_yamamoto 0:562021ed1ba9 45
t_yamamoto 0:562021ed1ba9 46 ここにメインのプログラムを書く
t_yamamoto 0:562021ed1ba9 47
t_yamamoto 0:562021ed1ba9 48 ・コントローラから受け取ったデータをもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 49 (コントローラのデータは controller-> で取る)
t_yamamoto 0:562021ed1ba9 50
t_yamamoto 0:562021ed1ba9 51 if(controller->Button.RIGHT) {
t_yamamoto 0:562021ed1ba9 52 motor[TIRE_L].dir = FOR;
t_yamamoto 0:562021ed1ba9 53 motor[TIRE_R].dir = BACK;
t_yamamoto 0:562021ed1ba9 54 motor[TIRE_L].dir = 12.3;
t_yamamoto 0:562021ed1ba9 55 motor[TIRE_R].dir = 12.3;
t_yamamoto 0:562021ed1ba9 56 }
t_yamamoto 0:562021ed1ba9 57
t_yamamoto 0:562021ed1ba9 58 motor[0].dirは FRONT (正転)
t_yamamoto 0:562021ed1ba9 59 BACK (逆転)
t_yamamoto 0:562021ed1ba9 60 BRAKE (ブレーキ)
t_yamamoto 0:562021ed1ba9 61 FREE (フリー)
t_yamamoto 0:562021ed1ba9 62
t_yamamoto 0:562021ed1ba9 63 motor[0].pwmは 0.0(%) ~ 100.0(%)
t_yamamoto 0:562021ed1ba9 64
t_yamamoto 0:562021ed1ba9 65 controllerは XBee.hの構造体の中身
t_yamamoto 0:562021ed1ba9 66
t_yamamoto 0:562021ed1ba9 67 (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください)
t_yamamoto 0:562021ed1ba9 68
t_yamamoto 0:562021ed1ba9 69 ・リミットスイッチの値をもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 70
t_yamamoto 0:562021ed1ba9 71 if(Switch::CheckPushed(ARM_L))
t_yamamoto 0:562021ed1ba9 72 {
t_yamamoto 0:562021ed1ba9 73 if(controller->Button.L)
t_yamamoto 0:562021ed1ba9 74 {
t_yamamoto 0:562021ed1ba9 75 motor[ARM].dir = FRONT;
t_yamamoto 0:562021ed1ba9 76 motor[ARM].pwm = 80.0;
t_yamamoto 0:562021ed1ba9 77 }
t_yamamoto 0:562021ed1ba9 78 if(motor[ARM].dir == BACK)
t_yamamoto 0:562021ed1ba9 79 {
t_yamamoto 0:562021ed1ba9 80 motor[ARM].dir = BRAKE;
t_yamamoto 0:562021ed1ba9 81 }
t_yamamoto 0:562021ed1ba9 82 }
t_yamamoto 0:562021ed1ba9 83
t_yamamoto 0:562021ed1ba9 84 →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false)
t_yamamoto 0:562021ed1ba9 85
t_yamamoto 0:562021ed1ba9 86 ・他にもやりたいことがあったら自由にどうぞ
t_yamamoto 0:562021ed1ba9 87
t_yamamoto 0:562021ed1ba9 88 ps.わからないことがあったら聞いてください
t_yamamoto 0:562021ed1ba9 89
t_yamamoto 0:562021ed1ba9 90 /------------------------ HOW TO WRITE ------------------------*/
t_yamamoto 0:562021ed1ba9 91 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 92
t_yamamoto 0:562021ed1ba9 93
t_yamamoto 0:562021ed1ba9 94
t_yamamoto 0:562021ed1ba9 95
t_yamamoto 0:562021ed1ba9 96
t_yamamoto 0:562021ed1ba9 97
t_yamamoto 0:562021ed1ba9 98
t_yamamoto 0:562021ed1ba9 99
t_yamamoto 0:562021ed1ba9 100
t_yamamoto 0:562021ed1ba9 101
t_yamamoto 0:562021ed1ba9 102
t_yamamoto 0:562021ed1ba9 103
t_yamamoto 0:562021ed1ba9 104
t_yamamoto 0:562021ed1ba9 105
t_yamamoto 0:562021ed1ba9 106 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
t_yamamoto 0:562021ed1ba9 107 //____________________________
t_yamamoto 0:562021ed1ba9 108
t_yamamoto 0:562021ed1ba9 109 MOTOR::Motor::Update(motor);
t_yamamoto 0:562021ed1ba9 110 }
t_yamamoto 0:562021ed1ba9 111 }
t_yamamoto 0:562021ed1ba9 112