Browse Source

change detection/detection_chassis.

liusunan 4 years ago
parent
commit
fd11e30875

+ 63 - 0
src/detection/detection_chassis/decodechassis.cpp

@@ -204,6 +204,7 @@ inline float getonevalue(unsigned char * strdata,float fratio,float foff)
     a = strdata[0];
     float fvalue = a;
     fvalue = fvalue * fratio + foff;
+ //   std::cout<<"hapo torque: "<<fvalue<<std::endl;
     return fvalue;
 }
 
@@ -234,6 +235,68 @@ int ProcMIDBUSChassis(void * pa, iv::can::canmsg * pmsg)
             xchassis.set_emergencystop_feedback((data[7]&06)>>1);
             xchassis.set_brakelight_feedback((data[7]&0x08)>>3);
 
+
+
+            ghave0x13 = true;
+
+        }
+        if(praw->id() == 0x14)
+        {
+            xchassis.set_range_feedback(data[0]);
+            xchassis.set_soc(getonevalue(data+1,0.4,0));
+            xchassis.set_drivectrltype_feedback(data[5]&0x0f);
+            xchassis.set_brakectrltype_feedback((data[5]&0xf0)>>4);
+            xchassis.set_epsctrltype_feedback(data[6]&0x0f);
+            ghave0x14 = true;
+        }
+        if(praw->id() == 0x15)
+        {
+
+            xchassis.set_frontleftwheel_feedback(gettwomotovalue(data,0.05625,0));
+            xchassis.set_frontrightwheel_feedback(gettwomotovalue(data+2,0.05625,0));
+            xchassis.set_rearleftwheel_feedback(gettwomotovalue(data+4,0.05625,0));
+            xchassis.set_rearrightwheel_feedback(gettwomotovalue(data+6,0.05625,0));
+            ghave0x15 = true;
+        }
+
+        if(ghave0x13&&ghave0x14&&ghave0x15)
+        {
+            ghave0x13 = false;
+            ghave0x14 = false;
+            ghave0x15 = false;
+            ShareChassis(pa,&xchassis);
+            nRtn = 1;
+        }
+    }
+
+    return nRtn;
+
+}
+
+int ProcHAPOChassis(void * pa, iv::can::canmsg * pmsg)
+{
+    int i;
+    int nRtn = 0;
+    static iv::chassis xchassis;
+    for(i=0;i<pmsg->rawmsg_size();i++)
+    {
+
+        const iv::can::canraw * praw = &(pmsg->rawmsg(i));
+        unsigned char data[8];
+        memcpy(data,praw->data().data(),8);
+        if(praw->id() == 0x13)
+        {
+            xchassis.set_angle_feedback(gettwomotovalue(data+0,0.1,-870));
+            xchassis.set_torque(getonevalue(data+2,0.4,0));
+            xchassis.set_brake_feedback(getonevalue(data+3,0.4,0));
+            xchassis.set_vel(gettwomotovalue(data+4,0.05625,0));
+            xchassis.set_epb_feedback(data[6]&0x03);
+            xchassis.set_shift((data[6]&0xf0)>>4);
+            xchassis.set_drivemode(data[7]&0x01);
+            xchassis.set_emergencystop_feedback((data[7]&06)>>1);
+            xchassis.set_brakelight_feedback((data[7]&0x08)>>3);
+
+            std::cout<<"torque is "<<xchassis.torque()<<std::endl;
             ghave0x13 = true;
 
         }

+ 2 - 0
src/detection/detection_chassis/decodechassis.h

@@ -15,5 +15,7 @@ int ProcMIDCARChassis(void * pa, iv::can::canmsg * pmsg);
 
 int ProcMIDBUSChassis(void * pa, iv::can::canmsg * pmsg);
 
+int ProcHAPOChassis(void * pa, iv::can::canmsg * pmsg);
+
 
 #endif // DECODECHASSIS_H

+ 8 - 1
src/detection/detection_chassis/main.cpp

@@ -26,7 +26,7 @@ QTime gTime;
 
 namespace  iv {
 
-enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,UNKNOWN} gVehicleType;  //车辆类型
+enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,HAPO,UNKNOWN} gVehicleType;  //车辆类型
 
 
 }
@@ -71,6 +71,9 @@ void Listencan0(const char * strdata,const unsigned int nSize,const unsigned int
     case iv::MIDBUS:
         nRtn = ProcMIDBUSChassis(gpa,&xmsg);
         break;
+    case iv::HAPO:
+        nRtn = ProcHAPOChassis(gpa,&xmsg);
+        break;
     default:
         break;
     }
@@ -157,6 +160,10 @@ int main(int argc, char *argv[])
     {
         iv::gVehicleType = iv::MIDBUS;
     }
+    if(strncmp(strvehicletype.data(),"HAPO",255) == 0)
+    {
+        iv::gVehicleType = iv::HAPO;
+    }
 
 //iv::gVehicleType = iv::MIDBUS;
 

+ 0 - 0
src/detection/detection_chassis/sh/chassis_deploy.sh