|
@@ -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;
|
|
|
|
|
|
}
|