增加了额外的注释
This commit is contained in:
parent
bfaae13b59
commit
f37d813bcd
|
@ -2,7 +2,7 @@
|
|||
#define CHASSIS_H
|
||||
|
||||
/**
|
||||
* @brief 底盘应用初始化,请在开启rtos之前调用
|
||||
* @brief 底盘应用初始化,请在开启rtos之前调用(目前会被RobotInit()调用)
|
||||
*
|
||||
*/
|
||||
void ChassisInit();
|
||||
|
|
|
@ -134,7 +134,7 @@ static void RemoteControlSet()
|
|||
; // 弹舱舵机控制,待添加servo_motor模块,关闭
|
||||
|
||||
// 摩擦轮控制,拨轮向上打为负,向下为正
|
||||
if (rc_data[TEMP].rc.dial < -100)
|
||||
if (rc_data[TEMP].rc.dial < -100) // 向上超过100,打开摩擦轮
|
||||
shoot_cmd_send.friction_mode = FRICTION_ON;
|
||||
else
|
||||
shoot_cmd_send.friction_mode = FRICTION_OFF;
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
#ifndef GIMBAL_CMD_H
|
||||
#define GIMBAL_CMD_H
|
||||
|
||||
/**
|
||||
* @brief 机器人核心控制任务初始化,会被RobotInit()调用
|
||||
*
|
||||
*/
|
||||
void RobotCMDInit();
|
||||
|
||||
/**
|
||||
* @brief 机器人核心控制任务,200Hz频率运行(必须高于视觉发送频率)
|
||||
*
|
||||
*/
|
||||
void RobotCMDTask();
|
||||
|
||||
#endif // !GIMBAL_CMD_H
|
|
@ -2,7 +2,7 @@
|
|||
#define GIMBAL_H
|
||||
|
||||
/**
|
||||
* @brief 初始化云台
|
||||
* @brief 初始化云台,会被RobotInit()调用
|
||||
*
|
||||
*/
|
||||
void GimbalInit();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
|
||||
#include "chassis.h"
|
||||
#endif
|
||||
|
||||
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
|
||||
#include "gimbal.h"
|
||||
#include "shoot.h"
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
#ifndef ROBOT_H
|
||||
#define ROBOT_H
|
||||
|
||||
/* Robot利用robot_def.h中的宏对不同的机器人进行了大量的兼容,同时兼容了两个开发板(云台板和底盘板)的配置 */
|
||||
|
||||
/**
|
||||
* @brief 机器人初始化,请在开启rtos之前调用.这也是唯一需要放入main函数的函数
|
||||
*
|
||||
*/
|
||||
void RobotInit();
|
||||
|
||||
/**
|
||||
* @brief 机器人任务,放入实时系统以一定频率运行,内部会调用各个应用的任务
|
||||
*
|
||||
*/
|
||||
void RobotTask();
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@
|
|||
// #define CHASSIS_BOARD //底盘板
|
||||
// #define GIMBAL_BOARD //云台板
|
||||
|
||||
// @todo: 增加机器人类型定义,后续是否要兼容所有机器人?(只兼容步兵英雄哨兵似乎就够了)
|
||||
/* 机器人类型定义 */
|
||||
// #define ROBOT_HERO 1 // 英雄机器人
|
||||
// #define ROBOT_ENINEER 2 // 工程机器人
|
||||
|
@ -46,11 +47,11 @@
|
|||
#define RADIUS_WHEEL 60 // 轮子半径
|
||||
#define REDUCTION_RATIO_WHEEL 19.0f // 电机减速比,因为编码器量测的是转子的速度而不是输出轴的速度故需进行转换
|
||||
|
||||
// 检查是否出现定义冲突
|
||||
// 检查是否出现定义冲突,只允许一个开发板定义存在,否则编译会自动报错
|
||||
#if (defined(ONE_BOARD) && defined(CHASSIS_BOARD)) || \
|
||||
(defined(ONE_BOARD) && defined(GIMBAL_BOARD)) || \
|
||||
(defined(CHASSIS_BOARD) && defined(GIMBAL_BOARD))
|
||||
#error Conflict board definition! You can only define one type.
|
||||
#error Conflict board definition! You can only define one board type.
|
||||
#endif
|
||||
|
||||
#pragma pack(1) // 压缩结构体,取消字节对齐
|
||||
|
|
|
@ -205,7 +205,7 @@ void ShootTask()
|
|||
DJIMotorSetRef(friction_l, 0);
|
||||
DJIMotorSetRef(friction_r, 0);
|
||||
break;
|
||||
default: // 当前为了调试设定的4000,因为还没有加入裁判系统无法读取弹速.后续修改为while(1);表明模式错误
|
||||
default: // 当前为了调试设定的默认值4000,因为还没有加入裁判系统无法读取弹速.
|
||||
DJIMotorSetRef(friction_l, 4000);
|
||||
DJIMotorSetRef(friction_r, 4000);
|
||||
break;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define SHOOT_H
|
||||
|
||||
/**
|
||||
* @brief 发射初始化
|
||||
* @brief 发射初始化,会被RobotInit()调用
|
||||
*
|
||||
*/
|
||||
void ShootInit();
|
||||
|
|
|
@ -11,7 +11,7 @@ void BSPInit()
|
|||
DWT_Init(168);
|
||||
BSPLogInit();
|
||||
|
||||
// 下面都是待删除的,将在实现了module之后移动到app层
|
||||
// legacy support,待删除,将在实现了led/tempctrl/buzzer的module之后移动到app层
|
||||
LEDInit();
|
||||
IMUTempInit();
|
||||
BuzzerInit();
|
||||
|
|
|
@ -26,16 +26,16 @@ static uint8_t idx; // 全局CAN实例索引,每次有新的模块注册会自
|
|||
static void CANAddFilter(CANInstance *_instance)
|
||||
{
|
||||
CAN_FilterTypeDef can_filter_conf;
|
||||
static uint8_t can1_filter_idx = 0, can2_filter_idx = 14;
|
||||
|
||||
can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST;
|
||||
can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT;
|
||||
can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1;
|
||||
can_filter_conf.SlaveStartFilterBank = 14;
|
||||
can_filter_conf.FilterIdLow = _instance->rx_id << 5;
|
||||
can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++);
|
||||
can_filter_conf.FilterActivation = CAN_FILTER_ENABLE;
|
||||
static uint8_t can1_filter_idx = 0, can2_filter_idx = 14; // 0-13给can1用,14-27给can2用
|
||||
|
||||
can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST; //使用id list模式,即只有将rxid添加到过滤器中才会接收到,其他报文会被过滤
|
||||
can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT; //使用16位id模式,即只有低16位有效
|
||||
can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1; //奇数id的模块会被分配到FIFO0,偶数id的模块会被分配到FIFO1
|
||||
can_filter_conf.SlaveStartFilterBank = 14; // 从第14个过滤器开始配置从机过滤器(在STM32的BxCAN控制器中CAN2是CAN1的从机)
|
||||
can_filter_conf.FilterIdLow = _instance->rx_id << 5; // 过滤器寄存器的低16位,因为使用STDID,所以只有低11位有效,高5位要填0
|
||||
can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++); // 根据can_handle判断是CAN1还是CAN2,然后自增
|
||||
can_filter_conf.FilterActivation = CAN_FILTER_ENABLE; // 启用过滤器
|
||||
|
||||
HAL_CAN_ConfigFilter(_instance->can_handle, &can_filter_conf);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue