mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
24对抗赛
This commit is contained in:
@@ -118,7 +118,7 @@ void CANCommSend(CANCommInstance *instance, uint8_t *data)
|
||||
send_len = instance->send_buf_len - i >= 8 ? 8 : instance->send_buf_len - i;
|
||||
CANSetDLC(instance->can_ins, send_len);
|
||||
memcpy(instance->can_ins->tx_buff, instance->raw_sendbuf + i, send_len);
|
||||
CANTransmit(instance->can_ins, 1);
|
||||
CANTransmit(instance->can_ins, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ void DJIMotorControl()
|
||||
|
||||
// pid_ref会顺次通过被启用的闭环充当数据的载体
|
||||
// 计算位置环,只有启用位置环且外层闭环为位置时会计算速度环输出
|
||||
if ((motor_setting->close_loop_type & ANGLE_LOOP) && motor_setting->outer_loop_type == ANGLE_LOOP)
|
||||
if (motor_setting->outer_loop_type == ANGLE_LOOP)
|
||||
{
|
||||
if (motor_setting->angle_feedback_source == OTHER_FEED)
|
||||
pid_measure = *motor_controller->other_angle_feedback_ptr;
|
||||
@@ -308,7 +308,7 @@ void DJIMotorControl()
|
||||
{
|
||||
if (sender_enable_flag[i])
|
||||
{
|
||||
CANTransmit(&sender_assignment[i], 1);
|
||||
CANTransmit(&sender_assignment[i], 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,25 +8,20 @@
|
||||
#include "robot_def.h"
|
||||
void MotorControlTask()
|
||||
{
|
||||
// static uint8_t cnt = 0; 设定不同电机的任务频率
|
||||
// if(cnt%5==0) //200hz
|
||||
// if(cnt%10==0) //100hz
|
||||
|
||||
#ifdef GIMBAL_BOARD
|
||||
#ifdef GIMBAL_BOARD
|
||||
static uint8_t cnt = 0;
|
||||
// 设定不同电机的任务频率
|
||||
if (cnt % 2 == 0) // 500hz
|
||||
{
|
||||
DJIMotorControl();
|
||||
#endif // DEBUG
|
||||
#ifdef CHASSIS_BOARD
|
||||
LKMotorControl();
|
||||
#endif // DEBUG
|
||||
cnt = 0;
|
||||
}
|
||||
cnt++;
|
||||
|
||||
/* 如果有对应的电机则取消注释,可以加入条件编译或者register对应的idx判断是否注册了电机 */
|
||||
//LKMotorControl();
|
||||
#endif // DEBUG
|
||||
#ifdef CHASSIS_BOARD
|
||||
LKMotorControl();
|
||||
#endif // DEBUG
|
||||
|
||||
// legacy support
|
||||
// 由于ht04电机的反馈方式为接收到一帧消息后立刻回传,以此方式连续发送可能导致总线拥塞
|
||||
// 为了保证高频率控制,HTMotor中提供了以任务方式启动控制的接口,可通过宏定义切换
|
||||
// HTMotorControl();
|
||||
// 将所有的CAN设备集中在一处发送,最高反馈频率仅能达到500Hz,为了更好的控制效果,应使用新的HTMotorControlInit()接口
|
||||
|
||||
// StepMotorControl();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define REMOTE_CONTROL_FRAME_SIZE 18u // 遥控器接收的buffer大小
|
||||
|
||||
// 遥控器数据
|
||||
static RC_ctrl_t rc_ctrl[2]; //[0]:当前数据TEMP,[1]:上一次的数据LAST.用于按键持续按下和切换的判断
|
||||
static RC_ctrl_t rc_ctrl[2] = {0}; //[0]:当前数据TEMP,[1]:上一次的数据LAST.用于按键持续按下和切换的判断
|
||||
static uint8_t rc_init_flag = 0; // 遥控器初始化标志位
|
||||
|
||||
// 遥控器拥有的串口实例,因为遥控器是单例,所以这里只有一个,就不封装了
|
||||
|
||||
Reference in New Issue
Block a user