增加转台
This commit is contained in:
104
app/app_turntable.h
Normal file
104
app/app_turntable.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#ifndef TURNTAABLE_H
|
||||
#define TURNTAABLE_H
|
||||
|
||||
|
||||
#include "app_power.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//编码器协议头
|
||||
|
||||
#define ENCODER_HEADER 0x1A
|
||||
#define ENCODER_MAX_COUNTS 0x1FFFFF// 最大位21位
|
||||
|
||||
#define ENCODER_PORT 2011
|
||||
|
||||
|
||||
//转台电机
|
||||
#define PITCH_MOTOR_CANID 0x7D
|
||||
#define RIGHT_MOTOR_CANID 0x7E
|
||||
#define TURN_MOTOR_CANID 0x7F
|
||||
|
||||
|
||||
#define PITCH_MOTOR_RxCANID (0x20000FD + (PITCH_MOTOR_CANID << 8)) // 0x2007DFD
|
||||
#define RIGHT_MOTOR_RxCANID (0x20000FD + (RIGHT_MOTOR_CANID << 8)) // 0x2007EFD
|
||||
#define TURN_MOTOR_RxCANID (0x20000FD + (TURN_MOTOR_CANID << 8)) // 0x2007FFD
|
||||
|
||||
|
||||
|
||||
// 力矩量程定义 (对应Byte4~5: 当前力矩)
|
||||
#define TORQUE_MIN -120.0f // 最小力矩: -120 Nm
|
||||
#define TORQUE_MAX 120.0f // 最大力矩: 120 Nm
|
||||
|
||||
#define ZERO_VAULE 0x0080 // 32768,需要高位在前
|
||||
|
||||
#define REMOTE_ZERO 1022
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
float r; // 径向距离
|
||||
float theta; // 极角(与Z轴的夹角,弧度制,范围[0, π])
|
||||
float phi; // 方位角(XY平面内与X轴的夹角,弧度制,范围[-π, π])
|
||||
} SphericalCoordinate;
|
||||
|
||||
|
||||
|
||||
typedef struct TurnableData
|
||||
{
|
||||
uint8_t turnable_state;
|
||||
PowerState current_state; // 当前电源状态
|
||||
|
||||
float position_x; //转台相对位置x
|
||||
float position_y; //转台相对位置y
|
||||
float position_z; //转台相对位置z
|
||||
|
||||
float desired_pitch_speed; // 期望俯仰位置
|
||||
float desired_horizontal_speed; // 期望水平位置
|
||||
float desired_pitch_position; // 期望俯仰位置
|
||||
float desired_horizontal_position; // 期望水平位置
|
||||
|
||||
float left_motor_speed; // 当前左电机速度
|
||||
float right_motor_speed; // 当前右电机速度
|
||||
float speed; // 当前转盘速度
|
||||
float pitch_position; // 当前俯仰位置
|
||||
float horizontal_position; // 当前水平位置
|
||||
|
||||
float max_speed; // 最大速度
|
||||
float out_left_motor_ampere; // 输出左电机电流
|
||||
float out_right_motor_ampere; // 输出右电机电流
|
||||
float out_pitch_motor_ampere; // 输出右电机电流
|
||||
|
||||
float out_left_motor_ampere_last; // 输出左电机电流
|
||||
float out_right_motor_ampere_last; // 输出右电机电流
|
||||
float out_pitch_motor_ampere_last; // 输出右电机电流
|
||||
|
||||
float out_left_motor_ampere_limit; // 输出左电机电流限制值
|
||||
float out_right_motor_ampere_limit; // 输出右电机电流限制值
|
||||
float out_pitch_motor_ampere_limit; // 输出右电机电流限制值
|
||||
|
||||
Timer turnable_timer; // 定时器
|
||||
Timer turnable_timer1; // 定时器
|
||||
Timer turnable_timer2; // 定时器
|
||||
Timer turnable_timer3; // 定时器
|
||||
|
||||
uint8_t turnable_cnt;
|
||||
|
||||
float max_ampere; // 最大电流限制
|
||||
|
||||
float min_pitch_postion; // 位置信息
|
||||
float max_pitch_postion; // 位置信息
|
||||
} TurnableData;
|
||||
|
||||
|
||||
|
||||
void turnableInit();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TURNTAABLE_H
|
||||
Reference in New Issue
Block a user