Paramater.c
9.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#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 = 12;
navi.PIDPara[0].MaxLimit = 40;
navi.PIDPara[1].Kp = 0.5;//低速
navi.PIDPara[1].Ki = 0;
navi.PIDPara[1].Kd = 0;
navi.PIDPara[1].PosCofficient = 1;
navi.PIDPara[1].AngleCofficient =10;
navi.PIDPara[1].MaxLimit = 40;
navi.PIDPara[2].Kp = 0.5;
navi.PIDPara[2].Ki = 0;
navi.PIDPara[2].Kd = 0;
navi.PIDPara[2].PosCofficient = 1;
navi.PIDPara[2].AngleCofficient = 15;
navi.PIDPara[2].MaxLimit = 40;
navi.PIDPara[3].Kp = 0.35;
navi.PIDPara[3].Ki = 0;
navi.PIDPara[3].Kd = 0;
navi.PIDPara[3].PosCofficient = 0;
navi.PIDPara[3].AngleCofficient = 15;
navi.PIDPara[3].MaxLimit = 40;
}
void initAgvData()
{
Uart_Printf(COM1, "参数初始化\r\n");
agv.Command.standSiteID = 1;
agv.Command.Au_Hand = 1;
agv.Public.i_StartSig = 0;
agv.Public.i_StopSig = 0;
agv.Public.i_UpdatePathSig = 1;
agv.Command.CurDirection = 0;
Lifter1.initState = 0;
Rotate1.initState = 0;
agv.Parameter.HandSpeed = 1000;//手动速度 你看调多少 按比例
agv.Parameter.HandTurnSpeed = 200;
agv.Parameter.angleTurnSpeed = 70 ;
agv.Parameter.HandSpeedSlope = 1;
agv.Parameter.AutoSpeedSlope = 5;
agv.Command.LaserState = 0;
agv.Parameter.AdvanceParkPos = 1000;//预停车距离100
agv.Parameter.AdvanceParkSpeed = 100;//预停车速度20
agv.Parameter.OnlyAnglePos = 500;//只纠偏角度距离
agv.Parameter.LiftSpeed = 60; //举升速度600
agv.Command.Barrier_ONOFF = 1;
agv.Command.Vol = 30;
agv.Command.Music_ONOFF = 1;
agv.Command.LaserArea = 1;
agv.Parameter.AGVID = 0xA001;
agv.Parameter.lastlandIDSig = 99999;
if(agv.Parameter.AGVID == 0xA005)
{
agv.Parameter.anglecompensation = 1.7;
}
else if(agv.Parameter.AGVID == 0xA001)
{
agv.Parameter.anglecompensation = 0;
}
else if(agv.Parameter.AGVID == 0xA002)
{
agv.Parameter.anglecompensation = 0.5;
}
else if(agv.Parameter.AGVID == 0xA003)
{
agv.Parameter.anglecompensation = 0.57;
}
else if(agv.Parameter.AGVID == 0xA004)
{
agv.Parameter.anglecompensation = 0.2;
}
else if(agv.Parameter.AGVID == 0xA006)
{
agv.Parameter.anglecompensation = 0.5;
}
else if(agv.Parameter.AGVID == 0xA007)
{
agv.Parameter.anglecompensation = 1.35;
}
else if(agv.Parameter.AGVID == 0xA008)
{
agv.Parameter.anglecompensation = 1;
}
else if(agv.Parameter.AGVID == 0xA009)
{
agv.Parameter.anglecompensation = -0.6;
}
else if(agv.Parameter.AGVID == 0xA010)
{
agv.Parameter.anglecompensation = -0.8;
}
else if(agv.Parameter.AGVID == 0xA011)
{
agv.Parameter.anglecompensation = -0.1;
}
}
void InitParamater()
{
initPidData();
initAgvData();
}
void clearPathInfomation()
{
static int i = 0;
agv.Command.Heartstate = 0; // 网咯掉线复位
agv.Command.standSiteID = 1; //执行点位置1复位
agv.Public.i_UpdatePathSig = 1; //路径更新标志置1复位
agv.Public.i_QRCodeCenterStopFlag = 0;
navi.Public.DistanceAgvToSTART = 0;
Camera.UpdataFlag1 = 0;
// agv.Command.LandMarkID = 0;
Reset_Alarm(0x028e); //清除脱线,停稳,系统停车
//跑单机时不用
#if P_SETUP_SINGLE_PLAYER == 0
//清除路径和到达站点停车标志
memset(&traffic_land_marks, 0, sizeof(traffic_land_marks)); //清除所有路径信息
SetAlarm(0x0040); //手动模式下给一个系统停车报警代码,方便系统下发路径指令
#endif
}
#if P_SETUP_SINGLE_PLAYER == 1
void initPathInfo()
{
#if 1
traffic_land_marks.land_marks[0].LightStopSig = 0;//起点
traffic_land_marks.land_marks[0].pose[0] = -8400;
traffic_land_marks.land_marks[0].pose[1] = 6000;
traffic_land_marks.land_marks[0].Direction = 3;
traffic_land_marks.land_marks[0].DispatchSpeed = 500;
traffic_land_marks.land_marks[0].RunState = 0;
traffic_land_marks.land_marks[1].LightStopSig = 0;
traffic_land_marks.land_marks[1].pose[0] = -8400;
traffic_land_marks.land_marks[1].pose[1] = 1200;
traffic_land_marks.land_marks[1].Direction = 3;
traffic_land_marks.land_marks[1].DispatchSpeed = 500;
traffic_land_marks.land_marks[1].RunState = 0;
traffic_land_marks.land_marks[2].LightStopSig = 0;
traffic_land_marks.land_marks[2].pose[0] = -1200;
traffic_land_marks.land_marks[2].pose[1] = 1200;
traffic_land_marks.land_marks[2].Direction = 3;
traffic_land_marks.land_marks[2].DispatchSpeed = 500;
traffic_land_marks.land_marks[2].RunState = 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[3].RunState = 0;
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.land_marks[4].RunState = 0;
#endif
SetAlarm(0x0004);
traffic_land_marks.size = 5;
}
#elif P_SETUP_SINGLE_PLAYER == 0
void initPathInfo()
{
memset(&traffic_land_marks,0,sizeof(traffic_land_marks));
SetAlarm(0x0040);
}
#endif
#if P_SETUP_PLATFORM_TYPE == 1 //不同平台IO信号获取
#elif P_SETUP_PLATFORM_TYPE == 5
//上报Rptpose信息,参数为间隔多少毫秒上报一次
extern float CurAngle;
extern u8 restRotateOkFlag;
extern u8 FloorStepFlag2 ,JudgementFlag2 ;
void reportRPTPose(u16 IntervalTime)
{
static int Xdata = 0,Ydata = 0;
static float VolValue = 0,VolValue1 = 0;
static int LastTime1 = 0, LastTime2 = 0, StopOKFlag = 0;
if (agv.Public.Error_Flag & 0x200)
StopOKFlag = 1;
else
StopOKFlag = 0;
VolValue1 = agv.Public.Voltage1 *0.01;
if((restRotateOkFlag == 0) || (agv.Public.Error_Flag & 0x400))
{
Xdata = 0;
Ydata = 0;
}
else
{
Xdata = Camera.XCoordingData;
Ydata = Camera.YCoordingData;
}
if (agv.Public.SystemTime - LastTime1 >= IntervalTime)
{
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::%.1f_%.1f::%.1f_%.1f::%d_%d::%d_%d::%d::%.1f::%d_%d::%.2f_%d_%d_%d_%d",
Xdata, Ydata,CurrentCenterPoint.CurAngle*57.3,
agv.Command.LandMarkID, //地图号
(int)agv.Command.SetBaseSpeed, //速度
agv.Command.CurDirection, //方向
agv.Command.LaserArea, //激光避障区域
agv.Public.Error_Flag,
agv.Command.Au_Hand, //手自动
traffic_land_marks.ChargingState, //充电状态
agv.Public.SOC, //电压
1, //定位状态
Lifter1.liftState, //举升状态0最低点1最高点2举升过程中
Rotate1.rotateState, //旋转状态 0旋转完成(静止)1旋转中
Camera.UpdataFlag, //物料状态 0没料 1有料
StopOKFlag, //停稳信号1停稳
StartPoint.TarX,
agv.Public.testCurAngle,//StartPoint.TarY,
agv.Public.testTarAngle,//TargetPoint.TarX,
agv.Public.testDiffAngle,//TargetPoint.TarY,
agv.Command.standSiteID,
traffic_land_marks.size,
(int)KincoStruct1.setSpeed,
(int)KincoStruct2.setSpeed,
agv.Public.i_QRCodeCenterStopFlag,
Lifter1.encodePos,
FloorStepFlag2,
agv.Command.AGVCenterControlStateDown,
VolValue1,
agv.Public.SingleVoltage,
agv.Public.VolProtectSig,
agv.Public.StartChargingSig,
agv.Public.Current
));
}
}
#endif