Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of circle_war_ver_A_NUCLEO_ by
main.cpp@14:3403ce49a37a, 2016-04-05 (annotated)
- Committer:
- baba2357
- Date:
- Tue Apr 05 17:25:09 2016 +0000
- Revision:
- 14:3403ce49a37a
- Parent:
- 11:f8fac9693cd5
??????;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
baba2357 | 1:86d25c1c4bd5 | 1 | #include "mbed.h" |
baba2357 | 1:86d25c1c4bd5 | 2 | #include "pin_file.h" |
baba2357 | 1:86d25c1c4bd5 | 3 | #include "spi_nucleo.h" |
baba2357 | 1:86d25c1c4bd5 | 4 | #include "transfer.h" |
baba2357 | 2:bed6b204e64c | 5 | #include <string.h> |
baba2357 | 14:3403ce49a37a | 6 | #include "arm_updown.h" |
baba2357 | 14:3403ce49a37a | 7 | #include "encoder.h" |
baba2357 | 14:3403ce49a37a | 8 | #include "speed_control.h" |
baba2357 | 14:3403ce49a37a | 9 | #include "math.h" |
baba2357 | 1:86d25c1c4bd5 | 10 | int main(){ |
baba2357 | 14:3403ce49a37a | 11 | setup(); |
baba2357 | 14:3403ce49a37a | 12 | //set-Ticker |
baba2357 | 14:3403ce49a37a | 13 | bole_checker.attach(bole_check,0.2); |
baba2357 | 3:6ab4e8e3aa02 | 14 | spiInit(); |
baba2357 | 8:554e3d643b2d | 15 | push.mode(PullUp); |
baba2357 | 3:6ab4e8e3aa02 | 16 | while(pushed_number==0){ //手動 |
baba2357 | 8:554e3d643b2d | 17 | transfer(); |
baba2357 | 3:6ab4e8e3aa02 | 18 | spi_mbed(); //コントローラーからの信号を読み取る |
baba2357 | 14:3403ce49a37a | 19 | valve1=cilinder; |
baba2357 | 3:6ab4e8e3aa02 | 20 | if(RR==1){ |
baba2357 | 14:3403ce49a37a | 21 | motor_f(1,0.5); //右旋回の関数 |
baba2357 | 14:3403ce49a37a | 22 | motor_r(1,0.5); |
baba2357 | 14:3403ce49a37a | 23 | motor_l(1,0.5); |
baba2357 | 3:6ab4e8e3aa02 | 24 | } |
baba2357 | 3:6ab4e8e3aa02 | 25 | else if(LR==1){ |
baba2357 | 14:3403ce49a37a | 26 | motor_f(-1,0.5); |
baba2357 | 14:3403ce49a37a | 27 | motor_r(-1,0.5); |
baba2357 | 14:3403ce49a37a | 28 | motor_l(-1,0.5); //左旋回の関数 |
baba2357 | 3:6ab4e8e3aa02 | 29 | } |
baba2357 | 8:554e3d643b2d | 30 | else if(onoff==1){ |
baba2357 | 14:3403ce49a37a | 31 | if(updown==1) bole_f=0.1;//上下機構上昇 |
baba2357 | 14:3403ce49a37a | 32 | else bole_b=0.1;//上下機構下降 |
baba2357 | 8:554e3d643b2d | 33 | } |
baba2357 | 3:6ab4e8e3aa02 | 34 | else{ |
baba2357 | 14:3403ce49a37a | 35 | motor_target(((-1)*speed_X)/30,((2/sqrt(3.0)*speed_X)-(speed_Y*2))/30,((2/sqrt(3.0)*speed_X)+(speed_Y*2))/30); |
baba2357 | 3:6ab4e8e3aa02 | 36 | //読み取った値speed_X,speed_Yを速度制御にぶち込む |
baba2357 | 3:6ab4e8e3aa02 | 37 | } |
baba2357 | 14:3403ce49a37a | 38 | } |
baba2357 | 3:6ab4e8e3aa02 | 39 | while(pushed_number==1){ //自動 |
baba2357 | 8:554e3d643b2d | 40 | transfer(); |
baba2357 | 3:6ab4e8e3aa02 | 41 | getGyro(); |
baba2357 | 3:6ab4e8e3aa02 | 42 | //自己位置 |
baba2357 | 14:3403ce49a37a | 43 | //測距関係により検知 |
baba2357 | 14:3403ce49a37a | 44 | //エアシリンダー |
baba2357 | 14:3403ce49a37a | 45 | if(UW*IR){ //幹検知 |
baba2357 | 14:3403ce49a37a | 46 | n++; |
baba2357 | 14:3403ce49a37a | 47 | bole_checker.detach(); |
baba2357 | 1:86d25c1c4bd5 | 48 | } |
baba2357 | 14:3403ce49a37a | 49 | if(n==1){ |
baba2357 | 14:3403ce49a37a | 50 | expand_gf(); |
baba2357 | 14:3403ce49a37a | 51 | }else if(n==2){ |
baba2357 | 14:3403ce49a37a | 52 | expand_ff(); |
baba2357 | 14:3403ce49a37a | 53 | }else if(n>2){ |
baba2357 | 14:3403ce49a37a | 54 | expand_sf(); |
baba2357 | 14:3403ce49a37a | 55 | } |
baba2357 | 3:6ab4e8e3aa02 | 56 | } |
baba2357 | 14:3403ce49a37a | 57 | } |