my_act.c 5 KB
#include "hardware.h"
#include "math.h"
#include "sys.h"
#include "all_value.h"
//#include "my_act.h"
///*******************电机停止*******************/
//void speed_set_mms(unsigned short id,signed long Velocity,signed long a,signed long d)
//{
//	signed long m=0;
//	signed long n=0;
//	signed long x=0;
//	signed long y=0;
//	m=id;
//	n=Velocity*60*(double)dataWheelReductionRatio/(PI*(double)dataWheelDiameter);
//	x=a*(double)dataWheelReductionRatio/(PI*(double)dataWheelDiameter);
//	y=d*(double)dataWheelReductionRatio/(PI*(double)dataWheelDiameter);
//	speed_set_rpm(m,(signed long)n,(signed long)x,(signed long)y);
//}

//void woodman(u8 a,u8 b,u8 c)  //a禁双轮 、b禁升降
//{
//	if(a==1){speed_set_mms(1,0,1500,1500);speed_set_mms(2,0,1500,1500);}
//	if(b==1) speed_set_rpm(3,0,25,50);
//	if(c==1) speed_set_rpm(4,0,25,50);
//}




///*****************手持器控制*******************/
//void hand_control(u8 button)
//{
//		switch(button)
//		{
//			case 1: Motor[1].PcToM;  MC_TargetSpeed_set(2,500);  break;//前进
//			case 2: MC_TargetSpeed_set(1,-1000);MC_TargetSpeed_set(2,-500);break;//后退
////			case 3: speed_set_rpm(1,-100,4,10);   speed_set_rpm(2,100,4,10);    break;//左转
////			case 4: speed_set_rpm(1,100,4,10);   speed_set_rpm(2,-100,4,10);  break;//右转
////			case 5: if(LIMIT_2==0){speed_set_rpm(3,-200,25,200);}else speed_set_rpm(3,0,25,200);break; //上升
////			case 6: if(LIMIT_1==0){speed_set_rpm(3,200,25,200);}else speed_set_rpm(3,0,25,200);break;//下降
////			case 7: speed_set_rpm(4,1000,25,25);delay_ms(1);break;  //正转
////			case 8: speed_set_rpm(4,-1000,25,25);delay_ms(1);break;//反转
////			case 10:speed_set_rpm(1,-100,8,10);
////					speed_set_rpm(2,100,8,10);
////					speed_set_rpm(4,-100*dataCouplingCoefficient,44,56);break;
////			case 11:speed_set_rpm(1,100,8,10);
////					speed_set_rpm(2,-100,8,10);	
////					speed_set_rpm(4,100*dataCouplingCoefficient,44,56);break;
//			default:MC_TargetSpeed_set(1,0);
//							MC_TargetSpeed_set(2,0);
////					speed_set_rpm(3,0,25,25);
////					speed_set_rpm(4,0,25,25);
//					break;
//		}	
//}

///*******************导航前进*******************/
//void guid_directiongo(double a,double b,double d,u32 acc,u32 dec)//a 导航角度、 b中心速度、c 比例、 d 目标方向
//{ 
//	static double pid_dir=0;
//	woodman(0,1,1);
//	if(radarstop==0)pid_dir=PID_realize(d,a);//检测到障碍物pid不需要调节
//	speed_set_mms(1,(signed long)(1000*b-1.1*b*pid_dir),acc,dec);
//	speed_set_mms(2,(signed long)(1000*b+1.1*b*pid_dir),acc,dec);
//}
///*******************导航后退*******************/
//void guid_directionback(double a,double b,double d,u32 acc,u32 dec)//a 导航角度 b中心速度 c 比例 d 目标方向
//{ 
//	woodman(0,1,1);
//	speed_set_mms(1,(signed long)(-(1000*b)),acc,dec);
//	speed_set_mms(2,(signed long)(-(1000*b)),acc,dec);
//}

///****************旋转到目标方向****************/
//void AGV_rot_target(u8 dir,double rot_s,double r_speed,u8 ouhe_en)//dir旋转方向 rot_speed旋转速度
//{
//	woodman(0,1,0);
//	/*耦合的条件
//	*托盘不在低位,并且agv当前点不是整体旋转点
//	*或者当前点是站台点,,站台点永远是耦合的
//	*/
//	/*原地复位也是高位耦合*/
// 	if(dir==2)//顺时针旋转
//	{
//		speed_set_rpm(1,r_speed,8,20);
//		speed_set_rpm(2,-r_speed,8,20);	
//		if(ouhe_en)speed_set_rpm(4,r_speed*rot_s,8*rot_s,20*rot_s);
//	}
//	else
//	if(dir==1)//逆时针旋转
//	{
//		speed_set_rpm(1,-r_speed,8,20);
//		speed_set_rpm(2,r_speed,8,20);
//		if(ouhe_en)speed_set_rpm(4,-r_speed*rot_s,8*rot_s,20*rot_s);
//	}
//	else
//	{			
//		speed_set_rpm(1,0,10,25);
//		speed_set_rpm(2,0,10,25);
//		speed_set_rpm(4,0,rot_s*10,rot_s*25);
//	}
//}

///*******************y轴调整********************/
//void adjust_y(double s)
//{
//	woodman(0,1,1);	
//	speed_set_mms(1,s,500,2500);
//	speed_set_mms(2,s,500,2500);
//}
///********转盘调整****************/
//void adjust_tray(double a,double b)//a 转盘角度 b转盘精度 返回1 调整完成
//{
//	woodman(1,1,0);	
//	if(a>=45&&a<(90-b))  speed_set_rpm(4,50,25,50);else
//	if(a<45&&a>b)        speed_set_rpm(4,-50,25,50);else
//	if(a>=0&&a<=b)       speed_set_rpm(4,0,25,100);else
//	if(a>=(90-b)&&a<=90) speed_set_rpm(4,0,25,100);
//}

///*********************上升************************/
//void uptray(double a)
//{
//	woodman(1,0,1);
//	if(LIMIT_2==1)
//	{
//		up_flag=0;
//		delay_ms(250);
//		speed_set_rpm(3,0,25,100);
//	}else
//	{
//		up_flag=1;
//		if(Distanceupdown<=50)
//		{
//			speed_set_rpm(3,-a,25,200);
//		}else
//		{
//			speed_set_rpm(3,-500,25,200);
//		}
//	}	
//}

///********************‘*下降************************/
//void downtray(double a)
//{
//	woodman(1,0,1);
//	if(LIMIT_1==1)
//	{
//		down_flag=0;
////		delay_ms(50);
//		speed_set_rpm(3,0,25,100);
//	}else
//	{
//		down_flag=1;
//		if(Distanceupdown<=50)
//		{
//			speed_set_rpm(3,a,25,200);
//		}else
//		{
//			speed_set_rpm(3,500,25,200);
//		}
//	}
//}
///************************旋转托盘***************************/
//void rottray(u8 a,double b)
//{
//	woodman(1,1,0);
//	if(a==1)
//	{
//		speed_set_rpm(4,-b,100,100);
//	}else
//	if(a==2)
//	{
//		speed_set_rpm(4,b,100,100);
//	}else
//	{
//		speed_set_rpm(4,0,100,100);
//	}
//}