Paramater.c 12.4 KB
#include "Paramater.h"

AGVStruct agv;
navigationPID pid;
navigationStruct navi;
/*定义用于计算的点
StartPoint TargetPoint直线运行当前点(起点)和下一个点(目标点)
CurrentCenterPoint  agv运动中心实时坐标
PointOne,PointTwo,PointThree,PointFour弧线转弯用的四个点,上一个点,当前点,下一个点,下两个点
A,B为单机测试时,放置屏幕可以调整的坐标
*/
CoordinatePoints StartPoint, TargetPoint, CurrentCenterPoint, PointOne, PointTwo, PointThree, PointFour, CircleCenterPoint,FrontViewPoint;



void initPidData()
{
	navi.PIDPara[0].Kp 						  = 0.5;//高速
	navi.PIDPara[0].Ki 						  = 0;
	navi.PIDPara[0].Kd 						  = 0;
	navi.PIDPara[0].PosCofficient 	  = 1;
	navi.PIDPara[0].AngleCofficient  = 8;
	navi.PIDPara[0].MaxLimit 				= 50;
	
	navi.PIDPara[1].Kp 						  = 1;//低速
	navi.PIDPara[1].Ki 						  = 0;
	navi.PIDPara[1].Kd 						  = 0;
	navi.PIDPara[1].PosCofficient 	  = 0.8;
	navi.PIDPara[1].AngleCofficient  =15;
	navi.PIDPara[1].MaxLimit 				= 50;
	
	navi.PIDPara[2].Kp 						  = 1;
	navi.PIDPara[2].Ki 						  = 0;
	navi.PIDPara[2].Kd 						  = 0;
	navi.PIDPara[2].PosCofficient 	  = 0.6;
	navi.PIDPara[2].AngleCofficient  = 15;
	navi.PIDPara[2].MaxLimit 				= 50;
	
	navi.PIDPara[3].Kp 						  = 1;
	navi.PIDPara[3].Ki 						  = 0;
	navi.PIDPara[3].Kd 						  = 0;
	navi.PIDPara[3].PosCofficient 	  = 0;
	navi.PIDPara[3].AngleCofficient  = 15;
	navi.PIDPara[3].MaxLimit 				= 50;
}


void initAgvData()
{
	Uart_Printf(COM1, "参数初始化\r\n");
	
	agv.Command.standSiteID = 1;
	agv.Command.Au_Hand = 0;
	agv.Public.i_StartSig = 0;
	agv.Public.i_StopSig = 0;
	agv.Public.i_UpdatePathSig = 1;

	Lifter1.initState = 0;
	Rotate1.initState = 0;
	
	agv.Parameter.HandSpeed 			= 300;//手动速度  你看调多少  按比例
	agv.Parameter.HandTurnSpeed 	= 100;
	agv.Parameter.HandSpeedSlope 	= 1;
	agv.Parameter.AutoSpeedSlope 	= 5;

	agv.Command.LaserState 					= 0;
	agv.Parameter.AdvanceParkPos 		= 800;//预停车距离100
	agv.Parameter.AdvanceParkSpeed	= 60;//预停车速度20
	agv.Parameter.OnlyAnglePos 			= 500;//只纠偏角度距离
	agv.Parameter.LiftSpeed		= 60; //举升速度600
	agv.Command.Barrier_ONOFF = 1;
	agv.Command.Vol 				= 15;
	agv.Command.Music_ONOFF = 1;
	agv.Command.LaserArea = 1;
	agv.Parameter.AGVID = 0x0000;
	agv.Parameter.SetLift1Height = 320;
	agv.Command.InitShiftSig = 1;
}
void InitParamater()
{
	initPidData();
	initAgvData();
}

void clearPathInfomation()
{
    static int i = 0;

    agv.Command.standSiteID = 1; //执行点位置1复位

    agv.Public.i_UpdatePathSig = 1; //路径更新标志置1复位

    Reset_Alarm(0x12A9); //清除脱线,停稳,系统停车
	
		agv.Public.i_ShiftCenterStopFlag = 0;

    memset(&traffic_land_marks, 0, sizeof(traffic_land_marks)); //清除所有路径信息
    SetAlarm(0x0040);                                           //手动模式下给一个系统停车报警代码,方便系统下发路径指令
}


#if P_SETUP_SINGLE_PLAYER == 1
void initPathInfo()
{

#if PATHSELECTFLAG == 1
	traffic_land_marks.land_marks[0].LightStopSig = 0;//起点
	traffic_land_marks.land_marks[0].pose[0] = 800;
	traffic_land_marks.land_marks[0].pose[1] = 800;
	traffic_land_marks.land_marks[0].Direction = 9;
	traffic_land_marks.land_marks[0].DispatchSpeed = 1000;

	traffic_land_marks.land_marks[1].LightStopSig = 0;
	traffic_land_marks.land_marks[1].pose[0] = 2000;
	traffic_land_marks.land_marks[1].pose[1] = 800;
	traffic_land_marks.land_marks[1].Direction = 2;
	traffic_land_marks.land_marks[1].DispatchSpeed = 1000;
	
	traffic_land_marks.land_marks[2].LightStopSig = 0;
	traffic_land_marks.land_marks[2].pose[0] = 2000;
	traffic_land_marks.land_marks[2].pose[1] = 3000;
	traffic_land_marks.land_marks[2].Direction = 0;
	traffic_land_marks.land_marks[2].DispatchSpeed = 0;
	
//	traffic_land_marks.land_marks[3].LightStopSig = 0;
//	traffic_land_marks.land_marks[3].pose[0] = -8400;
//	traffic_land_marks.land_marks[3].pose[1] = 1200;
//	traffic_land_marks.land_marks[3].Direction = 4;
//	traffic_land_marks.land_marks[3].DispatchSpeed = 500;
//	
//	traffic_land_marks.land_marks[4].LightStopSig = 0;
//	traffic_land_marks.land_marks[4].pose[0] = -8400;
//	traffic_land_marks.land_marks[4].pose[1] = 6000;
//	traffic_land_marks.land_marks[4].Direction = 0;
//	traffic_land_marks.land_marks[4].DispatchSpeed = 0;
	traffic_land_marks.size = 3;
	#elif PATHSELECTFLAG == 2
	traffic_land_marks.land_marks[0].LightStopSig = 0;//起点
	traffic_land_marks.land_marks[0].pose[0] = 80000;
	traffic_land_marks.land_marks[0].pose[1] = 25600;
	traffic_land_marks.land_marks[0].Direction = 2;
	traffic_land_marks.land_marks[0].DispatchSpeed = 500;

	traffic_land_marks.land_marks[1].LightStopSig = 0;
	traffic_land_marks.land_marks[1].pose[0] = 72000;
	traffic_land_marks.land_marks[1].pose[1] = 25600;
	traffic_land_marks.land_marks[1].Direction = 10;
	traffic_land_marks.land_marks[1].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[2].LightStopSig = 0;
	traffic_land_marks.land_marks[2].pose[0] = 70000;
	traffic_land_marks.land_marks[2].pose[1] = 27600;
	traffic_land_marks.land_marks[2].Direction = 2;
	traffic_land_marks.land_marks[2].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[3].LightStopSig = 0;
	traffic_land_marks.land_marks[3].pose[0] = 70000;
	traffic_land_marks.land_marks[3].pose[1] = 33000;
	traffic_land_marks.land_marks[3].Direction = 1;
	traffic_land_marks.land_marks[3].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[4].LightStopSig = 0;
	traffic_land_marks.land_marks[4].pose[0] = 70000;
	traffic_land_marks.land_marks[4].pose[1] = 27600;
	traffic_land_marks.land_marks[4].Direction = 7;
	traffic_land_marks.land_marks[4].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[5].LightStopSig = 0;
	traffic_land_marks.land_marks[5].pose[0] = 72000;
	traffic_land_marks.land_marks[5].pose[1] = 25600;
	traffic_land_marks.land_marks[5].Direction = 1;
	traffic_land_marks.land_marks[5].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[6].LightStopSig = 0;
	traffic_land_marks.land_marks[6].pose[0] = 80000;
	traffic_land_marks.land_marks[6].pose[1] = 25600;
	traffic_land_marks.land_marks[6].Direction = 0;
	traffic_land_marks.land_marks[6].DispatchSpeed = 0;
	traffic_land_marks.size = 7;
	#elif PATHSELECTFLAG == 3
	traffic_land_marks.land_marks[0].LightStopSig = 0;//起点
	traffic_land_marks.land_marks[0].pose[0] = 75000;
	traffic_land_marks.land_marks[0].pose[1] = 26900;
	traffic_land_marks.land_marks[0].Direction = 1;
	traffic_land_marks.land_marks[0].DispatchSpeed = 500;

	traffic_land_marks.land_marks[1].LightStopSig = 0;
	traffic_land_marks.land_marks[1].pose[0] = 83144;
	traffic_land_marks.land_marks[1].pose[1] = 26900;
	traffic_land_marks.land_marks[1].Direction = 6;
	traffic_land_marks.land_marks[1].DispatchSpeed = 200;
	
	traffic_land_marks.land_marks[2].LightStopSig = 0;
	traffic_land_marks.land_marks[2].pose[0] = 83144;
	traffic_land_marks.land_marks[2].pose[1] = 28742;
	traffic_land_marks.land_marks[2].Direction = 1;
	traffic_land_marks.land_marks[2].DispatchSpeed = 200;
	
	traffic_land_marks.land_marks[3].LightStopSig = 0;
	traffic_land_marks.land_marks[3].pose[0] = 83144;
	traffic_land_marks.land_marks[3].pose[1] = 26900;
	traffic_land_marks.land_marks[3].Direction = 3;
	traffic_land_marks.land_marks[3].DispatchSpeed = 300;
	
	traffic_land_marks.land_marks[4].LightStopSig = 0;
	traffic_land_marks.land_marks[4].pose[0] = 84144;
	traffic_land_marks.land_marks[4].pose[1] = 26900;
	traffic_land_marks.land_marks[4].Direction = 2;
	traffic_land_marks.land_marks[4].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[5].LightStopSig = 0;
	traffic_land_marks.land_marks[5].pose[0] = 75000;
	traffic_land_marks.land_marks[5].pose[1] = 26900;
	traffic_land_marks.land_marks[5].Direction = 0;
	traffic_land_marks.land_marks[5].DispatchSpeed = 0;
	
	traffic_land_marks.size = 6;
	#elif PATHSELECTFLAG == 4
	traffic_land_marks.land_marks[0].LightStopSig = 0;//起点
	traffic_land_marks.land_marks[0].pose[0] = 75000;//90000
	traffic_land_marks.land_marks[0].pose[1] = 25200;
	traffic_land_marks.land_marks[0].Direction = 2;
	traffic_land_marks.land_marks[0].DispatchSpeed = 500;

	traffic_land_marks.land_marks[1].LightStopSig = 0;
	traffic_land_marks.land_marks[1].pose[0] = 82276;
	traffic_land_marks.land_marks[1].pose[1] = 25200;
	traffic_land_marks.land_marks[1].Direction = 9;//10
	traffic_land_marks.land_marks[1].DispatchSpeed = 300;
	
	traffic_land_marks.land_marks[2].LightStopSig = 0;
	traffic_land_marks.land_marks[2].pose[0] = 83476;
	traffic_land_marks.land_marks[2].pose[1] = 26400;
	traffic_land_marks.land_marks[2].Direction = 2;
	traffic_land_marks.land_marks[2].DispatchSpeed = 200;
	
	traffic_land_marks.land_marks[3].LightStopSig = 0;
	traffic_land_marks.land_marks[3].pose[0] = 83476;
	traffic_land_marks.land_marks[3].pose[1] = 28694;
	traffic_land_marks.land_marks[3].Direction = 1;
	traffic_land_marks.land_marks[3].DispatchSpeed = 300;
	
	traffic_land_marks.land_marks[4].LightStopSig = 0;
	traffic_land_marks.land_marks[4].pose[0] = 83476;
	traffic_land_marks.land_marks[4].pose[1] = 26400;
	traffic_land_marks.land_marks[4].Direction = 8;
	traffic_land_marks.land_marks[4].DispatchSpeed = 300;
	
	traffic_land_marks.land_marks[5].LightStopSig = 0;
	traffic_land_marks.land_marks[5].pose[0] = 82276;
	traffic_land_marks.land_marks[5].pose[1] = 25200;
	traffic_land_marks.land_marks[5].Direction = 1;
	traffic_land_marks.land_marks[5].DispatchSpeed = 500;
	
	traffic_land_marks.land_marks[6].LightStopSig = 0;
	traffic_land_marks.land_marks[6].pose[0] = 75000;
	traffic_land_marks.land_marks[6].pose[1] = 25200;
	traffic_land_marks.land_marks[6].Direction = 0;
	traffic_land_marks.land_marks[6].DispatchSpeed = 0;
	traffic_land_marks.size = 7;
#endif
	SetAlarm(0x0004);
	
}


#elif P_SETUP_SINGLE_PLAYER == 0
void initPathInfo()
{
    memset(&traffic_land_marks,0,sizeof(traffic_land_marks));
	SetAlarm(0x0040);
}
#endif

//上报Rptpose信息,参数为间隔多少毫秒上报一次
extern float CurAngle;
void reportRPTPose(u16 IntervalTime)
{
	static int LastTime1 = 0, LastTime2 = 0, StopOKFlag = 0;
	static u8 Shift1State = 0, Shift2State = 0;
	static char CurDir = 'f';
	if (agv.Public.Error_Flag & 0x200)
			StopOKFlag = 1;
	else
			StopOKFlag = 0;

	if (agv.Public.SystemTime - LastTime1 >= IntervalTime)
	{
		Uart_Printf(COM1,"%4x  %s\r\n",agv.Parameter.AGVID,ParamBuff);
			LastTime1 = agv.Public.SystemTime;
			//上报方向换向
		Create_BodyTreaty(false, et_smtagv, sort_Send, ct_rptpos, ParameterTransform("%d_%d_%0.2f::%d::%d::%d::%d::%04x::%d::%d::%d::%d::%d::%d::%d::%d::%d::%.1f_%.1f::%.1f_%.1f::%d_%d::%d_%d::%.2f_%.2f",
																																											 (int)agv.Public.Coordinate_X, (int)agv.Public.Coordinate_Y,agv.Public.Coordinate_W*57.3,
																																											 agv.Command.LandMarkID,                        //地图号
																																											 (int)agv.Command.SetBaseSpeed, //速度
																																											 agv.Command.CurDirection,                      //方向
																																											 1,                        //激光避障区域
																																											 agv.Public.Error_Flag,
																																											 agv.Command.Au_Hand,                      //手自动
																																											 traffic_land_marks.ChargingState,         //充电状态
																																											 agv.Public.SOC,//(int)KincoStruct1.voltage, //电压
																																											 1,                                        //定位状态
																																											 (int)DriverLifter1.Public.encoderPose,           //举升状态0最低点1最高点2举升过程中
																																											 Rotate1.rotateState, //旋转状态 0旋转完成(静止)1旋转中
																																											 CameraTwo.UpdataFlag,						//物料状态  0没料 1有料
																																											 StopOKFlag,                   //停稳信号1停稳
																																											 agv.Public.i_SecondCommunication,
																																											 StartPoint.TarX,
																																											 StartPoint.TarY,
																																											 TargetPoint.TarX,
																																											 TargetPoint.TarY,
																																											 agv.Command.standSiteID,
																																											 traffic_land_marks.size,
																																											 (int)DriverSteering1.Command.speed,
																																											 (int)DriverLifter1.Command.speed,
																																												 Shifter1.encodePos,
																																											 navi.Public.CenterOffset
																																											 ));
        
	}
}