revert^2_T-T
This commit is contained in:
parent
9c7e5ce006
commit
f4c866f892
@ -142,7 +142,7 @@ int8_t Config_ShootInit(void) {
|
|||||||
.id = 0x201 + i,
|
.id = 0x201 + i,
|
||||||
.module = MOTOR_M3508,
|
.module = MOTOR_M3508,
|
||||||
/*设置电机反装;example***********************
|
/*设置电机反装;example***********************
|
||||||
.reverse = (i == 0||1||3||5) ? true : false,*/
|
.reverse = (i == 0||i == 2) ? true : false,*/
|
||||||
.reverse = (i == 1) ? true : false,
|
.reverse = (i == 1) ? true : false,
|
||||||
.gear = false,
|
.gear = false,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,10 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* far♂蛇模块
|
* far♂蛇模块
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/********************************* 使用示例 **********************************/
|
/****************************************************************************/
|
||||||
|
/********************************* 新手教程 **********************************/
|
||||||
|
|
||||||
/*1.配置config参数以及Config_ShootInit函数参数*/
|
/*1.配置config参数以及Config_ShootInit函数参数*/
|
||||||
/*2.
|
/*2.在cmd任务中获取遥控器数据,如下解析后发送给shoot任务
|
||||||
|
DEVICE_AT9S_t at9s_from_rc;
|
||||||
|
Shoot_CMD_t cmd_for_shoot;
|
||||||
|
osMessageQueueGet(task_runtime.msgq.cmd.rc, &at9s_from_rc, NULL, 0);
|
||||||
|
|
||||||
|
switch (at9s_from_rc.data.key_C) {
|
||||||
|
case AT9S_CMD_SW_DOWN:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = true;
|
||||||
|
cmd_for_shoot.firecmd = true;
|
||||||
|
break;
|
||||||
|
case AT9S_CMD_SW_MID:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = true;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
case AT9S_CMD_SW_UP:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = false;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = false;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
osMessageQueuePut(task_runtime.msgq.shoot.cmd, &cmd_for_shoot, 0, 0);*/
|
||||||
|
/*3.在shoot任务中完成初始化,接收控制指令以及控制函数调用
|
||||||
COMP_AT9S_CMD_t shoot_ctrl_cmd_rc;
|
COMP_AT9S_CMD_t shoot_ctrl_cmd_rc;
|
||||||
Shoot_t shoot;
|
Shoot_t shoot;
|
||||||
Shoot_CMD_t shoot_cmd;
|
Shoot_CMD_t shoot_cmd;
|
||||||
@ -13,22 +43,18 @@ void Task(void *argument) {
|
|||||||
|
|
||||||
Config_ShootInit();
|
Config_ShootInit();
|
||||||
Shoot_Init(&shoot,&Config_GetRobotParam()->shoot_param,SHOOT_CTRL_FREQ);
|
Shoot_Init(&shoot,&Config_GetRobotParam()->shoot_param,SHOOT_CTRL_FREQ);
|
||||||
Shoot_SetMode(&shoot,SHOOT_MODE_SINGLE); 初始化一个模式
|
/*关于模式切换,有两种方式:1.初始化一个模式
|
||||||
|
Shoot_SetMode(&shoot,SHOOT_MODE_SINGLE);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
/*关于模式切换,有两种方式:2.或者用遥控器某一摇杆随时切换模式
|
||||||
shoot_cmd.online =shoot_ctrl_cmd_rc.online;
|
shoot.mode =shoot_ctrl_cmd_rc.mode;
|
||||||
shoot_cmd.ready =shoot_ctrl_cmd_rc.shoot.ready;
|
osMessageQueueGet(task_runtime.msgq.shoot.cmd, &shoot_cmd, NULL, 0);
|
||||||
shoot_cmd.firecmd =shoot_ctrl_cmd_rc.shoot.firecmd;
|
Shoot_UpdateFeedback(&shoot);
|
||||||
|
Shoot_Control(&shoot,&shoot_cmd);
|
||||||
shoot.mode =shoot_ctrl_cmd_rc.mode; 或者用遥控器随时切换模式;二选一
|
|
||||||
|
|
||||||
Chassis_UpdateFeedback(&shoot);
|
|
||||||
Shoot_Control(&shoot,&shoot_cmd);
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
*******************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -39,7 +65,6 @@ void Task(void *argument) {
|
|||||||
#include "component/user_math.h"
|
#include "component/user_math.h"
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
#define WONDERFUL_COMPENSATION_FORHERO 0.010478f//给英雄做的补偿
|
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
static bool last_firecmd;
|
static bool last_firecmd;
|
||||||
@ -184,8 +209,6 @@ int8_t Shoot_CaluTargetAngle(Shoot_t *s, Shoot_CMD_t *cmd)
|
|||||||
{
|
{
|
||||||
s->anglecalu.time_last_shoot=s->now;
|
s->anglecalu.time_last_shoot=s->now;
|
||||||
CircleAdd(&s->target_variable.target_angle, M_2PI/s->param->num_trig_tooth, M_2PI);
|
CircleAdd(&s->target_variable.target_angle, M_2PI/s->param->num_trig_tooth, M_2PI);
|
||||||
if(s->param->trig_motor_param.module==MOTOR_M3508){
|
|
||||||
s->target_variable.target_angle+=WONDERFUL_COMPENSATION_FORHERO;}
|
|
||||||
s->anglecalu.num_to_shoot--;
|
s->anglecalu.num_to_shoot--;
|
||||||
}
|
}
|
||||||
return SHOOT_OK;
|
return SHOOT_OK;
|
||||||
|
|||||||
74
User/task/cmd.c
Normal file
74
User/task/cmd.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
cmd Task
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ----------------------------------------------------------------- */
|
||||||
|
#include "task/user_task.h"
|
||||||
|
/* USER INCLUDE BEGIN */
|
||||||
|
#include "device/at9s_pro.h"
|
||||||
|
#include "module/config.h"
|
||||||
|
#include "module/shoot.h"
|
||||||
|
|
||||||
|
//#define DEAD_AREA 0.05f
|
||||||
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
|
/* Private define ----------------------------------------------------------- */
|
||||||
|
/* Private macro ------------------------------------------------------------ */
|
||||||
|
/* Private variables -------------------------------------------------------- */
|
||||||
|
/* USER STRUCT BEGIN */
|
||||||
|
DEVICE_AT9S_t at9s_from_rc;
|
||||||
|
Shoot_CMD_t cmd_for_shoot;
|
||||||
|
/* USER STRUCT END */
|
||||||
|
|
||||||
|
/* Private function --------------------------------------------------------- */
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void Task_cmd(void *argument) {
|
||||||
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
|
const uint32_t delay_tick = osKernelGetTickFreq() / CMD_FREQ;
|
||||||
|
|
||||||
|
osDelay(CMD_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
|
/* USER CODE INIT BEGIN */
|
||||||
|
|
||||||
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
|
/* USER CODE BEGIN */
|
||||||
|
osMessageQueueGet(task_runtime.msgq.cmd.rc, &at9s_from_rc, NULL, 0);
|
||||||
|
|
||||||
|
switch (at9s_from_rc.data.key_C) {
|
||||||
|
case AT9S_CMD_SW_DOWN:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = true;
|
||||||
|
cmd_for_shoot.firecmd = true;
|
||||||
|
break;
|
||||||
|
case AT9S_CMD_SW_MID:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = true;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
case AT9S_CMD_SW_UP:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = false;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cmd_for_shoot.online = at9s_from_rc.online;
|
||||||
|
cmd_for_shoot.ready = false;
|
||||||
|
cmd_for_shoot.firecmd = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
osMessageQueuePut(task_runtime.msgq.shoot.cmd, &cmd_for_shoot, 0, 0);
|
||||||
|
|
||||||
|
/* USER CODE END */
|
||||||
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user