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.
Fork of 2015robot_main by
Diff: main_ps3.cpp
- Revision:
- 101:b67d33e56b66
- Parent:
- 100:5769dc0e7478
- Child:
- 102:e483c7453f52
- Child:
- 103:ffd3ca4a7a71
--- a/main_ps3.cpp Fri Oct 16 10:58:18 2015 +0000
+++ b/main_ps3.cpp Sat Oct 17 06:04:49 2015 +0000
@@ -15,8 +15,8 @@
//モード切替時に時間を待つ
/***コース選択***/
-//#define BLUE
-#define RED
+#define BLUE
+//#define RED
/***コントローラ選択***/
#define IM920
@@ -39,8 +39,8 @@
#ifdef MESURE
LocalFileSystem local("local");
#endif
+
Timeout MStop;
-
void Restart(){
if(step==10) step=11;
}
@@ -85,7 +85,7 @@
}
/********************************Nomal Mode*********************************/
if((step==0)&&((8650.0>x)&&(x>800.0))) {
- targ_sita=0.035;
+ targ_sita=0.025;
step=1;
}
if((step==1)&&(x>8600.0)) {
@@ -96,23 +96,22 @@
step=3;
spcount=0.0;
flagf=0;
- targ_sita=0.045;
+ targ_sita=0.035;
}
if((step==3)&&(x<2000.0)) {
targ_sita=PI/4;
step=4;
- sendData(7,255);
}
if((step==4)&&(x<0.0)) {
targ_velocity=0.0;
step=114;
}
/***Cylinder***/
- if((x>3100.0)&&(CStep==1)) {
+ if((x>3000.0)&&(CStep==1)) {
if(!skip) sendData(1,1);
CStep=2;
}
- if((x>5940.0)&&(CStep==2)) {
+ if((x>5890.0)&&(CStep==2)) {
if(!skip) sendData(1,3);
CStep=3;
}
@@ -120,18 +119,22 @@
if(!skip) sendData(1,2);
CStep=4;
}
- if((x<6700.0)&&(CStep==4)) {
+ if((x<6730.0)&&(CStep==4)) {
if(!skip) sendData(1,5);
CStep=5;
}
- if((x<6160.0)&&(CStep==5)) {
+ if((x<6170.0)&&(CStep==5)) {
if(!skip) sendData(1,4);
+ CStep=6;
+ }
+ if((x<4000.0)&&(CStep==6)){
+ sendData(7,255);
CStep=114;
}
/////////////////////////////////////////////////////////////////////////
/******************************Middle Mode******************************/
if((step==5)&&((5700.0>x)&&(x>800.0))) {
- targ_sita=0.035;
+ targ_sita=0.025;
step=6;
}
if((step==6)&&(x>7000.0)){
@@ -141,41 +144,47 @@
if((step==7)&&((velocity<500.0)&&(velocity>-500.0))){
flagf=0;
spcount=0.0;
- targ_sita=0.045;
+ targ_sita=0.035;
step=8;
}
if((step==8)&&(x<1900.0)) {
targ_sita=PI/4;
step=9;
- sendData(7,255);
}
if((step==9)&&(x<-10.0)) {
targ_velocity=0.0;
step=114;
}
- if((x>4620.0)&&(CStep==6)){
+ if((x>4620.0)&&(CStep==7)){
sendData(1,5);
- CStep=7;
+ CStep=8;
}
- if((x>5720.0)&&(CStep==7)){
+ if((x>5720.0)&&(CStep==8)){
sendData(1,4);
+ CStep=9;
+ }
+ if((x<4000.0)&&(CStep==9)){
+ sendData(7,255);
CStep=114;
}
/////////////////////////////////////////////////////////////////////////
/*****************************Opponents Mode****************************/
- if((step==15)&&((5700.0>x)&&(x>70.0))) {
- targ_sita=0.035;
+ if((step==15)&&((5700.0>x)&&(x>50.0))) {
+ targ_sita=0.025;
step=16;
}
- if((step==16)&&(x>2800.0)){
+// if((step==16)&&(x>3200.0)){
+ if((step==16)&&(x>2850.0)){
+// if((step==16)&&(x>1350.0)){
targ_velocity=0.0;
step=17;
}
- if((step==17)&&((velocity<500.0)&&(velocity>-500.0))){
+ if((step==17)&&((velocity<5000.0)&&(velocity>-5000.0))){
+// if((step==17)&&((velocity<10.0)&&(velocity>-10.0))){
flagf=0;
spcount=0.0;
- targ_sita=0.045;
+ targ_sita=0.035;
step=18;
}
if((step==18)&&(x<-100.0)){
@@ -184,14 +193,18 @@
step=114;
}
- if((x>950.0)&&(CStep==15)){
+ if((x>1350.0)&&(CStep==15)){
sendData(1,5);
CStep=16;
}
- if((x>2350.0)&&(CStep==16)){
+ if((x>2550.0)&&(CStep==16)){
sendData(1,4);
+ CStep=17;
+ }
+ /*if((x<1000.0)&&(CStep==17)){
+ sendData(7,255);
CStep=114;
- }
+ }*/
/////////////////////////////////////////////////////////////////////////
#else
//Red
@@ -200,8 +213,8 @@
targ_velocity=spcount;
}
/********************************Nomal Mode*********************************/
- if((step==0)&&((8650.0>x)&&(x>850.0))) {
- targ_sita=0.0;
+ if((step==0)&&((8650.0>x)&&(x>800.0))) {
+ targ_sita=-0.015;
step=1;
}
if((step==1)&&(x>8600.0)) {
@@ -212,9 +225,9 @@
step=3;
spcount=0.0;
flagf=0;
- targ_sita=0.0;
+ targ_sita=-0.02;
}
- if((step==3)&&(x<2000.0)) {
+ if((step==3)&&(x<2050.0)) {
targ_sita=-PI/4;
step=4;
sendData(7,255);
@@ -232,7 +245,7 @@
if(!skip) sendData(1,2);
CStep=3;
}
- if((x>7650.0)&&(CStep==3)) {
+ if((x>7550.0)&&(CStep==3)) {
if(!skip) sendData(1,3);
CStep=6;
}
@@ -340,7 +353,7 @@
#endif
mesureSwing();
wait(RATE);
-
+ pc.printf("%f\r\n",(float)((((2.0 * PI) / swingRadVelocity) / 4.0)));
// pc.printf("sita:%f, x:%f, y:%f ,x1:%f, x2:%f ,velocity:%f\r\n",sita,x,y,x1,x2,velocity);
// pc.printf("A2 = %d, X = %d, Y = %d, B = %d, dead = %d\r\n", a2, X, Y, b, deadflag);
// pc.printf("%f %f %f\r\n",cont,swingRadVelocity, (double)SwingSens.getPulses());

