diff --git a/CCEXPipe/CCEXPipe.vcxproj b/CCEXPipe/CCEXPipe.vcxproj index 9b22cd3..1cc13b3 100644 --- a/CCEXPipe/CCEXPipe.vcxproj +++ b/CCEXPipe/CCEXPipe.vcxproj @@ -22,7 +22,7 @@ {548705F2-AF3E-45B7-A716-578791B1ECBE} CCEXPipe Win32Proj - 10.0.10586.0 + 10.0 @@ -45,7 +45,7 @@ DynamicLibrary MultiByte - v140 + v143 diff --git a/Platform/Agv-Platform.vcxproj b/Platform/Agv-Platform.vcxproj index abf1018..e42c2d9 100644 --- a/Platform/Agv-Platform.vcxproj +++ b/Platform/Agv-Platform.vcxproj @@ -21,7 +21,7 @@ {4DA0C82B-2496-4A33-BDCE-E89D85A60BF8} VcsClient - 10.0.10586.0 + 10.0 MFCProj @@ -43,7 +43,7 @@ Application true - v140 + v143 MultiByte Dynamic diff --git a/Plugin/Driver/Driver.vcxproj b/Plugin/Driver/Driver.vcxproj index 7b225be..5aaea92 100644 --- a/Plugin/Driver/Driver.vcxproj +++ b/Plugin/Driver/Driver.vcxproj @@ -21,7 +21,7 @@ {8BBB60C1-510D-47BC-8FD2-E14E9EA3A156} VcsClient - 10.0.10586.0 + 10.0 MFCProj @@ -43,7 +43,7 @@ Application true - v140 + v143 MultiByte Dynamic diff --git a/Plugin/Driver/DriverMainDlg.cpp b/Plugin/Driver/DriverMainDlg.cpp index 92c75ac..4ec98bf 100644 --- a/Plugin/Driver/DriverMainDlg.cpp +++ b/Plugin/Driver/DriverMainDlg.cpp @@ -490,12 +490,12 @@ BOOL CDriverMainDlg::OnInitDialog() else StopFlag = 1; - if (m_bAutoSend2) - { - m_StopSendFlag2 = 0; - //开启发送线程 - AfxBeginThread(SendCanThread2, this); - } + //if (m_bAutoSend2) + //{ + // m_StopSendFlag2 = 0; + // //开启发送线程 + // AfxBeginThread(SendCanThread2, this); + //} if (m_bAutoSendForFast) { m_StopSendFlagForFast = 0; @@ -1018,6 +1018,58 @@ void CDriverMainDlg::SendCanControlDataForKDS(float Vel, float Ang) { LogOutToFile("(inner)SendCanControlDataForKDS: canData326 = %c,%c,%c,%c,%c,%c,%c,%c", canData326[0], canData326[1], canData326[2], canData326[3], canData326[4], canData326[5], canData326[6]); //SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, 0x326, canData326); } +//下发自动模式下前进后退参数_CAN_0x226 +void CDriverMainDlg::SendCanAGVMoveData(float Vel) { + UINT32 acId = 0x226; //速度参数帧 + byte mvDirection = 0; + float C = 3.14 * 0.343; //计算轮子周长 + float reSpeed = 0; + if (Vel > 0) { + mvDirection = 5; //前进 + } + else if (Vel < 0) { + mvDirection = 3; //后退 + Vel = -Vel; + } + reSpeed = Vel * 60 / C * 20.2; //RPM + int16_t bytePair = static_cast(reSpeed); + uint8_t reSpeedHByte = (bytePair >> 8) & 0xFF; // 高字节 + uint8_t reSpeedLByte = bytePair & 0xFF; // 低字节 + //TRACE("HByte is %x LByte is %x", reSpeedHByte, reSpeedLByte); + char acData[8] = {}; + acData[0] = mvDirection; + acData[1] = reSpeedLByte; + acData[2] = reSpeedHByte; + acData[3] = 30; + acData[4] = 30; + acData[5] = 1; + acData[6] = 1; + acData[7] = 0; + SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, acId, acData); +} + +//下发自动模式下转向角度_CAN_0x326 +void CDriverMainDlg::SendCanAGVTurnData(float Ang) +{ + UINT32 acId = 0x326; //角度帧 + Ang = Ang * 100; + int16_t bytePair = static_cast(Ang); + uint8_t turnDegreeHByte = (bytePair >> 8) & 0xFF; // 高字节 + uint8_t turnDegreeLByte = bytePair & 0xFF; // 低字节 + //TRACE("HByte is %x LByte is %x", turnDegreeHByte, turnDegreeLByte); + char acData[8] = {}; + acData[0] = turnDegreeLByte; + acData[1] = turnDegreeHByte; + acData[2] = 0; + acData[3] = 0; + acData[4] = 0; + acData[5] = 0; + acData[6] = 0; + acData[7] = 0; + SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, acId, acData); +} + + @@ -1206,8 +1258,11 @@ UINT CDriverMainDlg::SendCanThreadForFast(LPVOID v) //theApp.m_fAngCalForFast = UserAng; //下发运动控制参数 LogOutToFile("(inner)SendCanThreadForFast: Vel = %f, Ang = %f", theApp.m_fVelCalForFast, theApp.m_fAngCalForFast); - dlg->SendCanControlDataForKDS(theApp.m_fVelCalForFast, theApp.m_fAngCalForFast); - Sleep(20); + //dlg->SendCanControlDataForKDS(theApp.m_fVelCalForFast, theApp.m_fAngCalForFast); + dlg->SendCanAGVMoveData(theApp.m_fVelCalForFast); + Sleep(10); + dlg->SendCanAGVTurnData(theApp.m_fAngCalForFast); + Sleep(10); } return 0; } @@ -1240,6 +1295,9 @@ void CDriverMainDlg::OnBnClickedAutoSend3() } else m_StopSendFlagForFast = 1; + //停止发送Can报文,并将速度置0 + SendCanAGVMoveData(0.0f); + theApp.m_fVelCalForFast = 0.0f; } int before_trafficstop_action; diff --git a/Plugin/Driver/DriverMainDlg.h b/Plugin/Driver/DriverMainDlg.h index 1b8bf28..ab5ac0e 100644 --- a/Plugin/Driver/DriverMainDlg.h +++ b/Plugin/Driver/DriverMainDlg.h @@ -118,6 +118,8 @@ public: BOOL OpenCanDevice(); float NormalizeAngle(float angle); float CorrectAngle(float currentAngle, float targetAngle); + void SendCanAGVMoveData(float Vel); + void SendCanAGVTurnData(float Ang); void UpdateCanStatue(BOOL bStatue); void ProcessPipeMsg(int lMsgId, char* pData, int lLen); void SendCanData(int nDevIdx, int nCanIdx, int nFrameType, int nFrameFormat, UINT32 acFrameId, char acFrameData[8]); diff --git a/Plugin/Fast/Fast.vcxproj b/Plugin/Fast/Fast.vcxproj index 3d37acd..44470b0 100644 --- a/Plugin/Fast/Fast.vcxproj +++ b/Plugin/Fast/Fast.vcxproj @@ -47,7 +47,7 @@ Application - v140 + v143 MultiByte Dynamic diff --git a/Plugin/KcCtrl/KcCtrl.vcxproj b/Plugin/KcCtrl/KcCtrl.vcxproj index 06fd241..7701449 100644 --- a/Plugin/KcCtrl/KcCtrl.vcxproj +++ b/Plugin/KcCtrl/KcCtrl.vcxproj @@ -43,7 +43,7 @@ Application true - v140 + v143 MultiByte Dynamic diff --git a/Plugin/Plc/Plc.vcxproj b/Plugin/Plc/Plc.vcxproj index 0c81e1a..95c63e4 100644 --- a/Plugin/Plc/Plc.vcxproj +++ b/Plugin/Plc/Plc.vcxproj @@ -43,7 +43,7 @@ Application true - v140 + v143 MultiByte Dynamic diff --git a/Plugin/QrGuide/QrGuide.vcxproj b/Plugin/QrGuide/QrGuide.vcxproj index ea564c2..f2762c9 100644 --- a/Plugin/QrGuide/QrGuide.vcxproj +++ b/Plugin/QrGuide/QrGuide.vcxproj @@ -47,7 +47,7 @@ Application - v140 + v143 MultiByte Dynamic