Commit Graph

22 Commits

Author SHA1 Message Date
SkyLiCoder fd2386d33a tune: retune vision and gimbal angle PID, fix manual mode velocity hold
- Vision PID: increase Kp to 100, zero Ki/Kd, tighten CoefA/B
- Gimbal angle PID: reduce to P-only (Kp=1), lower IntegralLimit,
  remove derivative/output filters, unify MaxOut to 2000
- Manual mode: hold last velocity command on lost frames instead of
  stopping
- Debug mode: reset debug_updated flag on mode switch
- Remove stale .vscode settings copy
2026-06-02 23:44:08 +08:00
SkyLiCoder 6c6efc7f36 docs: fix baud rate 115200→921600 in host comm guide 2026-06-02 18:00:00 +08:00
SkyLiCoder 3cb727e151 refactor: remove deprecated zero_force field from manual control frame
VISION_MANUAL_LEN 11→10, frame [SOF:0xA6][yaw_velocity:4][pitch_velocity:4][checksum:1].
Protocol comment, docs, README struct diagram all updated.
2026-06-02 16:41:06 +08:00
SkyLiCoder da6acdcc89 refactor: manual mode from absolute setpoint to velocity control, remove auto-enable at motor init
Manual mode now receives angular velocity (degrees/s) via 0xA6 frame instead of
absolute angle reference. The firmware integrates velocity * dt into gimbal angle ref.
Motors are no longer auto-enabled at DMMotorInit — they stay disabled until a mode
switch out of DEBUG. Extract ROBOT_CMD_DELAY macro to replace magic number.
Fix "volity" typo → "velocity" and update docs/protocol comments accordingly.
2026-06-02 16:27:07 +08:00
SkyLiCoder 88702e2832 fix: move DMA buffers from DTCM to RAM_D1, improve bsp_usart error recovery
- Add .dma_buf section in RAM_D1 for DMA-accessible USART instance pool.
  DTCM (0x20000000) is not reachable by DMA on STM32H7, causing bus errors
  (TE) when DMA writes to malloc'd buffers placed in DTCM by the XG linker
  script.
- Replace malloc with static pool (usart_pool[]) placed in .dma_buf section.
- In RxEventCallback, set recv_buff_size from Size so module callbacks know
  how many bytes were actually received.
- Use USART_RXBUFF_LIMIT (256) as the DMA transfer size instead of per-module
  recv_buff_size. The actual buffer is always 256 bytes.
- Remove recv_buff_size from USART_Init_Config_s; it is now set at runtime.
- Flush RDR, clear error flags, and clear stale DMAR in error callback to
  prevent residual conditions from re-triggering errors on DMA restart.
- Switch Vision module from UART10 to UART1.
2026-06-02 16:03:21 +08:00
SkyLiCoder 9313310a87 refactor: replace IMU mount enum with user-defined rotation matrix
Replace compile-time orientation enum/macro approach with a general
3x3 rotation matrix IMU2BODY_ROTATION. User fills in the matrix
according to actual IMU mounting orientation. Matrix must be a proper
rotation (det = +1) to preserve right-handed coordinate system.
2026-06-01 20:11:38 +08:00
SkyLiCoder b0fca63b2b docs: remove Tkinter GUI example from host communication guide 2026-05-31 19:46:44 +08:00
SkyLiCoder ea4e45b940 feat: add IMU mount orientation correction via macro-controlled axis remapping
Support NORMAL, YAW_180, ROLL_180, PITCH_180 presets selected at compile
time by IMU_MOUNT_ORIENTATION macro. Replaces direct BMI088-to-INS
assignment with IMU_Mount_Correct() for sign flip and axis swap.
2026-05-31 19:45:56 +08:00
SkyLiCoder 9b8e204ff7 feat: add DEBUG mode with host-side PID tuning, motor enable/disable protection
- Add DEBUG mode (parallel to AUTO/MANUAL) for real-time PID parameter tuning
- New 0xA8 debug frame: 12 floats for vision/motor angle PID tuning params
- DMMotorSetMode: send zero-velocity before disable, clear PID to prevent jumps
- motor_enable topic: pub from robot_cmd, sub in gimbal, controls motor on/off
- motor_pid topic: pub from robot_cmd, sub in gimbal, updates motor angle PID
- Rename DM motor enums (DM_CMD_ENABLE_MODE/DISABLE_MODE, DM_Motor_Ctrl_Mode_e)
- SwitchToAuto/Manual: re-enable motors when switching back from DEBUG mode
- Static-allocate enable_msg/pid_tune in GimbalTask to avoid stack churn
- Add docs/host_comm_guide.md with Python Tkinter tuning GUI example
- Remove ARCHITECTURE.md
2026-05-31 03:49:41 +08:00
SkyLiCoder 77a3aeb25c fix: set txconf.Identifier from tx_id before CANTransmit, enable motor task
- DM motor send functions now fill txconf.Identifier from tx_id before CANTransmit
  (MIT=tid, PosVel=tid+0x100, Velocity=tid+0x200, SetMode=tid)
- Enable motor task with stack size 1024 1000Hz
- Increase FDCAN1 StdFiltersNbr from 1 to 14
- Comment out INS temperature log, DM error handling and PID for testing
- Remove test_robot_cmd.c
2026-05-31 01:04:19 +08:00
SkyLiCoder 5e662f8458 chore: disable USB_OTG_HS in CubeMX, remove USB device library
- Remove USB_OTG_HS peripheral and all USB Device Library files
- Remove USB_DEVICE application (usb_device, usbd_cdc_if, usbd_desc, usbd_conf)
- Remove HAL PCD/LL USB driver files
- Update generated files (main.c, freertos.c, stm32h7xx_it.c, hal_conf.h, CMakeLists)
2026-05-30 21:06:58 +08:00
SkyLiCoder 8763b25839 chore: upgrade FreeRTOS to v2 (CMSIS-RTOS_V2), update CubeMX project config
- Remove CMSIS-RTOS v1 (cmsis_os.h/cmsis_os.c), add CMSIS-RTOS v2 (cmsis_os2.c/freertos_os2.h/mpool.h)
- Update FreeRTOS kernel, port, and headers to match v2 integration
- Remove unused heap implementations, keep heap_4
- Update CubeMX project config (.mxproject, .ioc, CMakeLists.txt)
- Update FreeRTOSConfig.h, freertos.c, main.c, stm32h7xx_it.c
- Update application modules (master_machine, dmmotor)
- Add CMSIS-RTOS2 headers, mpu_syscall_numbers.h, newlib/picolibc support
2026-05-30 20:40:00 +08:00
SkyLiCoder b7328a0c93 fix: migrate CMSIS-RTOS v1 to v2 API, fix stack overflow and float format crash
- Replace osThreadDef/osThreadCreate/osThread with osThreadNew/osThreadAttr_t
- Replace osSignalWait with osThreadFlagsWait
- Change osThreadId to osThreadId_t, osPriority to osPriority_t
- Increase daemon task stack from 128 to 512 to fix stack overflow HardFault
- Cast BMI088.Temperature float to int before %d format to fix va_list misalignment
2026-05-30 20:38:30 +08:00
SkyLiCoder dff49cb462 fix: replace memcpy in PIDInit with explicit field assignment
The old approach used memcpy to copy PID_Init_Config_s into PIDInstance,
relying on identical struct layout at the beginning. This is fragile and
confusing. Now assigns each field explicitly.
2026-05-30 01:14:48 +08:00
SkyLiCoder d56254d190 refactor: remove remote control, zero-force mode and emergency stop
- Remove RC_ctrl_t and RemoteControlInit from robot_cmd.c
- Delete GIMBAL_ZERO_FORCE, gimbal_mode_e, Robot_Status_e from robot_def.h
- Remove EmergencyHandler and robot_state from robot_cmd.c
- Remove emergency commands from master_machine.h
- Remove remote_control and can_comm from CMakeLists.txt
2026-05-30 01:14:00 +08:00
SkyLiCoder 3e77eed2bb fix: remove duplicate pid_ref from DMMotorInstance
DMMotorInstance had its own pid_ref field while motor_controller already
has pid_ref. Use motor_controller.pid_ref uniformly.
2026-05-30 00:36:32 +08:00
SkyLiCoder 075495791a fix: change QuaternionEKF UpdateCount (uint64_t) to accel_lpf_inited (uint8_t)
UpdateCount was only used as a first-time-initialization flag for the
accel low-pass filter, not as a real counter. Replaced with a simple
uint8_t flag and moved the set to the first-update path.
2026-05-30 00:35:54 +08:00
SkyLiCoder ea493af11f fix: remove attitude_t, unify with INS_t
- Delete attitude_t struct from ins_task.h
- INS_Init() returns INS_t* directly instead of casting from INS.Gyro offset
- Change Gimbal_Upload_Data_s.gimbal_imu_data to INS_t* pointer
- Update gimbal.c and robot_cmd.c accordingly
2026-05-30 00:27:39 +08:00
SkyLiCoder 9b52a9ec64 refactor: rename opencv module to master_machine, remove old master_process
- Delete modules/master_machine/ (old seasky protocol vision module)
- Rename modules/opencv/ → modules/master_machine/
- Rename opencv.h/c → master_machine.h/c
- Remove master_process.h include from robot_def.h and ins_task.c
- Remove VisionSetAltitude() call from ins_task.c (send not needed)
- Update all #include paths and CMakeLists.txt
2026-05-29 23:52:27 +08:00
SkyLiCoder 67a26a5ff6 cleanup: remove unused motor drivers and simplify motor_def.h
- Remove DJImotor, HTmotor, LKmotor, step_motor, servo_motor directories
- Remove Motor_Control_Setting_s and related enums (Closeloop_Type_e,
  Feedback_Source_e, Feedfoward_Type_e, MOTOR_SEND_MODE_e, Motor_Working_Type_e)
- Merge motor_reverse_flag and feedback_reverse_flag into output_reverse
- Hardcode DM motor control: IMU angle feedback → angle PID → velocity output
- Simplify Motor_Init_Config_s to only: PID params, output_reverse, motor_type, CAN config
2026-05-29 23:45:38 +08:00
SkyLiCoder 4d1702b577 refactor: migrate from DJI motors to DM motors, simplify to gimbal-only control
- Rewrite DM motor driver based on DM_6220 reference protocol (MIT/PosVel/Velocity modes)
- Use velocity control mode: MCU runs angle PID with IMU feedback, motor handles speed loop
- Rewrite vision protocol with 3 frame types (0xA5 auto data, 0xA6 manual data, 0xA7 command)
- Decouple serial parsing (opencv module) from mode switching (robot_cmd module)
- Implement dual-loop architecture: vision PID outer loop → angle ref → motor PID inner loop
- Add KF/PID reset on mode switch transitions
- Merge motor_reverse_flag and feedback_reverse_flag into single output_reverse flag
- Remove DMMotorEnable/DMMotorStop (motor always runs, controlled by angle ref)
- Remove unused modules: DJI/LK/HT/step/servo motors, chassis, shoot, referee
- Add ExitRun0Mode() for STM32H723 power supply configuration
- Clean up CMakeLists: 115 → 76 C source files
2026-05-29 23:37:36 +08:00
SkyLiCoder 5b3333125d 第一次提交 2026-05-29 17:36:34 +08:00