harurobo_mbed_undercarriage_sub

Dependencies:   mbed Maxon_setting move4wheel2 EC PathFollowing_12_22 CruizCore_R1370P

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EC.h"
00003 #include "R1370P.h"
00004 #include "move4wheel.h"
00005 #include "PathFollowing.h"
00006 #include "Maxon_setting.h"
00007 
00008 CAN can1(p30,p29,1000000);
00009 DigitalOut led(LED1);
00010 Ticker ticker;
00011 
00012 void can_read(){//CAN通信受信
00013     
00014     CANMessage msg;
00015     
00016     if(can1.read(msg)){
00017       
00018       if(msg.id == 1){
00019         led = 1;
00020        usw_data1 =  0.01 * (short)((msg.data[0]<<8) | msg.data[1]);
00021      printf("usw_data1 = %d:%d,%lf\n\r",msg.data[0],msg.data[1],usw_data1);
00022       }else if(msg.id == 2){
00023         //led = 1;
00024       //  usw_data2 = 0.01 * (short)((msg.data[0]<<8) | msg.data[1]);
00025         //printf("usw_data2 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data2);
00026       }else if(msg.id == 3){
00027         //led = 1;
00028         //usw_data3 = 0.01 * (short)((msg.data[0]<<8) | msg.data[1]);
00029         //printf("usw_data3 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data3);
00030       }else if(msg.id == 4){
00031         //led = 1;
00032         //usw_data4 = 0.01 * (short)((msg.data[0]<<8) | msg.data[1]);
00033         //printf("usw_data4 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data4);
00034       }
00035           
00036     }
00037 }
00038 
00039 
00040 //////////////////////////////////////////////////////////////以下main文/////////////////////////////////////////////////////////////////
00041 int main()
00042 {   
00043     UserLoopSetting();
00044     //UserLoopSetting2();
00045     //Debug_Control()
00046     
00047 
00048     //purecurve2(5,1,1,0,0,-500,-500,9,1500,5,0.1,10,0.1,600,0);
00049     //gogo_straight(1,1,0,0,500,0,2000,2000,5,0.1,10,0.1,600,0);
00050     
00051     ticker.attach(&can_read,0.01);
00052     
00053     while(1);
00054       //printf("%f\n\r",usw_data1);
00055     
00056 
00057     //MotorControl(0,0,0,0);
00058 }