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