From 62924be8d7b08f27498f309560ab7b1b28083ddb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=BE=8E=E9=A3=9F=E5=8D=9A=E4=B8=BB?= <939387484@qq.com>
Date: Thu, 19 Jun 2025 15:04:23 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=92=8C=E6=95=B0=E6=8D=AE=E5=8F=91=E9=80=81=E9=80=BB?=
=?UTF-8?q?=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 将多个项目文件中的
- 在 `DriverMainDlg.cpp` 中注释掉与 `m_bAutoSend2` 相关的代码,新增 `SendCanAGVMoveData` 和 `SendCanAGVTurnData` 函数以发送运动和转向数据。
- 更新 `SendCanThreadForFast` 函数,使用新的数据发送函数替代旧实现。
- 在 `OnBnClickedAutoSend3` 函数中添加停止发送 CAN 报文的逻辑,并将速度置为 0。
- 在 `DriverMainDlg.h` 中新增相关函数声明。
- 其他项目文件(如 `Fast.vcxproj`、`KcCtrl.vcxproj`、`Plc.vcxproj` 和 `QrGuide.vcxproj`)也进行了类似的工具集更新。
---
CCEXPipe/CCEXPipe.vcxproj | 4 +-
Platform/Agv-Platform.vcxproj | 4 +-
Plugin/Driver/Driver.vcxproj | 4 +-
Plugin/Driver/DriverMainDlg.cpp | 74 +++++++++++++++++++++++++++++----
Plugin/Driver/DriverMainDlg.h | 2 +
Plugin/Fast/Fast.vcxproj | 2 +-
Plugin/KcCtrl/KcCtrl.vcxproj | 2 +-
Plugin/Plc/Plc.vcxproj | 2 +-
Plugin/QrGuide/QrGuide.vcxproj | 2 +-
9 files changed, 78 insertions(+), 18 deletions(-)
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