From 4adc78553c8d48ff122506195fa33641134bd7b1 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期六, 13 十二月 2025 18:55:14 +0800
Subject: [PATCH] 路径点不重复的控制算法测试通了,但是好像不如之前路径点重复的版本好。增加了蓝牙接口部分。准备移植外包的MQTT。
---
STM32H743/APL/app.c | 85 +++++++++++++++++++++++++++++++++++-------
1 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/STM32H743/APL/app.c b/STM32H743/APL/app.c
index bda2343..6af073b 100644
--- a/STM32H743/APL/app.c
+++ b/STM32H743/APL/app.c
@@ -13,7 +13,15 @@
#include "UDPClient.h"
#include "bluetooth.h"
#include "TCPClient.h"
-static osSemaphoreId_t g_semaphoreHandle = NULL;
+#include "SBUS.h"
+#include "pwm_ctrol.h"
+#include "PythonLink.h"
+#include "motion_mode.h"
+#include "motion_control_task.h"
+#include "motion_calibration_task.h"
+osSemaphoreId_t g_semaphoreHandle = NULL;
+TaskHandle_t g_app_task_handle = NULL;
+
extern uint8_t restart_num;
void IdleTask(void)
{
@@ -38,21 +46,72 @@
Internet_Init();
UDPClient_Init();
TCPClient_Init();
+ BT_Init();
+ SBUS_Init();
+ PythonLink_Init();
+#if (MOTION_ACTIVE_MODE == MOTION_MODE_CONTROL)
+ MotionControl_TaskInit();
+#elif (MOTION_ACTIVE_MODE == MOTION_MODE_CALIBRATION)
+ MotionCalibration_TaskInit();
+#else
+#error "Unsupported MOTION_ACTIVE_MODE"
+#endif
+ /* ENU璋冭瘯鎵撳嵃锛堥潪鏍″噯妯″紡锛� */
+ static HIDO_UINT32 debug_print_counter = 0;
+ const HIDO_UINT32 DEBUG_PRINT_INTERVAL = 100; /* 姣�100娆″惊鐜墦鍗颁竴娆� (绾�500ms) */
+
+ /* GPS GGA涓婁紶瀹氭椂鍣� */
+ static HIDO_UINT32 gps_upload_counter = 0;
+ const HIDO_UINT32 GPS_UPLOAD_INTERVAL = 200; /* 姣�200娆″惊鐜笂浼犱竴娆� (绾�1000ms) */
+
while (1)
{
//HIDO_UINT32 timeout = HIDO_TimerGetNearestTimeout(1000);
- HIDO_UINT32 timeout = 100;
+ HIDO_UINT32 timeout = 5;
if (xSemaphoreTake(g_semaphoreHandle, timeout / portTICK_PERIOD_MS) == pdTRUE)
{
}
DBG_Poll();
BT_Poll();
+ SBUS_Poll();
+ PythonLink_Poll();
HIDO_ATLitePoll();
Internet_Poll();
GPS_Poll();
+
+ /* 瀹氭椂涓婁紶GGA鎶ユ枃鍒�4G锛堟瘡绉掍竴娆★級 */
+ if (++gps_upload_counter >= GPS_UPLOAD_INTERVAL)
+ {
+ gps_upload_counter = 0;
+ GPS_UploadGGA();
+ }
+
+ /* 鍛ㄦ湡鎬ф墦鍗癊NU鍧愭爣鍜孖MU鏁版嵁锛堢敤浜庤皟璇旼PS瑙f瀽锛� */
+#if (MOTION_ACTIVE_MODE != MOTION_MODE_CALIBRATION)
+ if (++debug_print_counter >= DEBUG_PRINT_INTERVAL)
+ {
+ debug_print_counter = 0;
+
+ ST_GPRMI gprmi;
+ ST_GPIMU gpimu;
+ float enu[3];
+
+ if (GPS_GetGPRMI(&gprmi) == HIDO_OK &&
+ GPS_GetGPIMU(&gpimu) == HIDO_OK &&
+ GPS_GetCurrentENU(enu) == HIDO_OK)
+ {
+ HIDO_Debug2("$DEBUG,ENU,%.2f,%.2f,%.2f,HDG,%.2f,ACC,%.3f,%.3f,%.3f,GYRO,%.3f,%.3f,%.3f\r\n",
+ enu[0], enu[1], enu[2], /* ENU鍧愭爣 (m) */
+ gprmi.m_fHeadingAngle, /* 鑸悜瑙� (搴�) */
+ gpimu.m_fAccelX, gpimu.m_fAccelY, gpimu.m_fAccelZ, /* 鍔犻�熷害 (m/s虏) */
+ gpimu.m_fGyroX, gpimu.m_fGyroY, gpimu.m_fGyroZ); /* 瑙掗�熷害 (rad/s) */
+ }
+ }
+#endif
+
UDPClient_Poll();
- TCPClient_Poll();
+ // TCPClient_Poll();
IdleTask();
HIDO_TimerPoll();
}
@@ -85,9 +144,7 @@
{
MCUFlash_Init();
parameter_init();
- printf("demo run!\r\n");
-
- /* 寮�鏈轰俊鎭緭鍑猴細鐗堟湰鍙枫�佽澶嘔D銆両P銆佺鍙o紙UDP/TCP锛� */
+
{
uint16_t dev_id = g_com_map[DEV_ID];
uint16_t udp_port = g_com_map[UDP_PORT];
@@ -101,23 +158,21 @@
uint16_t tip2 = g_com_map[TCP_IP_2];
uint16_t tip3 = g_com_map[TCP_IP_3];
- /* VERSION 绱㈠紩鍦� global_param.h 涓负 0x1锛屽鏋滈渶瑕佹墦鍗扮増鏈彿瀛楃涓诧紝鍙槧灏勫埌鍏跺畠瀛樺偍锛涚洰鍓嶄粎鎵撳嵃鏁存暟 */
+
uint16_t version = g_com_map[VERSION];
- printf("[BOOT] Version: %u\r\n", version);
- printf("[BOOT] DeviceID: %u\r\n", dev_id);
- printf("[BOOT] UDP Server: %u.%u.%u.%u:%u\r\n", ip0, ip1, ip2, ip3, udp_port);
- printf("[BOOT] TCP Server: %u.%u.%u.%u:%u\r\n", tip0, tip1, tip2, tip3, tcp_port);
+ HIDO_Debug2("[BOOT] Version: %u\r\n", version);
+ HIDO_Debug2("[BOOT] DeviceID: %u\r\n", dev_id);
+ HIDO_Debug2("[BOOT] UDP Server: %u.%u.%u.%u:%u\r\n", ip0, ip1, ip2, ip3, udp_port);
+ HIDO_Debug2("[BOOT] TCP Server: %u.%u.%u.%u:%u\r\n", tip0, tip1, tip2, tip3, tcp_port);
}
- TaskHandle_t xTaskHandle = NULL;
-
osSemaphoreAttr_t semaphore_attr = {
.name = "MySemaphore",
.attr_bits = 0,
.cb_mem = NULL,
.cb_size = 0};
- // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟脚猴拷锟斤拷锟斤拷锟斤拷始锟斤拷锟斤拷为0锟斤拷锟斤拷锟斤拷锟斤拷为1锟斤拷
+ //
g_semaphoreHandle = osSemaphoreNew(1, 0, &semaphore_attr);
xTaskCreate(
@@ -126,5 +181,5 @@
2048,
NULL,
tskIDLE_PRIORITY + 1,
- &xTaskHandle);
+ &g_app_task_handle);
}
--
Gitblit v1.10.0