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 MPU6050 Kalman BMP180
Revision 12:6a3c0e9075eb, committed 2019-03-10
- Comitter:
- sashida_h
- Date:
- Sun Mar 10 11:47:23 2019 +0000
- Parent:
- 11:c90db1500720
- Child:
- 13:3e6411bfd581
- Commit message:
- 2019_0310_2047
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Mar 10 08:17:44 2019 +0000
+++ b/main.cpp Sun Mar 10 11:47:23 2019 +0000
@@ -65,9 +65,7 @@
}
alt_gnd = _median(alt_buff,NUM_CNT_MEDIAN);
wait(2.0);
- pc.printf("Hello World!\r\n");
- wait(1.0);
- pc.printf("f:Flight_mode_on\r\n");
+ pc.printf("0,0,0,0,0\r\n");
wait(1.0);
timer_data.start();
servo1_signal = 1;
@@ -85,14 +83,16 @@
servo1.pulsewidth(0.0006);
servo2.pulsewidth(0.0006);
mpu.getAccelero(acc);
- pc.printf("OPEN:%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)));
+ //pc.printf("OPEN:%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)));
+ pc.printf("0,%f,%f,0,%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)),(acc[1]/9.81),timer_data.read());
}
if(c[0] == 'l'){
myled = 0;
servo1.pulsewidth(0.0024);
servo2.pulsewidth(0.0024);
mpu.getAccelero(acc);
- pc.printf("LOCK:%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)));
+ //pc.printf("LOCK:%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)));
+ pc.printf("0,%f,%f,0,%f\r\n",sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0)),(acc[1]/9.81),timer_data.read());
}
if(c[0] == 'f'){
//pc.printf("flight_mode\r\n");
@@ -109,7 +109,9 @@
}
acc_abs = _median(acc_buff,NUM_CNT_MEDIAN);
if(timer_data.read() - t > TIME_SEND){
- pc.printf("LAUNCH,acc:%f,time:%3f,cnt:%d\r\n",acc_abs,timer_data.read(),cnt_judge);
+ //pc.printf("LAUNCH,acc:%f,time:%3f,cnt:%d\r\n",acc_abs,timer_data.read(),cnt_judge);
+ pc.printf("1,%f,%f,0,%3f\r\n",acc_abs,acc_abs,timer_data.read());
+
t = timer_data.read();
}
/*加速度判定*/
@@ -127,8 +129,19 @@
case RISE:
while(timer_open.read() < TIME_BURNING){
- pc.printf("RISE,time from launch:%f\r\n",timer_open.read());
- wait(1.0);
+ for(cnt_data=0;cnt_data<NUM_CNT_MEDIAN;cnt_data++){
+ alt_buff[cnt_data] = _getAlt();
+ }
+ alt_md = _median(alt_buff,NUM_CNT_MEDIAN);
+ alt_md = alt_md - alt_gnd;
+ for(cnt_data=0;cnt_data<NUM_CNT_MEDIAN;cnt_data++){
+ mpu.getAccelero(acc);
+ acc_buff[cnt_data] = sqrt(pow(acc[0]/9.81,2.0)+pow(acc[1]/9.81,2.0)+pow(acc[2]/9.81,2.0));
+ }
+ acc_abs = _median(acc_buff,NUM_CNT_MEDIAN);
+ //pc.printf("RISE,time from launch:%f\r\n",timer_open.read());
+ pc.printf("3,%f,%f,%f,%3f\r\n",acc_abs,acc_abs,alt_md,timer_open.read());
+ wait(0.9);
i=0;
timer_data.reset();
}
@@ -144,7 +157,8 @@
alt_md = _median(alt_buff,NUM_CNT_MEDIAN);
alt_md = alt_md - alt_gnd;
if(timer_open.read() - t > TIME_SEND){
- pc.printf("OPEN,alt:%f,time:%3f,cnt:%d\r\n",alt_md,timer_open.read(),cnt_judge);
+ //pc.printf("OPEN,alt:%f,time:%3f,cnt:%d\r\n",alt_md,timer_open.read(),cnt_judge);
+ pc.printf("15,%f,%f,%f,%3f\r\n",acc_abs,acc_abs,alt_md,timer_open.read());
t = timer_open.read();
}
if(alt_md > alt_max){
@@ -158,6 +172,8 @@
//if((timer_open.read()-time_judge) - TIME_JUDGE_CNT > 0) cnt_judge=0;
if(cnt_judge == CNT_JUDGE || timer_open.read() > TIME_OPEN){
Phase = RECOVERY;
+ pc.printf("9,0,0,0,0\r\n");
+ wait(0.5);
tic_gps.attach(&_SendGPS, 1.0/RATE_GPS);
}
break;
@@ -224,7 +240,7 @@
//pc.printf("%s\r\n",gps_data);
//pc.printf("Lat:%f,Lon:%f\r\ntime:%f,sat_num:%d\r\n",lat_north,lon_east,world_time,sat_num);
int japan_time = int(world_time) - 9;
- pc.printf("Lat:%f,Lon:%f,MAX_ALT:%f\r\n",lat_north,lon_east,alt_max);
+ pc.printf("Lat,%f,Lon,%f,MAX_ALT,%f\r\n",lat_north,lon_east,alt_max);
for(i=0;i<2;i++){
c[i]=pc.getc();
}