Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
f50817a218 | |||
83a9c93e16 |
4
MDK-ARM/.vscode/settings.json
vendored
4
MDK-ARM/.vscode/settings.json
vendored
@ -17,6 +17,8 @@
|
||||
"shoot.h": "c",
|
||||
"dji.h": "c",
|
||||
"calc_lib.h": "c",
|
||||
"odrive_shoot.h": "c"
|
||||
"odrive_shoot.h": "c",
|
||||
"remote_control.h": "c",
|
||||
"dji_task.h": "c"
|
||||
}
|
||||
}
|
13
MDK-ARM/.vscode/uv4.log
vendored
13
MDK-ARM/.vscode/uv4.log
vendored
@ -1,10 +1,3 @@
|
||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||
Build target 'mycode1'
|
||||
compiling read_spi.c...
|
||||
compiling odrive_shoot.c...
|
||||
compiling shoot_task.c...
|
||||
linking...
|
||||
Program Size: Code=26528 RO-data=1904 RW-data=280 ZI-data=22496
|
||||
FromELF: creating hex file...
|
||||
"mycode1\mycode1.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:03
|
||||
Load "mycode1\\mycode1.axf"
|
||||
Erase Done.Programming Done.Verify OK.Application running ...
|
||||
Flash Load finished at 22:03:22
|
||||
|
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
||||
2025/3/14 20:41:26
|
||||
2025/3/14 22:03:23
|
@ -208,37 +208,27 @@
|
||||
<Ww>
|
||||
<count>11</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angleo,0x0A</ItemText>
|
||||
<ItemText>encoder,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>12</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>shoot</ItemText>
|
||||
<ItemText>mode,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>13</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>multi_turn_angle,0x0A</ItemText>
|
||||
<ItemText>m</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angle_encoder</ItemText>
|
||||
<ItemText>trigger_motor_data,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>15</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>back_angle,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>16</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>encoder,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>17</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angles</ItemText>
|
||||
<ItemText>trigger_angle_o</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
@ -322,7 +312,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/User/Core</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
@ -37,7 +37,7 @@
|
||||
(ptr)->temperate = (data)[6]; \
|
||||
(ptr)->ecd - (ptr)->last_ecd > 4096 ? ((ptr)->round_cnt--) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->ecd - (ptr)->last_ecd < -4096 ? ((ptr)->round_cnt++) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->total_angle = (fp64)((ptr)->round_cnt * 8192 + (ptr)->ecd - (ptr)->offset_ecd ) * MOTOR_ECD_TO_ANGLE; \
|
||||
(ptr)->total_angle = (fp64)((ptr)->round_cnt * 8192 + (ptr)->ecd - (ptr)->offset_ecd ) * MOTOR_ECD_TO_ANGLE_3508; \
|
||||
}//ptr指向电机测量数据结构体的指针,data包含电机测量数据的数组.
|
||||
/*(ptr)->real_angle = (ptr)->real_angle % 360; */
|
||||
#define get_motor_offset(ptr, data) \
|
||||
@ -55,6 +55,17 @@
|
||||
(ptr)->ecd - (ptr)->last_ecd > 4096 ? ((ptr)->round_cnt--) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->ecd - (ptr)->last_ecd < -4096 ? ((ptr)->round_cnt++) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->total_angle = (fp64)((ptr)->round_cnt * 8192 + (ptr)->ecd - (ptr)->offset_ecd ) * MOTOR_ECD_TO_ANGLE_6020; \
|
||||
}
|
||||
#define get_2006_motor_measure(ptr, data) \
|
||||
{ \
|
||||
(ptr)->last_ecd = (ptr)->ecd; \
|
||||
(ptr)->ecd = (uint16_t)((data)[0] << 8 | (data)[1]); \
|
||||
(ptr)->speed_rpm = (uint16_t)((data)[2] << 8 | (data)[3]); \
|
||||
(ptr)->given_current = (uint16_t)((data)[4] << 8 | (data)[5]); \
|
||||
(ptr)->temperate = (data)[6]; \
|
||||
(ptr)->ecd - (ptr)->last_ecd > 4096 ? ((ptr)->round_cnt--) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->ecd - (ptr)->last_ecd < -4096 ? ((ptr)->round_cnt++) : ((ptr)->round_cnt=(ptr)->round_cnt); \
|
||||
(ptr)->total_angle = (fp64)((ptr)->round_cnt * 8192 + (ptr)->ecd - (ptr)->offset_ecd ) * MOTOR_ECD_TO_ANGLE_2006; \
|
||||
}
|
||||
// 解析出初始编码器值
|
||||
// #define get_5065motor_measure(ptr, data) \
|
||||
@ -132,7 +143,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
|
||||
|
||||
}
|
||||
#else
|
||||
static osEventFlagsId_t eventReceive;
|
||||
static osEventFlagsId_t eventReceive;//事件标志
|
||||
/**
|
||||
* @brief 自定义大疆电机回调函数
|
||||
* @param[in] none
|
||||
|
@ -47,7 +47,8 @@ typedef struct
|
||||
|
||||
//motor calc ecd to angle
|
||||
|
||||
#define MOTOR_ECD_TO_ANGLE (360.0 / 8191.0 / (3591.0/187.0))
|
||||
#define MOTOR_ECD_TO_ANGLE_3508 (360.0 / 8191.0 / (3591.0/187.0))
|
||||
#define MOTOR_ECD_TO_ANGLE_2006 (360.0 / 8191.0 / 36)
|
||||
#define MOTOR_ECD_TO_RAD 0.000766990394f
|
||||
#define MOTOR_ECD_TO_ANGLE_6020 (360.0 / 8191.0 )
|
||||
|
||||
|
@ -5,22 +5,26 @@
|
||||
#include <cmsis_os2.h>
|
||||
#include "remote_control.h"
|
||||
#include "dji.h"
|
||||
#include "read_spi.h"
|
||||
#include "vofa.h"
|
||||
|
||||
|
||||
extern RC_mess_t RC_mess;
|
||||
extern int16_t result;
|
||||
extern int16_t t_result;
|
||||
extern motor_measure_t *motor_3508_data;
|
||||
extern motor_measure_t *trigger_motor_data;
|
||||
Encoder_t encoder;
|
||||
float vofa[8];
|
||||
|
||||
int speed=0;
|
||||
float m=0;
|
||||
float trigger_angle_o=0;
|
||||
int mode=0;
|
||||
/**
|
||||
* \brief 电机任务
|
||||
*
|
||||
* \param argument 未使用
|
||||
*/
|
||||
|
||||
int speed=0;
|
||||
float angle=0;
|
||||
float m;
|
||||
void Task_Motor(void *argument)
|
||||
{
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
@ -28,6 +32,7 @@ void Task_Motor(void *argument)
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_CHASSIS;
|
||||
|
||||
motor_init();
|
||||
Encoder_Init(&encoder);
|
||||
|
||||
uint32_t tick = osKernelGetTickCount();
|
||||
|
||||
@ -35,12 +40,28 @@ void Task_Motor(void *argument)
|
||||
{
|
||||
//收到消息队列新数据
|
||||
|
||||
//电机控制
|
||||
//motor_speed(speed);
|
||||
m=angle*(8191/360);
|
||||
// motor_pos(m);
|
||||
// 更新编码器数据
|
||||
Update_Encoder(&encoder);
|
||||
m=trigger_angle_o*(8191/360);
|
||||
if( mode == THREE )
|
||||
{
|
||||
//当最高点时进入离合
|
||||
if(encoder.round_cnt>=8)
|
||||
{
|
||||
trigger_angle_o=2;
|
||||
trigger_pos(m);
|
||||
//CAN_cmd_200(result[MOTOR_UP],result[MOTOR_UP],result[MOTOR_UP],result[MOTOR_UP],&hcan1);
|
||||
}
|
||||
|
||||
}
|
||||
else if( mode == DZ )
|
||||
{
|
||||
//退出离合
|
||||
trigger_angle_o=0;
|
||||
trigger_pos(m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CAN_cmd_200(t_result,0,0,0,&hcan1);
|
||||
osDelay(2);
|
||||
|
||||
|
@ -2,4 +2,7 @@
|
||||
#define _DJI_TASK_H_
|
||||
|
||||
|
||||
#define THREE 3
|
||||
#define DZ 0
|
||||
|
||||
#endif
|
||||
|
@ -7,20 +7,27 @@
|
||||
#include "shoot.h"
|
||||
#include "odrive_shoot.h"
|
||||
#include "read_spi.h"
|
||||
#include "dji_task.h"
|
||||
|
||||
extern RC_mess_t RC_mess;
|
||||
Encoder_t encoder;
|
||||
double angles;
|
||||
int32_t rounds;
|
||||
int angleo = 0; //发射角度
|
||||
extern Encoder_t encoder;
|
||||
extern motor_measure_t *trigger_motor_data;//3508电机数据
|
||||
extern int mode;
|
||||
|
||||
#define GO1_SHOOT 0
|
||||
#define ODRIVE_SHOOT 1
|
||||
|
||||
//odrive发射
|
||||
#define SHOOT3 12
|
||||
#define TOP 6
|
||||
#define MIDDLE 3
|
||||
#define BOTTOM 0
|
||||
|
||||
void Task_Shoot(void *argument)
|
||||
{
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
|
||||
Encoder_Init(&encoder);
|
||||
|
||||
#if GO1_SHOOT == 1
|
||||
shooterInit();
|
||||
#endif
|
||||
@ -34,12 +41,20 @@ void Task_Shoot(void *argument)
|
||||
shoot_ball(0);
|
||||
|
||||
#elif ODRIVE_SHOOT == 1
|
||||
shootStep();
|
||||
//shoot_odrive(angleo);
|
||||
#endif
|
||||
// 更新编码器数据
|
||||
Update_Encoder(&encoder);
|
||||
if(mode == THREE)
|
||||
{
|
||||
shoot_odrive(SHOOT3);
|
||||
}
|
||||
else if(mode == DZ)
|
||||
{
|
||||
if(trigger_motor_data->total_angle ==0)//扳机已闭合
|
||||
{
|
||||
shoot_odrive(BOTTOM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
osDelayUntil(tick); /* 运行结束,等待下一个周期唤醒 */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user