yokokawa

Dependencies:   ADXL345 AigamozuControlPackets HMC5843 ITG3200 MBed_Adafruit-GPS-Library XBee agzIDLIST agz_common mbed

Fork of aigamozu_program_ver2 by aigamozu

Files at this revision

API Documentation at this revision

Comitter:
m5171135
Date:
Sun Jun 08 11:55:07 2014 +0000
Parent:
4:39d2aadf3068
Child:
6:21e2792e66c7
Commit message:
berfore

Changed in this revision

AigamozuControlPackets.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/AigamozuControlPackets.lib	Wed Jun 04 09:12:29 2014 +0000
+++ b/AigamozuControlPackets.lib	Sun Jun 08 11:55:07 2014 +0000
@@ -1,1 +1,1 @@
-AigamozuControlPackets#80448565c15c
+http://mbed.org/teams/aigamozu/code/AigamozuControlPackets/#04dadf67ecb6
--- a/main.cpp	Wed Jun 04 09:12:29 2014 +0000
+++ b/main.cpp	Sun Jun 08 11:55:07 2014 +0000
@@ -4,8 +4,8 @@
 //
 //  Program name: Aigamozu Robot Control
 //  author: Atsunori Maruyama
-//  ver ->  1.0
-//
+//  ver ->  1.1
+//  day ->  2014/06/01
 //  
 //
 /**********************************************/
@@ -43,7 +43,7 @@
 
 //Motor Contorol Pin Setting
 VNH5019 motorShield(p21,p22,p23,p24,p25,p26);
-AigamozuControlPackets agz;
+
 
 //Interrupt Setting
 Ticker axis;
@@ -92,26 +92,32 @@
 //
 /////////////////////////////////////////
  
- void randomRenovation(){
+ void normalRandomMode(){
     
     if(count < 20){
         motorShield.changeSpeed(1,127,1,127);
     }
-    
     else{
         motorShield.changeSpeed(1,64,2,64);
         if(count > 21) {
-            
             count = 0;
             motorShield.changeSpeed(1,127,1,127);
-            
             }
         } 
     count++;
+    }
+    
+void gpsRandomMode(){
+    
+        
+            
+
     }   
 
 
 
+
+
 /////////////////////////////////////////
 //
 //Main Processing
@@ -137,11 +143,11 @@
     myGPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
     myGPS.sendCommand(PGCMD_ANTENNA);
     
-    //gyro_registor Setting
     wait(2);
        
     //interrupt start
     axis.attach(&axisRenovation, 0.1);
+    AigamozuControlPackets agz(axis);
     refresh_Timer.start();
     
     
@@ -152,17 +158,26 @@
             if (xbee.getResponse().isAvailable()) {
                 if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
                 xbee.getResponse().getZBRxResponse(zbRx);
-                unsigned char *buf = zbRx.getFrameData(); 
+                uint8_t *buf = zbRx.getFrameData(); 
                  
                  
                  //Check Command Type 
                  switch(agz.checkCommnadType(buf)){
                     //CommandType -> ChanegeMode
                     case CHANGE_MODE :{
-                        my_mode = buf[19];
+                        //Change Mode
+                        agz.changeMode(buf);
+                        //Motor Stop 
                         motorShield.changeSpeed(0,0,0,0);
-                        if(my_mode == 2)  auth_axis.attach(&randomRenovation, 1.0);
+                        //case: AUTO1
+                        if(agz.nowMode == AUTO_MODE)  auth_axis.attach(&normalRandomMode, 1.0);
+                        else if(agz.nowMode ==AUTO_GPS_MODE) auth_axis.attach(&gpsRandomMode, 1.0);
                         else auth_axis.detach();
+                        
+                        //case:AUTO2
+                        
+                            
+                                        
                         break;
                         }
 
@@ -180,13 +195,12 @@
                     //CommandType -> Send Status
                     case STATUS_REQUEST:{
                             //Create GPS Infomation Packet
-                            uint8_t* data = agz.createStatusPacket(myGPS.longitudeH,myGPS.longitudeL,myGPS.latitudeH,myGPS.latitudeL,'B','a');
+                            agz.createReceiveStatusCommand('B','a',myGPS.longitudeH,myGPS.longitudeL,myGPS.latitudeH,myGPS.latitudeL);
                             //Select Destination
-                            ZBTxRequest tx64request(remoteAddress,data,RECEIVES_GPS_STATUS_LENGTH);
+                            ZBTxRequest tx64request(remoteAddress,agz.packetData,agz.getPacketLength());
+                            
                             //Send -> Base
                             xbee.send(tx64request);
-                            //Buffer Release
-                            delete data;
                             break;         
           
                         }