v2

Dependencies:   BEAR_Protocol_Edited BufferedSerial Debug MaxSonar PID Process QEI UI iSerial mbed

Fork of clean_V1 by Betago

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //*****************************************************/
00002 //  Include  //
00003 #include "mbed.h"
00004 #include "pinconfig.h"
00005 #include "PID.h"
00006 //#include "Motor.h"
00007 #include "eeprom.h"
00008 #include "Receiver.h"
00009 #include "Motion_EEPROM_Address.h"
00010 #include "move.h"
00011 #include "UNTRASONIC.h"
00012 #include "BufferedSerial.h"
00013 #include "rplidar.h"
00014 RPLidar lidar;
00015 //#include "pidcontrol.h"
00016 BufferedSerial se_lidar(PA_11,PA_12);
00017 #define EEPROM_DELAY 2
00018 DigitalOut rs485_dirc1(RS485_DIRC);
00019 //#define DEBUG_UP
00020 //#define DEBUG_LOW
00021 PwmOut VMO(PC_8);
00022 InterruptIn encoderA_d(PB_12);
00023 DigitalIn encoderB_d(PB_13);
00024 InterruptIn encoderA_1(PB_1);
00025 DigitalIn encoderB_1(PB_2);
00026 InterruptIn encoderA_2(PB_14);
00027 DigitalIn encoderB_2(PB_15);
00028 Timer timerStart;
00029 Timer tim;
00030 Timeout time_getsensor;
00031 Timeout time_distance;
00032 Timeout shutdown;
00033 move m1;
00034 //*****************************************************/
00035 
00036 // Global  //
00037 //timer
00038  int timer_now=0,timer_later=0;
00039  int times=0,timer_buffer=0;
00040  
00041  //encoder
00042  int Encoderpos = 0;
00043  int real_d=0;
00044  float valocity1 =0,valocity2 =0,pulse_1=0,pulse_2=0,count=0,r=0.125,velocityreal=0,pulse_d=0,Z_d=0;
00045 //pid
00046 
00047 double setp1=0,setp2=0;
00048 float outPID =0;
00049 float VRmax=0,VLmax=0,VR=0,VL=0,KP_LEFT=0,KI_LEFT=0,KD_LEFT=0,KP_RIGHT=0,KI_RIGHT=0 ,KD_RIGHT=0 ;
00050 PID P1(KP_LEFT,KI_LEFT,KD_LEFT,0.1);
00051 PID P2(KP_RIGHT,KI_RIGHT ,KD_RIGHT,0.1);
00052 //Ticker Recieve;
00053 //-- Communication --
00054 COMMUNICATION  *com1;
00055 
00056 //BufferedSerial PC(SERIAL_TX,SERIAL_RX);
00057 Serial PC(SERIAL_TX,SERIAL_RX);
00058 Bear_Receiver com(PA_9,PA_10,115200);
00059 int16_t MY_ID = 0x00;
00060 //-- Memorry --
00061 EEPROM memory(PB_4,PA_8,0);
00062 float KP_LEFT_BUFF=0,KI_LEFT_BUFF=0,KD_LEFT_BUFF=0,KP_RIGHT_BUFF=0,KI_RIGHT_BUFF =0,KD_RIGHT_BUFF=0;
00063 
00064  void CmdCheck(int16_t id,uint8_t *command,uint8_t ins);
00065  void RC();
00066 
00067 //rplidar
00068  //float distances = 0;
00069  //float angle    = 0;
00070 //ool  startBit = 0;
00071 //char  quality =0 ;
00072 
00073 
00074 void CmdCheck(int16_t id,uint8_t *command,uint8_t ins);
00075 
00076 
00077 DigitalOut myled(LED1);
00078 
00079 
00080 void Rx_interrupt()
00081 {
00082     //s1.get_motor();รับค่ามอเตอร์
00083     RC();
00084     timer_later= timer_now;
00085   
00086 }
00087 void EncoderA_1()//ซ้าย
00088 {   if(encoderB_1==0)
00089         { Encoderpos = Encoderpos + 1;}
00090     else
00091    { Encoderpos = Encoderpos -1;}
00092    pulse_1+=1;
00093    //Encoderpos = Encoderpos + 1;
00094    //valocity+=1;
00095    //pc.printf("%d \n",Encoderpos);
00096    //pc.printf("pulse=%f  \n",pulse);
00097    //if(pulse==128)
00098    //{count+=1;pulse=0; pc.printf("count=%f  \n",count);}
00099 }
00100   void EncoderA_2()//ขวา
00101 { 
00102     if(encoderB_2==0)
00103     { Encoderpos = Encoderpos + 1;}
00104     else
00105     { Encoderpos = Encoderpos -1;}
00106     pulse_2+=1;
00107     //pc.printf("%d",Encoderpos);
00108 }
00109 void EncoderA_D()
00110 { 
00111     if(encoderB_d==0)
00112     { Encoderpos = Encoderpos + 1;}
00113     else
00114     { Encoderpos = Encoderpos -1;}
00115     pulse_d+=1;
00116     if(pulse_d==128)
00117     {
00118         Z_d+=1;
00119         pulse_d=0;
00120     }
00121   
00122 }
00123 void getvelo1()//จาก encoder
00124 {
00125     valocity1=pulse_1*((2*3.14*r)/128);
00126     PC.printf("valocity=%f  \n",valocity1);
00127     count=0;
00128     timerStart.reset();
00129 }
00130 void getvelo2()
00131 {
00132     valocity2=pulse_2*((2*3.14*r)/128);
00133     PC.printf("valocity=%f  \n",valocity2);
00134     count=0;
00135     timerStart.reset();
00136 }
00137 void get_d()//ระยะทาง
00138 {
00139     real_d=Z_d*(2*3.14*r);
00140     //ส่งข้อมูล
00141     
00142 }
00143 void get_rplidar()
00144 {
00145      if (IS_OK(lidar.waitPoint())) 
00146      {
00147     
00148     } 
00149     else
00150     {
00151   
00152        lidar.startScan();
00153   
00154     }
00155     
00156 }
00157 double map(double x, double in_min, double in_max, double out_min, double out_max)
00158 {
00159     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
00160     
00161 }
00162 void PID_m1()//left
00163 {
00164     setp1=map(1.0,0.0,1.094,0.0,1.0);
00165     P1.setSetPoint(setp1);
00166      times=timerStart.read();
00167        if(times==1)// m/s
00168        {   
00169            getvelo1();
00170            //pc.printf("TIME \n");
00171            times=0;
00172            pulse_1=0;
00173         }
00174     P1.setProcessValue(valocity1);
00175     outPID=P1.compute();
00176      //pc.printf("outPID=%f \n",outPID);
00177      m1.movespeed_1(setp1,outPID);
00178 }
00179 void PID_m2()//right
00180 {
00181     setp2=map(1.0,0.0,1.094,0.0,1.0);
00182     P2.setSetPoint(setp2);
00183      times=timerStart.read();
00184        if(times==1)// m/s
00185        {   
00186            getvelo2();
00187            //pc.printf("TIME \n");
00188            times=0;
00189            pulse_2=0;
00190         }
00191     P2.setProcessValue(valocity2);
00192     outPID=P2.compute();
00193      //pc.printf("outPID=%f \n",outPID);
00194      m1.movespeed_2(setp2,outPID);
00195 }
00196 
00197 
00198 void RC()
00199 {
00200     myled =1;
00201     uint8_t data_array[30];
00202     uint8_t id=0;
00203     uint8_t ins=0;
00204     uint8_t status=0xFF;
00205 
00206 
00207 
00208     status = com.ReceiveCommand(&id,data_array,&ins);
00209     PC.printf("status = 0x%02x\n\r",status);
00210     if(status == ANDANTE_ERRBIT_NONE) {
00211         CmdCheck((int16_t)id,data_array,ins);
00212         PC.printf("RC******************************");
00213     }
00214 
00215 }
00216 /*******************************************************/
00217 int buf=0;
00218 int main()
00219 {
00220     PC.baud(115200);
00221     lidar.begin(se_lidar);
00222     tim.start();
00223     //com1 = new COMMUNICATION(PA_9,PA_10,115200);
00224        encoderA_1.rise(&EncoderA_1);
00225        timerStart.start();   
00226        P1.setMode(1);
00227        P1.setBias(0);
00228      //  pc.printf("READY \n");
00229     //pc.attach(&Rx_interrupt, Serial::RxIrq);
00230     lidar.setAngle(0,360);
00231     while(1) {
00232 
00233         VMO=1;
00234         get_rplidar();
00235     /*    if(tim.read_ms()-buf>=1000){
00236       for(int x=0;x<=359;x++){
00237         printf("%d,",lidar.Data[x]);
00238       }
00239       buf = tim.read_ms();
00240     }*/
00241         RC();
00242         //wait_ms(1);
00243     }
00244 }
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 void CmdCheck(int16_t id,uint8_t *command,uint8_t ins)
00255 {
00256        PC.printf("cmdcheck\n");
00257      if(id==MY_ID) {
00258         switch (ins) {
00259             case PING: {
00260                 break;
00261             }
00262             case WRITE_DATA: {
00263                 switch (command[0]) {
00264                     case ID: {
00265                         ///
00266                         MY_ID = (int16_t)command[1];
00267                         break;
00268                     }
00269                     case SET_VELOCITY_LEFT: {
00270                         //
00271                         uint8_t int_buffer[2],float_buffer[2];
00272                         float Int,flo;
00273                         int_buffer[0]=command[1];
00274                         int_buffer[1]=command[2];
00275                         float_buffer[0]=command[3];
00276                         float_buffer[1]=command[4];
00277                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00278                         flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00279                         VL=Int+(flo/10000);
00280                         PC.printf("VL=%f /n",VL);
00281                         break;
00282                     }
00283                     case SET_VELOCITY_RIGHT: {
00284                         //
00285                         uint8_t int_buffer[2],float_buffer[2];
00286                         float Int,flo;
00287                         int_buffer[0]=command[1];
00288                         int_buffer[1]=command[2];
00289                         float_buffer[0]=command[3];
00290                         float_buffer[1]=command[4];
00291                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00292                         flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00293                         VR=Int+flo;
00294                         PC.printf("VL=%f /n",VR);
00295                         break;
00296                     }
00297                     case SET_VELOCITY_MAX_LEFT: {
00298                         //
00299                         uint8_t int_buffer[2],float_buffer[2];
00300                         float Int,flo;
00301                         int_buffer[0]=command[1];
00302                         int_buffer[1]=command[2];
00303                         float_buffer[0]=command[3];
00304                         float_buffer[1]=command[4];
00305                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00306                         flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00307                         VLmax=Int+flo;
00308                         PC.printf("VL=%f /n",VLmax);
00309                         break;
00310                     }
00311                     case SET_VELOCITY_MAX_RIGHT: {
00312                         //
00313                         uint8_t int_buffer[2],float_buffer[2];
00314                         float Int,flo;
00315                         int_buffer[0]=command[1];
00316                         int_buffer[1]=command[2];
00317                         float_buffer[0]=command[3];
00318                         float_buffer[1]=command[4];
00319                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00320                          flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00321                         VRmax=Int+flo;
00322                         PC.printf("VRmax = %f",VRmax);
00323                       //  PC.printf("*****************************");
00324                         break;
00325                     }
00326                     //save to rom
00327                     case SET_KP_LEFT: {
00328                         uint8_t int_buffer[2],float_buffer[2];
00329                         float Int,flo;
00330                         int_buffer[0]=command[1];
00331                         int_buffer[1]=command[2];
00332                          float_buffer[0]=command[3];
00333                         float_buffer[1]=command[4];
00334                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00335                         flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00336 
00337                        KP_LEFT=Int+flo;
00338                        PC.printf("KP_LEFT=%f /n",KP_LEFT);
00339                        int32_t data_buff;
00340                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00341                        memory.write(ADDRESS_LEFT_KP,data_buff);
00342                        wait_ms(EEPROM_DELAY);
00343                         break;
00344                     }
00345                     case SET_KI_LEFT: {
00346                        uint8_t int_buffer[2],float_buffer[2];
00347                         float Int,flo;
00348                         int_buffer[0]=command[1];
00349                         int_buffer[1]=command[2];
00350                          float_buffer[0]=command[3];
00351                         float_buffer[1]=command[4];
00352                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00353                         flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00354 
00355                        KI_LEFT=Int+flo;
00356                           PC.printf("KI_LEFT=%f /n",KI_LEFT);
00357                        int32_t data_buff;
00358                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00359                        memory.write(ADDRESS_LEFT_KI ,data_buff);
00360                        wait_ms(EEPROM_DELAY);
00361                         break;
00362                     }
00363                     case SET_KD_LEFT: {
00364                         uint8_t int_buffer[2],float_buffer[2];
00365                         float Int,flo;
00366                         int_buffer[0]=command[1];
00367                         int_buffer[1]=command[2];
00368                          float_buffer[0]=command[3];
00369                         float_buffer[1]=command[4];
00370                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00371                          flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00372                        KD_LEFT=Int+flo;
00373                           PC.printf("KD_LEFT=%f /n",KD_LEFT);
00374                        int32_t data_buff;
00375                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00376                        memory.write(ADDRESS_LEFT_KD,data_buff);
00377                        wait_ms(EEPROM_DELAY);
00378                         break;
00379                     }
00380                     case  SET_KP_RIGHT: {
00381                         uint8_t int_buffer[2],float_buffer[2];
00382                         float Int,flo;
00383                         int_buffer[0]=command[1];
00384                         int_buffer[1]=command[2];
00385                          float_buffer[0]=command[3];
00386                         float_buffer[1]=command[4];
00387                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00388                          flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00389                        KP_RIGHT=Int+flo;
00390                           PC.printf("KP_RIGHT=%f /n",KP_RIGHT);
00391                        int32_t data_buff;
00392                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00393                        memory.write(ADDRESS_RIGHT_KP,data_buff);
00394                        wait_ms(EEPROM_DELAY);
00395                         break;
00396                     }
00397                     case SET_KI_RIGHT: {
00398                        uint8_t int_buffer[2],float_buffer[2];
00399                         float Int,flo;
00400                         int_buffer[0]=command[1];
00401                         int_buffer[1]=command[2];
00402                          float_buffer[0]=command[3];
00403                         float_buffer[1]=command[4];
00404                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00405                          flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00406                        KI_RIGHT=Int+flo;
00407                           PC.printf("KI_RIGHT=%f /n",KI_RIGHT);
00408                        int32_t data_buff;
00409                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00410                        memory.write(ADDRESS_RIGHT_KI,data_buff);
00411                        wait_ms(EEPROM_DELAY);
00412                         break;
00413                     }
00414                     case SET_KD_RIGHT: {
00415                         uint8_t int_buffer[2],float_buffer[2];
00416                         float Int,flo;
00417                         int_buffer[0]=command[1];
00418                         int_buffer[1]=command[2];
00419                         float_buffer[0]=command[3];
00420                         float_buffer[1]=command[4];
00421                         Int=(float)Utilities::ConvertUInt8ArrayToInt16(int_buffer);
00422                          flo=(float)Utilities::ConvertUInt8ArrayToInt16(float_buffer);
00423                        KD_RIGHT=Int+flo;
00424                           PC.printf("KD_RIGHT=%f /n",KD_RIGHT);
00425                        int32_t data_buff;
00426                        data_buff = Utilities::ConvertUInt8ArrayToInt32(int_buffer);
00427                        memory.write(ADDRESS_RIGHT_KD,data_buff);
00428                        wait_ms(EEPROM_DELAY);
00429                         break;
00430                     }
00431                  }
00432             } break;
00433              case READ_DATA: {  PC.printf("READ_DATA\n");
00434                 switch (command[0]) {
00435                     case GET_LIDAR: {
00436                    
00437                         com.sendlidar();
00438                         PC.printf("SEND1\n");
00439                         break;
00440                         }
00441                      case GET_LIDAR2: {
00442                        
00443                         com.sendlidar2();
00444                         PC.printf("SEND2\n");
00445                         break;
00446                         }
00447                      case GET_LIDAR3: {
00448                         
00449                         com.sendlidar3();
00450                         PC.printf("SEND3\n");
00451                      break;
00452                         }
00453                       case GET_LIDAR4: {
00454                         
00455                         com.sendlidar4();
00456                         PC.printf("SEND4\n");
00457                      break;
00458                         }
00459                           case GET_LIDAR5: {
00460                               
00461                        
00462                         com.sendlidar5();
00463                         PC.printf("SEND5\n");
00464                      break;
00465                         }
00466                           case GET_LIDAR6: {
00467                       com.sendlidar6();
00468                       PC.printf("SEND6\n");
00469                         
00470                      break;
00471                         }
00472                         
00473                     case GET_BATTERY: {
00474                         
00475                         break;
00476                         }
00477                     case GET_VELOCITY_LEFT: {
00478                         uint8_t intVelo_L[2],floatVelo_L[2];
00479                         com.FloatSep(valocity1,intVelo_L,floatVelo_L);
00480                          ANDANTE_PROTOCOL_PACKET package;
00481 
00482                         package.robotId = MY_ID;
00483                          package.length = 6;
00484                         package.instructionErrorId = WRITE_DATA;
00485                         package.parameter[0]=intVelo_L[0];
00486                         package.parameter[1]=intVelo_L[1];
00487                          package.parameter[2]=floatVelo_L[0];
00488                         package.parameter[3]=floatVelo_L[1];
00489 
00490                         rs485_dirc1=1;
00491                          wait_us(RS485_DELAY);
00492                          com1->sendCommunicatePacket(&package);
00493                         
00494                         
00495                         break;
00496                         }
00497                     case GET_VELOCITY_RIGHT : {
00498                         uint8_t intVelo_R[2],floatVelo_R[2];
00499                         com.FloatSep(valocity2,intVelo_R,floatVelo_R);
00500                         
00501                         
00502                          ANDANTE_PROTOCOL_PACKET package;
00503 
00504                         package.robotId = MY_ID;
00505                          package.length = 6;
00506                         package.instructionErrorId = WRITE_DATA;
00507                         package.parameter[0]=intVelo_R[0];
00508                         package.parameter[1]=intVelo_R[1];
00509                          package.parameter[2]=floatVelo_R[0];
00510                         package.parameter[3]=floatVelo_R[1];
00511 
00512                         rs485_dirc1=1;
00513                          wait_us(RS485_DELAY);
00514                          com1->sendCommunicatePacket(&package);
00515                         
00516                         break;
00517                         }
00518                     case GET_KP_LEFT: {
00519                         memory.read(ADDRESS_LEFT_KP ,KP_LEFT_BUFF);
00520                         uint8_t intKPL[2],floatKPL[2];
00521                         com.FloatSep(KP_LEFT_BUFF,intKPL,floatKPL);
00522                         
00523                         
00524                          ANDANTE_PROTOCOL_PACKET package;
00525 
00526                         package.robotId = MY_ID;
00527                          package.length = 6;
00528                         package.instructionErrorId = WRITE_DATA;
00529                         package.parameter[0]=intKPL[0];
00530                         package.parameter[1]=intKPL[1];
00531                          package.parameter[2]=floatKPL[0];
00532                         package.parameter[3]=floatKPL[1];
00533 
00534                         rs485_dirc1=1;
00535                          wait_us(RS485_DELAY);
00536                          com1->sendCommunicatePacket(&package);
00537                         
00538                         break;
00539                         }
00540                     case GET_KI_LEFT: {
00541                         memory.read(ADDRESS_LEFT_KP ,KI_LEFT_BUFF);
00542                         uint8_t intKIL[2],floatKIL[2];
00543                         com.FloatSep(KI_LEFT_BUFF,intKIL,floatKIL);
00544                         
00545                         
00546                          ANDANTE_PROTOCOL_PACKET package;
00547 
00548                         package.robotId = MY_ID;
00549                          package.length = 6;
00550                         package.instructionErrorId = WRITE_DATA;
00551                         package.parameter[0]=intKIL[0];
00552                         package.parameter[1]=intKIL[1];
00553                          package.parameter[2]=floatKIL[0];
00554                         package.parameter[3]=floatKIL[1];
00555 
00556                         rs485_dirc1=1;
00557                          wait_us(RS485_DELAY);
00558                          com1->sendCommunicatePacket(&package);
00559                         
00560                         break;
00561                         }
00562                     case GET_KD_LEFT: {
00563                         memory.read(ADDRESS_LEFT_KP ,KD_LEFT_BUFF);
00564                         uint8_t intKDL[2],floatKDL[2];
00565                         com.FloatSep(KD_LEFT_BUFF,intKDL,floatKDL);
00566                         
00567                         
00568                          ANDANTE_PROTOCOL_PACKET package;
00569 
00570                         package.robotId = MY_ID;
00571                          package.length = 6;
00572                         package.instructionErrorId = WRITE_DATA;
00573                         package.parameter[0]=intKDL[0];
00574                         package.parameter[1]=intKDL[1];
00575                          package.parameter[2]=floatKDL[0];
00576                         package.parameter[3]=floatKDL[1];
00577 
00578                         rs485_dirc1=1;
00579                          wait_us(RS485_DELAY);
00580                          com1->sendCommunicatePacket(&package);
00581                         
00582                         break;
00583                         }
00584                     case GET_KP_RIGHT: {
00585                         memory.read(ADDRESS_LEFT_KP ,KP_RIGHT_BUFF);
00586                         uint8_t intKDR[2],floatKDR[2];
00587                         com.FloatSep(KP_RIGHT_BUFF,intKDR,floatKDR);
00588                         
00589                         
00590                          ANDANTE_PROTOCOL_PACKET package;
00591 
00592                         package.robotId = MY_ID;
00593                          package.length = 6;
00594                         package.instructionErrorId = WRITE_DATA;
00595                         package.parameter[0]=intKDR[0];
00596                         package.parameter[1]=intKDR[1];
00597                          package.parameter[2]=floatKDR[0];
00598                         package.parameter[3]=floatKDR[1];
00599 
00600                         rs485_dirc1=1;
00601                          wait_us(RS485_DELAY);
00602                          com1->sendCommunicatePacket(&package);
00603                         
00604                         break;
00605                         }
00606                     case GET_KI_RIGHT: {
00607                         memory.read(ADDRESS_LEFT_KP ,KI_RIGHT_BUFF);
00608                         uint8_t intKIR[2],floatKIR[2];
00609                         com.FloatSep(KI_RIGHT_BUFF,intKIR,floatKIR);
00610                         
00611                         
00612                          ANDANTE_PROTOCOL_PACKET package;
00613 
00614                         package.robotId = MY_ID;
00615                          package.length = 6;
00616                         package.instructionErrorId = WRITE_DATA;
00617                         package.parameter[0]=intKIR[0];
00618                         package.parameter[1]=intKIR[1];
00619                          package.parameter[2]=floatKIR[0];
00620                         package.parameter[3]=floatKIR[1];
00621 
00622                         rs485_dirc1=1;
00623                          wait_us(RS485_DELAY);
00624                          com1->sendCommunicatePacket(&package);
00625                         
00626                         break;
00627                         }
00628                     case GET_KD_RIGHT: {
00629                         memory.read(ADDRESS_LEFT_KP ,KD_RIGHT_BUFF);
00630                         uint8_t intKDR[2],floatKDR[2];
00631                         com.FloatSep(KD_RIGHT_BUFF,intKDR,floatKDR);
00632                         
00633                         
00634                          ANDANTE_PROTOCOL_PACKET package;
00635 
00636                         package.robotId = MY_ID;
00637                          package.length = 6;
00638                         package.instructionErrorId = WRITE_DATA;
00639                         package.parameter[0]=intKDR[0];
00640                         package.parameter[1]=intKDR[1];
00641                          package.parameter[2]=floatKDR[0];
00642                         package.parameter[3]=floatKDR[1];
00643 
00644                         rs485_dirc1=1;
00645                          wait_us(RS485_DELAY);
00646                          com1->sendCommunicatePacket(&package);
00647                         
00648                         break;
00649                         }
00650            }
00651      }break;
00652                     
00653     }
00654   }
00655 }