Paramater.c
12.4 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#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
));
}
}