#ifndef __ROBOTSELECTINIT_H #define __ROBOTSELECTINIT_H #include "sys.h" #include "system.h" //Parameter structure of robot //�����˲����ṹ�� typedef struct { float WheelSpacing; //Wheelspacing, Mec_Car is half wheelspacing //�־� ���ֳ�Ϊ���־� float AxleSpacing; //Axlespacing, Mec_Car is half axlespacing //��� ���ֳ�Ϊ����� int GearRatio; //Motor_gear_ratio //������ٱ� int EncoderAccuracy; //Number_of_encoder_lines //����������(����������) float WheelDiameter; //Diameter of driving wheel //������ֱ�� float OmniTurnRadiaus; //Rotation radius of omnidirectional trolley //ȫ����С����ת�뾶 }Robot_Parament_InitTypeDef; // Encoder structure //�������ṹ�� typedef struct { int A; int B; int C; int D; }Encoder; //The minimum turning radius of Ackermann models is determined by the mechanical structure: //the maximum Angle of the wheelbase, wheelbase and front wheels //���������͵���Сת��뾶���ɻ�е�ṹ�������־ࡢ��ࡢǰ�����ת�� #define MINI_AKM_MIN_TURN_RADIUS 0.350f //Wheelspacing, Mec_Car is half wheelspacing //�־� ������һ�� //#define MEC_wheelspacing 0.109 #define MEC_wheelspacing 0.0930 //����2021.03.30 #define Akm_wheelspacing 0.160f #define Diff_wheelSpacing 0.177f #define Four_Mortor_wheelSpacing 0.26f #define Tank_wheelSpacing 0.235f //Axlespacing, Mec_Car is half axlespacing //��� ������һ�� #define MEC_axlespacing 0.085 #define Akm_axlespacing 0.160f // Set to 1 to drive the Ackermann servo directly from TIM8 channel 1 (bench debug). // Set to 0 to use the calibrated curvature->servo model in balance.c. #define AKM_SERVO_DEBUG_REMOTE_CH1 0 // Ackermann control law selector (mutually exclusive with the debug switch above): // 0 = calibrated kinematic model: kappa = wz/Vx -> quadratic servo fit, // rear wheels get Ackermann differential. Physically correct. // 1 = direct passthrough (tuning/debug): Vz is linearly mapped across the // full servo travel, Vx is sent to both drive wheels unchanged (no // differential, no curvature math). Handy for isolating servo/motor. #define AKM_DIRECT_MAP 0 // Direct-map input span: |Vz| >= AKM_DIRECT_VZ_FULL maps to the servo end stop. // Vz > 0 = left (ROS), which maps toward AKM_SERVO_MIN (left end). // TUNING KNOB (Mode 1 & Mode 2 share it): set this to the MAX angular.z [rad/s] // your commander actually sends, so a full stick/command uses the full servo // travel. Too high -> steering stays small; too low -> servo saturates (always // full lock) and loses proportional control. Vz arrives in rad/s (usartx.c // XYZ_Target_Speed_transition: raw/1000). #define AKM_DIRECT_VZ_FULL 1.0f // Ackermann yaw-rate closed-loop assist (Mode 2), mutually exclusive with // AKM_DIRECT_MAP (direct-map wins if both are 1). "Front wheel does the main // steering, rear wheels add a yaw-rate differential" -- a simplified torque- // vectoring / yaw-rate closed loop: // path -> (Vx, kappa_cmd) -> servo main steering (calibrated fit) // + IMU yaw-rate PI differential on the rear wheels. // Degenerates EXACTLY to the Mode-0 Ackermann differential when // AKM_YAW_FF_ALPHA = 1 and AKM_YAW_KP = AKM_YAW_KI = 0. #define AKM_YAW_ASSIST 1 // PI gains on the yaw-rate error e_r = r_ref - r_imu [rad/s], output in m/s. #define AKM_YAW_KP 0.10f #define AKM_YAW_KI 0.00f // Feedforward blend: 0 = pure IMU feedback, 1 = full geometric differential. #define AKM_YAW_FF_ALPHA 0.00f // Below this |Vx| the yaw loop is frozen (integrator reset, no differential). #define AKM_YAW_MIN_SPEED 0.10f // |dv| clamp as a fraction of |Vx|, so the differential cannot stall a wheel. #define AKM_YAW_MAX_DIFF_RATIO 0.35f // gyro[2] LSB -> rad/s at FS +-500 dps (see MPU6050.c: FS_500 -> /3754.9). #define AKM_GYRO_Z_TO_RADPS 3754.9f // Light first-order low-pass on the measured yaw rate (0 = none, 1 = no filter // lag). r_f += beta*(r_meas - r_f). ~0.3 gives gentle smoothing at 200 Hz. #define AKM_YAW_IMU_LPF 0.30f // Flip to -1.0f if the IMU +z spins opposite to the ROS convention (+ = left). // MUST be verified on hardware: command a left turn and confirm gyro[2] > 0. #define AKM_GYRO_Z_SIGN (+1.0f) #define Diff_axlespacing 0.155f #define Four_Mortor__axlespacing 0.28f #define Tank_axlespacing 0.222f //Motor_gear_ratio //������ٱ� #define HALL_30F 30 #define HALL_60F 60 #define MD36N_5_18 5.18 #define MD36N_27 27 #define MD36N_51 51 #define MD36N_71 71 #define MD60N_18 18 #define MD60N_47 47 //Number_of_encoder_lines //���������� #define Photoelectric_500 500 #define Hall_13 13 //Mecanum wheel tire diameter series //������ֱ̥�� #define Mecanum_60 0.060f #define Mecanum_75 0.075f #define Mecanum_100 0.100f #define Mecanum_127 0.127f #define Mecanum_152 0.152f //Omni wheel tire diameter series //�־�ȫ����ֱ��ϵ�� #define FullDirecion_60 0.060 #define FullDirecion_75 0.075 #define FullDirecion_127 0.127 #define FullDirecion_152 0.152 #define FullDirecion_203 0.203 #define FullDirecion_217 0.217 //Black tire, tank_car wheel diameter //��ɫ��̥���Ĵ�����ֱ�� #define Black_WheelDiameter 0.065 //#define Tank_WheelDiameter 0.047 #define Tank_WheelDiameter 0.043 //Rotation radius of omnidirectional trolley //ȫ����С����ת�뾶 #define Omni_Turn_Radiaus_109 0.109 #define Omni_Turn_Radiaus_164 0.164 #define Omni_Turn_Radiaus_180 0.180 #define Omni_Turn_Radiaus_290 0.290 //The encoder octave depends on the encoder initialization Settings //��������Ƶ����ȡ���ڱ�������ʼ������ #define EncoderMultiples 4 //Wheel-speed control and encoder reading frequency //���ٿ������������ȡƵ�� #define CONTROL_FREQUENCY 200 //#define PI 3.1415f //PI //Բ���� void Robot_Select(void); void Robot_Init(double wheelspacing, float axlespacing, float omni_turn_radiaus, float gearratio,float Accuracy,float tyre_diameter); #endif