能用
This commit is contained in:
parent
ca4d8145e5
commit
e297b9960e
@ -410,7 +410,7 @@ motor_measure_t *get_2006_motor_point(uint8_t i)
|
||||
vesc_send_data[2] = data >> 8 ;
|
||||
vesc_send_data[3] = data ;
|
||||
|
||||
HAL_CAN_AddTxMessage(&hcan1, &vesc_tx_message, vesc_send_data, &send_mail_box);
|
||||
HAL_CAN_AddTxMessage(&hcan2, &vesc_tx_message, vesc_send_data, &send_mail_box);
|
||||
}
|
||||
|
||||
|
||||
@ -431,5 +431,5 @@ motor_measure_t *get_2006_motor_point(uint8_t i)
|
||||
vesc_tx_message.RTR = CAN_RTR_DATA;
|
||||
vesc_tx_message.DLC = 0x04;
|
||||
|
||||
HAL_CAN_AddTxMessage(&hcan1, &vesc_tx_message, vesc_send_data, &send_mail_box);
|
||||
HAL_CAN_AddTxMessage(&hcan2, &vesc_tx_message, vesc_send_data, &send_mail_box);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ typedef struct {
|
||||
#define MOTOR_ECD_TO_RAD 0.000766990394f
|
||||
#define MOTOR_ECD_TO_ANGLE_6020 (360.0 / 8191.0 )
|
||||
|
||||
#define wtrcfg_VESC_COMMAND_ERPM_MAX 35000
|
||||
#define wtrcfg_VESC_COMMAND_ERPM_MAX 40000
|
||||
#define CAN_VESC_CTRL_ID_BASE (0x300)
|
||||
|
||||
#if FREERTOS_DJI == 1
|
||||
|
@ -8,8 +8,8 @@
|
||||
// PC6 ball_up_Pin读运球 检测到输出0,未检测到输出1
|
||||
// PE13 down_Pin 下推
|
||||
// PE14 paw_Pin 爪子
|
||||
// PI6 ball_in1_Pin 读接球
|
||||
// PI7 ball_in2_Pin 读接球
|
||||
// PI6 ball_in2_Pin 读接球
|
||||
// PI7 ball_in1_Pin 读接球
|
||||
// PE11 key_Pin 收网
|
||||
#define ballcome 1
|
||||
#define balldown 0
|
||||
@ -31,7 +31,7 @@ int pass_ball(void)
|
||||
//运球
|
||||
void handling_ball(int hand, int angle)
|
||||
{
|
||||
GO_TURN_ball(TURN,go,angle);//停止运球
|
||||
|
||||
int ball_state =0;//有球
|
||||
int paw_state =0;//获取爪子开合状态
|
||||
if( hand==1)
|
||||
@ -40,11 +40,19 @@ void handling_ball(int hand, int angle)
|
||||
paw_state =1;//爪子开
|
||||
// osDelay(5);
|
||||
HAL_GPIO_WritePin(down_GPIO_Port, down_Pin, GPIO_PIN_RESET);//打出
|
||||
osDelay(500);
|
||||
angle=80;
|
||||
GO_TURN_ball(TURN,go,angle);//停止运球
|
||||
ball_state =1;//无球
|
||||
osDelay(500);
|
||||
HAL_GPIO_WritePin(down_GPIO_Port, down_Pin, GPIO_PIN_SET);//收回
|
||||
ball_state =ball_in();//获取爪子有无球状态
|
||||
}
|
||||
else if (hand==0)
|
||||
{
|
||||
angle=20;
|
||||
GO_TURN_ball(TURN,go,angle);//停止运球
|
||||
}
|
||||
if (paw_state==1&&ball_state==0)
|
||||
{
|
||||
HAL_GPIO_WritePin(paw_GPIO_Port, paw_Pin, GPIO_PIN_RESET);//爪子合
|
||||
|
@ -1,14 +1,51 @@
|
||||
#include "shoot.h"
|
||||
#include "remote_control.h"
|
||||
#include "go.h"
|
||||
|
||||
#include "calc_lib.h"
|
||||
|
||||
extern RC_mess_t RC_mess;
|
||||
extern motor_measure_t *trigger_motor_data;//3508电机数据
|
||||
extern GO go;
|
||||
|
||||
int shoot_flag = 0;
|
||||
int speed_5065=0;
|
||||
|
||||
#define KP 0.12
|
||||
#define KD 0.008
|
||||
|
||||
//sw[1] 306--1694
|
||||
void control_shoot(void)
|
||||
{
|
||||
|
||||
if(RC_mess.RC_data.sw[1]>800)
|
||||
{
|
||||
|
||||
if(HAL_GPIO_ReadPin(ball_in1_GPIO_Port, ball_in1_Pin) == GPIO_PIN_RESET)
|
||||
{
|
||||
CAN_VESC_HEAD(1);
|
||||
CAN_VESC_HEAD(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//speed_5065=5000;
|
||||
speed_5065=map_fp32(RC_mess.RC_data.ch[2],0,100,0,25000);
|
||||
CAN_VESC_RPM(1, speed_5065); //发射电机转速
|
||||
CAN_VESC_RPM(2, speed_5065); //发射电机转速
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(shoot_flag == 2 || RC_mess.RC_data.sw[5]==1694)//返回//不拨动为306
|
||||
{
|
||||
speed_5065=-5000;
|
||||
CAN_VESC_RPM(1, speed_5065); //发射电机转速
|
||||
CAN_VESC_RPM(2, speed_5065); //发射电机转速
|
||||
osDelay(2000);
|
||||
speed_5065=0;
|
||||
|
||||
}
|
||||
|
||||
osDelay(1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ typedef struct
|
||||
float allowRange;
|
||||
}GO_SHOOT;
|
||||
|
||||
void control_shoot(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,14 @@ void Task_Ball(void *argument)
|
||||
{
|
||||
|
||||
// Turn_pos=20;
|
||||
|
||||
if(RC_mess.RC_data.sw[0]==306)//加速
|
||||
{
|
||||
basketball.hand=1;
|
||||
}
|
||||
else if(RC_mess.RC_data.sw[0]==1694)//减速
|
||||
{
|
||||
basketball.hand=0;
|
||||
}
|
||||
handling_ball(basketball.hand,Turn_pos);
|
||||
bb=ball_in();
|
||||
if(bb==1)
|
||||
|
@ -40,17 +40,15 @@ void Task_Motor(void *argument)
|
||||
if(RC_mess.RC_data.sw[4]==306||shoot_f==3)
|
||||
{
|
||||
pos2006=200;
|
||||
trigger_pos(pos2006);
|
||||
|
||||
}
|
||||
else if(RC_mess.RC_data.sw[4]==1694)
|
||||
else
|
||||
{
|
||||
pos2006=0;
|
||||
trigger_pos(pos2006);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
trigger_pos(pos2006);
|
||||
CAN_cmd_1FF(t_result,0,0,0,&hcan1);
|
||||
osDelay(1);
|
||||
|
||||
|
@ -5,20 +5,15 @@
|
||||
#include <cmsis_os2.h>
|
||||
#include "remote_control.h"
|
||||
#include "shoot.h"
|
||||
#include "odrive_shoot.h"
|
||||
#include "read_spi.h"
|
||||
#include "dji.h"
|
||||
#include "go.h"
|
||||
|
||||
|
||||
extern RC_mess_t RC_mess;
|
||||
extern Encoder_t encoder;
|
||||
extern motor_measure_t *trigger_motor_data;//3508电机数据
|
||||
extern GO go;
|
||||
int shoot_flag = 0;
|
||||
int trigger_flag = 0;
|
||||
int pos=0;
|
||||
|
||||
int gopos=0;
|
||||
int speed_5065=0;
|
||||
|
||||
|
||||
#define VESC_SHOOT 1
|
||||
@ -44,40 +39,9 @@ void Task_Shoot(void *argument)
|
||||
#if VESC_SHOOT == 1
|
||||
gopos=35;//云台位置
|
||||
GO_TURN_ball(GIMBAL,go,gopos); //锁云台
|
||||
control_shoot();
|
||||
|
||||
|
||||
if(shoot_flag==1||RC_mess.RC_data.sw[0]==306)//加速
|
||||
{
|
||||
|
||||
if(HAL_GPIO_ReadPin(ball_in1_GPIO_Port, ball_in1_Pin) == GPIO_PIN_RESET)
|
||||
{
|
||||
CAN_VESC_HEAD(1);
|
||||
CAN_VESC_HEAD(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
speed_5065=35000;
|
||||
CAN_VESC_RPM(1, speed_5065); //发射电机转速
|
||||
CAN_VESC_RPM(2, speed_5065); //发射电机转速
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if(shoot_flag == 2 || RC_mess.RC_data.sw[5]==1694)//返回//不拨动为306
|
||||
{
|
||||
speed_5065=-5000;
|
||||
CAN_VESC_RPM(1, speed_5065); //发射电机转速
|
||||
CAN_VESC_RPM(2, speed_5065); //发射电机转速
|
||||
|
||||
}
|
||||
else if(shoot_flag == 0)
|
||||
{
|
||||
CAN_VESC_RPM(1, 0); //发射电机转速
|
||||
CAN_VESC_RPM(2, 0); //发射电机转速
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
|
Loading…
Reference in New Issue
Block a user