diff --git a/MDK-ARM/ELE_CHASSIS/AUTO_CHASSIS.axf b/MDK-ARM/ELE_CHASSIS/AUTO_CHASSIS.axf index 32d3906..4590adc 100644 Binary files a/MDK-ARM/ELE_CHASSIS/AUTO_CHASSIS.axf and b/MDK-ARM/ELE_CHASSIS/AUTO_CHASSIS.axf differ diff --git a/User/Module/config.c b/User/Module/config.c index 2372880..ae4bd2b 100644 --- a/User/Module/config.c +++ b/User/Module/config.c @@ -76,11 +76,11 @@ static const ConfigParam_t param_chassis ={ }, /*投球*/ .PitchConfig_Config = { - .m2006_init_angle =-150, + .m2006_init_angle =-170, .m2006_trigger_angle =0, - .go1_init_position = 0, - .go1_release_threshold =0, - .m2006_Screw_init=0 + .go1_init_position = -50, + .go1_release_threshold =-210, + .m2006_Screw_init=0, }, diff --git a/User/Module/up.c b/User/Module/up.c index 5d1e45d..0434088 100644 --- a/User/Module/up.c +++ b/User/Module/up.c @@ -120,7 +120,7 @@ int8_t VESC_M5065_Control(UP_t *u,fp32 speed) } - +int aaaaaaaaaaa=1; /*go电机控制*/ @@ -130,17 +130,17 @@ int8_t GO_SendData(UP_t *u, float pos, float limit) static int is_calibration=0; static fp32 error=0; //误差量 - GO_MotorData_t *GO_calibration;//校准前,原始数据 - GO_calibration = get_GO_measure_point() ; - if(is_calibration==0) - { - is_calibration=HAL_GPIO_ReadPin (GPIOE ,GPIO_PIN_9 ); - u->go_cmd.Pos = -50; //上电之后跑 - error= GO_calibration->Pos ; - } - u->motorfeedback .go_data = GO_calibration; - u->motorfeedback .go_data ->Pos= error ; - u->go_cmd.Pos = pos; +// GO_MotorData_t *GO_calibration;//校准前,原始数据 + u->motorfeedback .go_data = get_GO_measure_point() ; +// if(is_calibration==0) +// { +// is_calibration=HAL_GPIO_ReadPin (GPIOE ,GPIO_PIN_9 ); +// u->go_cmd.Pos = -50; //上电之后跑 +// error= GO_calibration->Pos ; +// } +// u->motorfeedback .go_data = GO_calibration; +// u->motorfeedback .go_data ->Pos= error ; +// u->go_cmd.Pos = pos; // 读取参数 float tff = u->go_cmd.T; // 前馈力矩 @@ -181,7 +181,7 @@ int8_t ALL_Motor_Control(UP_t *u,CAN_Output_t *out) &u->pid .Pitch_M2006_angle , &u->pid .Pitch_M2006_speed , u->motor_target .Pitch_M2006_angle ); - GO_SendData(u,u->motor_target .go_shoot,1 ); + GO_SendData(u,u->motor_target .go_shoot,5 ); for(int i=0;i<4;i++){ @@ -218,8 +218,8 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c) u->motor_target .go_shoot =u->PitchContext .PitchConfig .go1_init_position ; is_pitch=0; } -// u->motor_target .M2006_angle =u->PitchContext .PitchConfig .m2006_init_angle ; -// u->PitchContext .PitchState = PITCH_PREPARE; //状态更新,开始夹球 + u->motor_target .Shoot_M2006_angle =u->PitchContext .PitchConfig .m2006_init_angle ; + u->PitchContext .PitchState = PITCH_PREPARE; //状态更新,开始夹球 // /*运球*/ // u->motor_target .go_spin = u->DribbleContext.DribbleConfig .go2_init_angle ; @@ -234,12 +234,12 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c) break; case Pitch : - if (u->PitchContext .PitchState ==PITCH_PREPARE) //首次启动 + if (u->PitchContext .PitchState ==PITCH_PREPARE) { u->PitchContext .PitchState=PITCH_START;//置标志位用于启动投篮 } -// Pitch_Process(u,out,c); + Pitch_Process(u,out,c); break ; @@ -256,7 +256,7 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c) }break ; case Dribbl_transfer: - + break ; // Dribbl_transfer_a(u,out); } break; @@ -286,52 +286,52 @@ return 0; -//int8_t Pitch_Process(UP_t *u, CAN_Output_t *out,CMD_t *c) -//{ -// static fp32 go1_position,M2006_Screw_position ; -// static int is_initialize=1; -// if(is_initialize) -// { -// go1_position=u->PitchContext .PitchConfig .go1_init_position ; -// M2006_Screw_position=u->PitchContext .PitchConfig .m2006_Screw_init; -// is_initialize=0; -// } +int8_t Pitch_Process(UP_t *u, CAN_Output_t *out,CMD_t *c) +{ + static fp32 go1_position,M2006_Screw_position ; + static int is_initialize=1; + if(is_initialize) + { + go1_position=u->PitchContext .PitchConfig .go1_init_position ; + M2006_Screw_position=u->PitchContext .PitchConfig .m2006_Screw_init; + is_initialize=0; + } -// switch(u->PitchContext .PitchState){ -// -// case PITCH_START: -// u->motor_target .go_shoot = u->PitchContext .PitchConfig .go1_release_threshold; -// -//// if(u->motorfeedback .GO_motor_info[0]->Pos < -32.40){ //检测go位置到达最上面,这里的检测条件可以更改 -//// u->motor_target .M2006_angle = u->PitchContext .PitchConfig .m2006_trigger_angle ;//设置2006角度,0 -// -// u->PitchContext .PitchState=PITCH_PULL_TRIGGER; -////}//更改标志位 + switch(u->PitchContext .PitchState){ + + case PITCH_START: + u->motor_target .go_shoot = u->PitchContext .PitchConfig .go1_release_threshold; + + if(u->motorfeedback .go_data ->Pos < -209){ //检测go位置到达最上面,这里的检测条件可以更改 + u->motor_target .Shoot_M2006_angle = u->PitchContext .PitchConfig .m2006_trigger_angle ;//设置2006角度,0 + + u->PitchContext .PitchState=PITCH_PULL_TRIGGER; +}//更改标志位 -// break ; -// case PITCH_PULL_TRIGGER: -// -// -// if(u->motorfeedback .M2006 .total_angle >-1) //当2006的总角度小于1,可以认为已经勾上,误差为1 -// { -// u->motor_target .go_shoot = go1_position;//go下拉 -// u->motor_target .M3508_angle = M2006_Screw_position;//丝杠上的2006 -// go1_position = go1_position + c->Vx ; -// M2006_Screw_position=M2006_Screw_position+ c->Vy; -// -// -// } -// -// break ; + break ; + case PITCH_PULL_TRIGGER: + + + if(u->motorfeedback .DJmotor_feedback [0].total_angle >-1) //当2006的总角度小于1,可以认为已经勾上,误差为1 + { + u->motor_target .go_shoot = go1_position;//go下拉 + u->motor_target .Pitch_M2006_angle = M2006_Screw_position;//丝杠上的2006 + go1_position = go1_position + c->Vx ; + M2006_Screw_position=M2006_Screw_position+ c->Vy; + + + } + + break ; -// -// -// -// } -// -//return 0; -// -//} + + + + } + +return 0; + +} diff --git a/User/Module/up.h b/User/Module/up.h index cc81c4f..2621bfa 100644 --- a/User/Module/up.h +++ b/User/Module/up.h @@ -228,6 +228,7 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c); int8_t ALL_Motor_Control(UP_t *u,CAN_Output_t *out); int8_t DJ_processdata(DJmotor_feedback_t *f,fp32 ecd_to_angle); int8_t DJ_Angle_Control(UP_t *u,int id,DJmotor_feedback_t *f,pid_type_def *Angle_pid,pid_type_def *Speed_pid,fp32 target_angle); +int8_t Pitch_Process(UP_t *u, CAN_Output_t *out,CMD_t *c); #endif diff --git a/User/task/up_task.c b/User/task/up_task.c index 1f96fc2..2c3c423 100644 --- a/User/task/up_task.c +++ b/User/task/up_task.c @@ -68,9 +68,9 @@ void Task_up(void *argument) // -// UP_control(&UP,&UP_CAN_out,&up_cmd); - UP.motor_target .Pitch_M2006_angle =aaa; -// UP.motor_target .M2006_angle =bbb ; + UP_control(&UP,&UP_CAN_out,&up_cmd); +// UP.motor_target .go_shoot =aaa; +// UP.motor_target .Shoot_M2006_angle =bbb ; // UP.motor_target .M3508_angle =CCC; // UP.motor_target .go_shoot =aaa;