From b4d4228ccca9b2821cf7c3a719f0e6cbd7297008 Mon Sep 17 00:00:00 2001 From: NeoZng Date: Fri, 23 Jun 2023 15:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86freertos=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81include=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86da?= =?UTF-8?q?emon=E7=9A=84=E4=B8=8A=E7=BA=BF=E7=AD=89=E5=BE=85=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E5=A2=9E=E5=8A=A0pid=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=95=B4=E5=AE=9A=E6=8C=87=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inc/FreeRTOSConfig.h | 1 + Makefile | 3 ++- application/cmd/robot_cmd.c | 10 +--------- basic_framework.ioc | 3 ++- bsp/{log => flash}/bsp_flash.c | 0 bsp/{log => flash}/bsp_flash.h | 0 bsp/flash/bsp_flash.md | 0 modules/BMI088/bmi088.c | 2 +- modules/algorithm/user_lib.c | 5 ++--- modules/algorithm/user_lib.h | 4 +--- modules/daemon/daemon.c | 3 ++- modules/daemon/daemon.h | 1 + modules/led/led.c | 2 +- 合理地进行PID参数整定.md | 3 +++ 14 files changed, 17 insertions(+), 20 deletions(-) rename bsp/{log => flash}/bsp_flash.c (100%) rename bsp/{log => flash}/bsp_flash.h (100%) create mode 100644 bsp/flash/bsp_flash.md create mode 100644 合理地进行PID参数整定.md diff --git a/Inc/FreeRTOSConfig.h b/Inc/FreeRTOSConfig.h index a7de255..49e09e9 100644 --- a/Inc/FreeRTOSConfig.h +++ b/Inc/FreeRTOSConfig.h @@ -69,6 +69,7 @@ #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 +#define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 /* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ /* Defaults to size_t for backward compatibility, but can be changed diff --git a/Makefile b/Makefile index c9c229f..7d22a54 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ bsp/can/bsp_can.c \ bsp/usart/bsp_usart.c \ bsp/usb/bsp_usb.c \ bsp/log/bsp_log.c \ -bsp/log/bsp_flash.c \ +bsp/flash/bsp_flash.c \ bsp/bsp_init.c \ modules/algorithm/controller.c \ modules/algorithm/kalman_filter.c \ @@ -244,6 +244,7 @@ C_INCLUDES = \ -Ibsp/spi \ -Ibsp/iic \ -Ibsp/log \ +-Ibsp/flash \ -Ibsp/pwm \ -Ibsp/bsp_legacy_support \ -Ibsp \ diff --git a/application/cmd/robot_cmd.c b/application/cmd/robot_cmd.c index 8188dc3..6a989ce 100644 --- a/application/cmd/robot_cmd.c +++ b/application/cmd/robot_cmd.c @@ -132,16 +132,8 @@ static void RemoteControlSet() { // 按照摇杆的输出大小进行角度增量,增益系数需调整 gimbal_cmd_send.yaw += 0.005f * (float)rc_data[TEMP].rc.rocker_l_; gimbal_cmd_send.pitch += 0.001f * (float)rc_data[TEMP].rc.rocker_l1; - // 摇杆控制的软件限位 - // if (gimbal_cmd_send.pitch <= PITCH_MIN_ECD) - // { - // gimbal_cmd_send.pitch = PITCH_MIN_ECD; - // } - // else if (gimbal_cmd_send.pitch >= PITCH_MAX_ECD) - // { - // gimbal_cmd_send.pitch = PITCH_MAX_ECD; - // } } + // 云台软件限位 // 底盘参数,目前没有加入小陀螺(调试似乎暂时没有必要),系数需要调整 chassis_cmd_send.vx = 10.0f * (float)rc_data[TEMP].rc.rocker_r_; // _水平方向 diff --git a/basic_framework.ioc b/basic_framework.ioc index ebde68e..3cb82bd 100644 --- a/basic_framework.ioc +++ b/basic_framework.ioc @@ -174,11 +174,12 @@ Dma.USART6_TX.1.PeriphInc=DMA_PINC_DISABLE Dma.USART6_TX.1.Priority=DMA_PRIORITY_HIGH Dma.USART6_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.IPParameters=Tasks01,configENABLE_FPU,configMAX_TASK_NAME_LEN,configUSE_TIMERS,configUSE_POSIX_ERRNO,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE +FREERTOS.IPParameters=Tasks01,configENABLE_FPU,configMAX_TASK_NAME_LEN,configUSE_TIMERS,configUSE_POSIX_ERRNO,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE,configUSE_COUNTING_SEMAPHORES FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL FREERTOS.configENABLE_FPU=1 FREERTOS.configMAX_TASK_NAME_LEN=32 FREERTOS.configTOTAL_HEAP_SIZE=20000 +FREERTOS.configUSE_COUNTING_SEMAPHORES=1 FREERTOS.configUSE_POSIX_ERRNO=0 FREERTOS.configUSE_TIMERS=0 File.Version=6 diff --git a/bsp/log/bsp_flash.c b/bsp/flash/bsp_flash.c similarity index 100% rename from bsp/log/bsp_flash.c rename to bsp/flash/bsp_flash.c diff --git a/bsp/log/bsp_flash.h b/bsp/flash/bsp_flash.h similarity index 100% rename from bsp/log/bsp_flash.h rename to bsp/flash/bsp_flash.h diff --git a/bsp/flash/bsp_flash.md b/bsp/flash/bsp_flash.md new file mode 100644 index 0000000..e69de29 diff --git a/modules/BMI088/bmi088.c b/modules/BMI088/bmi088.c index 2126cec..fb0ec46 100644 --- a/modules/BMI088/bmi088.c +++ b/modules/BMI088/bmi088.c @@ -382,7 +382,7 @@ void BMI088CalibrateIMU(BMI088Instance *_bmi088) BMI088Instance *BMI088Register(BMI088_Init_Config_s *config) { // 申请内存 - BMI088Instance *bmi088_instance = (BMI088Instance *)zero_malloc(sizeof(BMI088Instance)); + BMI088Instance *bmi088_instance = (BMI088Instance *)zmalloc(sizeof(BMI088Instance)); // 从右向左赋值,让bsp instance保存指向bmi088_instance的指针(父指针),便于在底层中断中访问bmi088_instance config->acc_int_config.id = config->gyro_int_config.id = diff --git a/modules/algorithm/user_lib.c b/modules/algorithm/user_lib.c index eb3b021..b511bb9 100644 --- a/modules/algorithm/user_lib.c +++ b/modules/algorithm/user_lib.c @@ -23,9 +23,7 @@ #define user_malloc malloc #endif -uint8_t GlobalDebugMode = 7; - -void *zero_malloc(size_t size) +void *zmalloc(size_t size) { void *ptr = malloc(size); memset(ptr, 0, size); @@ -207,3 +205,4 @@ float AverageFilter(float new_data, float *buf, uint8_t len) sum += new_data; return sum / len; } + diff --git a/modules/algorithm/user_lib.h b/modules/algorithm/user_lib.h index 4404c46..fc90e5a 100644 --- a/modules/algorithm/user_lib.h +++ b/modules/algorithm/user_lib.h @@ -23,8 +23,6 @@ #define mcos(x) (arm_cos_f32(x)) -extern uint8_t GlobalDebugMode; - #ifndef user_malloc #ifdef _CMSIS_OS_H #define user_malloc pvPortMalloc @@ -89,7 +87,7 @@ extern uint8_t GlobalDebugMode; * @param size 分配大小 * @return void* */ -void *zero_malloc(size_t size); +void *zmalloc(size_t size); // ���ٿ��� float Sqrt(float x); diff --git a/modules/daemon/daemon.c b/modules/daemon/daemon.c index 85cf752..01b4f87 100644 --- a/modules/daemon/daemon.c +++ b/modules/daemon/daemon.c @@ -13,8 +13,9 @@ DaemonInstance *DaemonRegister(Daemon_Init_Config_s *config) memset(instance, 0, sizeof(DaemonInstance)); instance->owner_id = config->owner_id; - instance->reload_count = config->reload_count == 0 ? 100 : config->reload_count; + instance->reload_count = config->reload_count == 0 ? 100 : config->reload_count; // 默认值为100 instance->callback = config->callback; + instance->temp_count = config->init_count == 0 ? 100 : config->init_count; // 默认值为100,初始计数 daemon_instances[idx++] = instance; return instance; diff --git a/modules/daemon/daemon.h b/modules/daemon/daemon.h index e729c96..a3a42cc 100644 --- a/modules/daemon/daemon.h +++ b/modules/daemon/daemon.h @@ -22,6 +22,7 @@ typedef struct daemon_ins typedef struct { uint16_t reload_count; // 实际上这是app唯一需要设置的值? + uint16_t init_count; // 上线等待时间,有些模块需要收到主控的指令才会反馈报文,或pc等需要开机时间 offline_callback callback; // 异常处理函数,当模块发生异常时会被调用 void *owner_id; // id取拥有daemon的实例的地址,如DJIMotorInstance*,cast成void*类型 } Daemon_Init_Config_s; diff --git a/modules/led/led.c b/modules/led/led.c index f3f4a38..6140fc0 100644 --- a/modules/led/led.c +++ b/modules/led/led.c @@ -8,7 +8,7 @@ static LEDInstance *bsp_led_ins[LED_MAX_NUM] = {NULL}; LEDInstance *LEDRegister(LED_Init_Config_s *led_config) { - LEDInstance *led_ins = (LEDInstance *)zero_malloc(sizeof(LEDInstance)); + LEDInstance *led_ins = (LEDInstance *)zmalloc(sizeof(LEDInstance)); // 剩下的值暂时都被置零 led_ins->led_pwm = PWMRegister(&led_config->pwm_config); led_ins->led_switch = led_config->init_swtich; diff --git a/合理地进行PID参数整定.md b/合理地进行PID参数整定.md new file mode 100644 index 0000000..17195b2 --- /dev/null +++ b/合理地进行PID参数整定.md @@ -0,0 +1,3 @@ +# 利用Ozone进行model-based PID tunning + +Ozone的实时变量可视化监测(示波器)功能可以很好地帮助我们观察控制器在时域的表现,典型的有上升时间、超调量和稳态时间等。 \ No newline at end of file