Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on May 23, 2023. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 510
Expand file tree
/
Copy pathreverse.lua
More file actions
Latest commit
472 lines (411 loc) · 19.5 KB
/
Copy pathreverse.lua
File metadata and controls
472 lines (411 loc) · 19.5 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
localabs, max, rad, sin=math.abs, math.max, math.rad, math.sin;
functioncourseplay:goReverse(vehicle,lx,lz,mode2)
-- TODO get rid of cx and cz and the global Waypoints array. I know this is horrible but I don't want to
-- maintain a cx/cz in the Course object
localgetX=function(waypoints, ix)
returnwaypoints[ix].cxorwaypoints[ix].x
end
localgetZ=function(waypoints, ix)
returnwaypoints[ix].czorwaypoints[ix].z
end
localwaypoints, index
-- when the AI Driver is driving we want to use the course set up by the driver and not the legacy
-- global variable
-- TODO: fix missing encapsulation
index=math.min(vehicle.cp.driver.ppc:getCurrentWaypointIx() +1, vehicle.cp.driver.ppc.course:getNumberOfWaypoints())
waypoints=vehicle.cp.driver:getCurrentCourse().waypoints
localfwd=false;
localworkTool=courseplay:getFirstReversingWheeledWorkTool(vehicle) orvehicle.cp.workTools[1];
localnewTarget;
localattacherVehicle;
ifvehicle.cp.turnTargetsandvehicle.cp.curTurnIndexthen
newTarget=vehicle.cp.turnTargets[vehicle.cp.curTurnIndex];
end;
ifworkToolthen
attacherVehicle=workTool.getAttacherVehicleandworkTool:getAttacherVehicle() orvehicle;
-- Attacher modules and HookLift modules that needs the hookLiftTrailer
ifcourseplay:isHookLift(workTool) orcourseplay:isAttacherModule(workTool) then
workTool=attacherVehicle;
ifworkTool==vehicleandvehicle.cp.workTools[2] ~=nilthen
workTool=vehicle.cp.workTools[2];
ifcourseplay:isAttacherModule(workTool) then
workTool=attacherVehicle;
end;
end;
end;
end;
localmode=vehicle.cp.settings.driverMode:get()
localdebugActive=courseplay.debugChannels[courseplay.DBG_REVERSE];
localisNotValid=vehicle.cp.numWorkTools==0orworkTool==nilorworkTool.cp.isPivot==nilornotworkTool.cp.frontNodeormode==courseplay.MODE_SHOVEL_FILL_AND_EMPTY;
ifisNotValidthen
-- Simple reversing, no trailer to back up, so set the direction and get out of here, no need for
-- all the sophisticated reversing
ifnewTargetthen
-- If we have the revPosX, revPosZ set, use those
ifnewTarget.revPosXandnewTarget.revPosZthen
local_, vehicleY, _=getWorldTranslation(vehicle.cp.directionNode);
lx, lz=AIVehicleUtil.getDriveDirection(vehicle.cp.directionNode, newTarget.revPosX, vehicleY, newTarget.revPosZ);
end;
elseifmode~=courseplay.MODE_SHOVEL_FILL_AND_EMPTYthen
-- Start: Fixes issue #525
localtx, ty, tz=localToWorld(vehicle.cp.directionNode, 0, 1, -3);
localnx, ny, nz=localDirectionToWorld(vehicle.cp.directionNode, lx, -0,1, lz);
courseplay:doTriggerRaycasts(vehicle, 'tipTrigger', 'rev', false, tx, ty, tz, nx, ny, nz);
-- End: Fixes issue #525
end
-- false means that this is a trivial reverse and can be handled by drive
return-lx,-lz,fwd, false;
end;
localnode=workTool.cp.realTurningNode;
ifmode2then
vehicle.cp.toolsRealTurningNode=node;
end
localxTipper,yTipper,zTipper=getWorldTranslation(node);
ifdebugActivethencpDebug:drawPoint(xTipper, yTipper+5, zTipper, 1, 0 , 0) end;
localfrontNode=workTool.cp.frontNode;
localxFrontNode,yFrontNode,zFrontNode=getWorldTranslation(frontNode);
localtcx,tcy,tcz=0,0,0;
ifdebugActiveandnotnewTargetthen
cpDebug:drawPoint(xFrontNode,yFrontNode+3,zFrontNode, 1, 0 , 0);
ifnotvehicle.cp.checkReverseValdityPrintedthen
localcheckValidity=false;
fori=index, #waypointsdo
ifwaypoints[i].revthen
tcx=getX(waypoints, i);
tcz=getZ(waypoints, i);
local_,_,z=worldToLocal(node, tcx,yTipper,tcz);
ifz<0then
checkValidity=true;
break;
end;
else
break;
end;
end;
ifnotcheckValiditythen
print(nameNum(vehicle) ..": reverse course is not valid");
end;
vehicle.cp.checkReverseValdityPrinted=true;
end;
end;
ifnewTargetthen
ifnewTarget.revPosXandnewTarget.revPosZthen
tcx=newTarget.revPosX;
tcz=newTarget.revPosZ;
else
tcx=newTarget.posX;
tcz=newTarget.posZ;
end;
elseifnotmode2then
fori=index, #waypointsdo
ifwaypoints[i].revandnotwaypoints[i-1].waitthen
tcx=getX(waypoints, i);
tcz=getZ(waypoints, i);
else
localdx, dz, _=courseplay:getPointDirection(waypoints[i-2], waypoints[i-1]);
tcx=getX(waypoints, i-1) +dx* (waypoints[i-1].waitand15or30);
tcz=getZ(waypoints, i-1) +dz* (waypoints[i-1].waitand15or30);
end;
localdistance=courseplay:distance(xTipper,zTipper, getX(waypoints, i-1) ,getZ(waypoints, i-1));
localwaitingPoint;
localunloadPoint;
ifwaypoints[i-1].waitthen
waitingPoint=i-1;
end;
ifwaypoints[i].waitthen
waitingPoint=i;
end;
ifwaypoints[i-1].unloadthen
unloadPoint=i-1;
end;
ifwaypoints[i].unloadthen
unloadPoint=i;
end;
-- HANDLE WAITING POINT WAYPOINT CHANGE
ifwaitingPointthen
ifworkTool.cp.realUnloadOrFillNodethen
local_,y,_=getWorldTranslation(workTool.cp.realUnloadOrFillNode);
local_,_,z=worldToLocal(workTool.cp.realUnloadOrFillNode, getX(waypoints, waitingPoint), y, getZ(waypoints, waitingPoint));
ifz>=0then
courseplay:setWaypointIndex(vehicle, waitingPoint+1);
courseplay:debug(string.format("%s: Is at waiting point", nameNum(vehicle)), courseplay.DBG_REVERSE);
break;
end;
else
ifdistance<=2then
courseplay:setWaypointIndex(vehicle, waitingPoint+1);
courseplay:debug(string.format("%s: Is at waiting point", nameNum(vehicle)), courseplay.DBG_REVERSE);
break;
end;
end;
ifdistance>3then
local_,_,z=worldToLocal(node, tcx,yTipper,tcz);
ifz<0then
courseplay:setWaypointIndex(vehicle, i-1);
break;
end;
end;
break;
elseifunloadPointthen
ifworkTool.cp.rearTipRefPointthen
localtipRefPoint=workTool.tipReferencePoints[workTool.cp.rearTipRefPoint].node
localx,y,z=getWorldTranslation(tipRefPoint);
localtipDistanceToPoint=courseplay:distance(x,z,getX(waypoints, unloadPoint),getZ(waypoints, unloadPoint))
courseplay:debug(string.format("%s:workTool.cp.rearTipRefPoint: tipDistanceToPoint: %s", nameNum(vehicle),tostring(tipDistanceToPoint)), courseplay.DBG_REVERSE);
iftipDistanceToPoint<0.5then
courseplay:setWaypointIndex(vehicle, unloadPoint+1);
courseplay:debug(string.format("%s: Is at unload point", nameNum(vehicle)), courseplay.DBG_REVERSE);
break;
end;
end
ifdistance>3then
local_,_,z=worldToLocal(node, tcx,yTipper,tcz);
ifz<0then
courseplay:setWaypointIndex(vehicle, i-1);
break;
end;
end;
break
-- SWITCH TO FORWARD
elseifwaypoints[i-1].revandnotwaypoints[i].revthen
ifdistance<=2then
courseplay:debug(string.format("%s: Change direction to forward", nameNum(vehicle)), courseplay.DBG_REVERSE);
end;
break;
-- FIND THE RIGHT START REVERSING WAYPOINT
elseifwaypoints[i-1].revandnotwaypoints[i-2].revthen
forrecNum=index, vehicle.cp.numWaypointsdo
localsrX,srZ=getX(waypoints, recNum),getZ(waypoints, recNum);
local_,_,tsrZ=worldToLocal(node,srX,yTipper,srZ);
iftsrZ<-2then
courseplay:setWaypointIndex(vehicle, recNum);
courseplay:debug(string.format("%s: First reverse point -> Change waypoint to behind trailer: %q", nameNum(vehicle), recNum), courseplay.DBG_REVERSE);
break;
end;
end;
break;
-- HANDLE REVERSE WAYPOINT CHANGE
elseifdistance>3then
local_,_,z=worldToLocal(node, tcx,yTipper,tcz);
ifz<0then
courseplay:setWaypointIndex(vehicle, i-1);
break;
end;
end;
end;
elseifmode2then
tcx,tcz=vehicle.cp.curTarget.x, vehicle.cp.curTarget.z;
end;
ifdebugActivethen
cpDebug:drawPoint(tcx, yTipper+3, tcz, 1, 1 , 1)
ifworkTool.cp.realUnloadOrFillNodethen
localxUOFNode,yUOFNode,zUOFNode=getWorldTranslation(workTool.cp.realUnloadOrFillNode);
cpDebug:drawPoint(xUOFNode,yUOFNode+5,zUOFNode, 0, 1 , 0.5);
end;
end;
locallxTipper, lzTipper=AIVehicleUtil.getDriveDirection(node, tcx, yTipper, tcz);
courseplay:showDirection(node,lxTipper, lzTipper, 1, 0, 0);
locallxFrontNode, lzFrontNode=AIVehicleUtil.getDriveDirection(frontNode, xTipper,yTipper,zTipper);
locallxTractor, lzTractor=0,0;
localmaxTractorAngle=rad(60);
-- for articulated vehicles use the articulated axis' rotation node as it is a better indicator or the
-- vehicle's orientation than the direction node which often turns/moves with an articulated vehicle part
-- TODO: consolidate this with AITurn:getTurnNode()
localturnNode
localuseArticulatedAxisRotationNode=SpecializationUtil.hasSpecialization(ArticulatedAxis, vehicle.specializations) andvehicle.spec_articulatedAxis.rotationNode
ifuseArticulatedAxisRotationNodethen
turnNode=vehicle.spec_articulatedAxis.rotationNode
else
turnNode=vehicle.cp.directionNode
end
ifworkTool.cp.isPivotthen
courseplay:showDirection(frontNode,lxFrontNode, lzFrontNode, 0, 1, 0);
lxTractor, lzTractor=AIVehicleUtil.getDriveDirection(turnNode, xFrontNode,yFrontNode,zFrontNode);
courseplay:showDirection(turnNode,lxTractor, lzTractor, 0, 0.7, 0);
localrotDelta= (workTool.cp.nodeDistance* (0.5- (0.023*workTool.cp.nodeDistance-0.073)));
localtrailerToWaypointAngle=courseplay:getLocalYRotationToPoint(node, tcx, yTipper, tcz, -1) *rotDelta;
trailerToWaypointAngle=MathUtil.clamp(trailerToWaypointAngle, -rad(90), rad(90));
localdollyToTrailerAngle=courseplay:getLocalYRotationToPoint(frontNode, xTipper, yTipper, zTipper, -1);
localtractorToDollyAngle=courseplay:getLocalYRotationToPoint(turnNode, xFrontNode, yFrontNode, zFrontNode, -1);
localrearAngleDiff= (dollyToTrailerAngle-trailerToWaypointAngle);
rearAngleDiff=MathUtil.clamp(rearAngleDiff, -rad(45), rad(45));
localfrontAngleDiff= (tractorToDollyAngle-dollyToTrailerAngle);
frontAngleDiff=MathUtil.clamp(frontAngleDiff, -rad(45), rad(45));
localangleDiff= (frontAngleDiff-rearAngleDiff) * (1.5- (workTool.cp.nodeDistance*0.4-0.9) +rotDelta);
angleDiff=MathUtil.clamp(angleDiff, -rad(45), rad(45));
lx, lz=MathUtil.getDirectionFromYRotation(angleDiff);
else
lxTractor, lzTractor=AIVehicleUtil.getDriveDirection(turnNode, xTipper,yTipper,zTipper);
courseplay:showDirection(turnNode,lxTractor, lzTractor, 1, 1, 0);
localrotDelta=workTool.cp.nodeDistance*0.3;
localtrailerToWaypointAngle=courseplay:getLocalYRotationToPoint(node, tcx, yTipper, tcz, -1) *rotDelta;
trailerToWaypointAngle=MathUtil.clamp(trailerToWaypointAngle, -math.rad(90), math.rad(90));
localtractorToTrailerAngle=courseplay:getLocalYRotationToPoint(turnNode, xTipper, yTipper, zTipper, -1);
localangleDiff= (tractorToTrailerAngle-trailerToWaypointAngle) * (1+rotDelta);
-- If we only have steering axle on the worktool and they turn when reversing, we need to steer a lot more to counter this.
ifworkTool.cp.steeringAxleUpdateBackwardsthen
angleDiff=angleDiff*4;
end;
angleDiff=MathUtil.clamp(angleDiff, -maxTractorAngle, maxTractorAngle);
lx, lz=MathUtil.getDirectionFromYRotation(angleDiff);
end;
if (mode==courseplay.MODE_GRAIN_TRANSPORTormode==courseplay.MODE_COMBIormode==courseplay.MODE_FIELDWORK) andvehicle.cp.currentTipTrigger==niland (vehicle.cp.totalFillLevel~=nilandvehicle.cp.totalFillLevel>0) then
localnx, ny, nz=localDirectionToWorld(node, lxTipper, -0.1, lzTipper);
courseplay:doTriggerRaycasts(vehicle, 'tipTrigger', 'rev', false, xTipper, yTipper+1, zTipper, nx, ny, nz);
end;
courseplay:showDirection(turnNode,lx,lz, 0.7, 0, 1);
-- do a little bit of damping if using the articulated axis as lx tends to oscillate around 0 which results in the
-- speed adjustment kicking in and slowing down the vehicle.
ifuseArticulatedAxisRotationNodeandmath.abs(lx) <0.04thenlx=0end
-- true means this code is taking care of the reversing as this is not a trivial case
-- for instance because of a trailer
returnlx,lz,fwd, true;
end;
functioncourseplay:getFirstReversingWheeledWorkTool(vehicle)
-- since some weird things like Seed Bigbag are also vehicles, check this first
ifnotvehicle.getAttachedImplementsthenreturnnilend
-- Check all attached implements if we are an wheeled workTool behind the tractor
for_, impinipairs(vehicle:getAttachedImplements()) do
-- Check if the implement is behind
ifcourseplay:isRearAttached(vehicle, imp.jointDescIndex) then
ifcourseplay:isWheeledWorkTool(imp.object) then
-- If the implement is a wheeled workTool, then return the object
returnimp.object;
else
-- If the implement is not a wheeled workTool, then check if that implement have an attached wheeled workTool and return that.
returncourseplay:getFirstReversingWheeledWorkTool(imp.object);
end;
end;
end;
-- If we didnt find any workTool, return nil
returnnil;
end;
functioncourseplay:getLocalYRotationToPoint(node, x, y, z, direction)
direction=directionor1;
localdx, _, dz=worldToLocal(node, x, y, z);
dx=dx*direction;
dz=dz*direction;
returnMathUtil.getYRotationFromDirection(dx, dz);
end;
functioncourseplay:showDirection(node,lx,lz, r, g, b)
ifcourseplay.debugChannels[courseplay.DBG_REVERSE] then
localx,y,z=getWorldTranslation(node);
localctx,_,ctz=localToWorld(node,lx*5,y,lz*5);
cpDebug:drawLine(x, y+5, z, ror1, gor0, bor0, ctx, y+5, ctz);
end
end
-- Find the first forward waypoint ahead of the vehicle
functioncourseplay:getNextFwdPoint(vehicle, isTurning)
localdirectionNode=AIDriverUtil.getDirectionNode(vehicle)
ifisTurningthen
courseplay:debug(('%s: getNextFwdPoint()'):format(nameNum(vehicle)), courseplay.DBG_REVERSE);
-- scan only the next few waypoints, we don't want to end up way further in the course, missing
-- many waypoints. The proper solution here would be to take the workarea into account as the tractor may
-- be well ahead of the turnEnd point in case of long implements. Instead we just assume 10 waypoints is
-- long enough.
fori=vehicle.cp.waypointIndex, math.min( vehicle.cp.waypointIndex+10, vehicle.cp.numWaypoints ) do
localwaypointToCheck=vehicle.Waypoints[i]
ifnotwaypointToCheck.revandnotwaypointToCheck.turnEndthen
localwpX, wpZ=waypointToCheck.cx, waypointToCheck.cz;
local_, _, disZ=worldToLocal(directionNode, wpX, getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, wpX, 300, wpZ), wpZ);
localvX, _, vZ=localToWorld( directionNode, 0, 0, 0 )
courseplay:debug(('%s: getNextFwdPoint(), vX = %.1f, vZ = %.1f, i = %d, wpX = %.1f, wpZ = %.1f, disZ = %.1f '):format(
nameNum(vehicle), vX, vZ, i, wpX, wpZ, disZ ), courseplay.DBG_REVERSE);
ifdisZ>5then
courseplay:debug(('--> return (%d) as waypointIndex'):format(i), courseplay.DBG_REVERSE);
returni;
end;
end;
end;
localix=math.min(vehicle.cp.waypointIndex+1, vehicle.cp.numWaypoints)
courseplay:debug(('\tno waypoint found in front of us, returning next waypoint (%d)'):format(ix), courseplay.DBG_REVERSE);
returnix
else
localmaxVarianceX=sin(rad(30));
localfirstFwd, firstFwdOver3;
courseplay:debug(('%s: getNextFwdPoint()'):format(nameNum(vehicle)), courseplay.DBG_REVERSE);
fori=vehicle.cp.waypointIndex, vehicle.cp.numWaypointsdo
ifnotvehicle.Waypoints[i].revthen
localx, y, z=getWorldTranslation(directionNode);
localwdx, _, wdz, dist=courseplay:getWorldDirection(x, 0, z, vehicle.Waypoints[i].cx, 0, vehicle.Waypoints[i].cz);
localdx,_,dz=worldDirectionToLocal(directionNode, wdx, 0, wdz);
ifnotfirstFwdthen
firstFwd=i;
courseplay:debug(('--> set firstFwd as %d'):format(i), courseplay.DBG_REVERSE);
end;
ifnotfirstFwdOver3anddzanddistanddz*dist>=3then
firstFwdOver3=i;
courseplay:debug(('--> set firstFwdOver3 as %d'):format(i), courseplay.DBG_REVERSE);
end;
courseplay:debug(('--> point %d, dx=%.4f, dz=%.4f, dist=%.2f, maxVarianceX=%.4f'):format(i, dx, dz, dist, maxVarianceX), courseplay.DBG_REVERSE);
ifdz>0andabs(dx) <=maxVarianceXthen-- forward and x angle <= 30°
courseplay:debug('----> return as waypointIndex', courseplay.DBG_REVERSE);
returni;
end;
end;
end;
iffirstFwdOver3then
courseplay:debug(('\treturn firstFwdOver3 (%d)'):format(firstFwdOver3), courseplay.DBG_REVERSE);
returnfirstFwdOver3;
elseiffirstFwdthen
courseplay:debug(('\treturn firstFwd (%d)'):format(firstFwd), courseplay.DBG_REVERSE);
returnfirstFwd;
end;
end;
courseplay:debug('\treturn 1', courseplay.DBG_REVERSE);
return1;
end;
functioncourseplay:getReverseProperties(vehicle, workTool)
courseplay:debug(('getReverseProperties(%q, %q)'):format(nameNum(vehicle), nameNum(workTool)), courseplay.DBG_REVERSE);
-- Make sure they are reset so they wont conflict when changing worktools
workTool.cp.frontNode=nil;
workTool.cp.isPivot=nil;
ifworkTool==vehiclethen
courseplay:debug('--> workTool is vehicle (steerable) -> return', courseplay.DBG_REVERSE);
return;
end;
ifvehicle.cp.hasSpecializationShovelthen
courseplay:debug('--> vehicle has "Shovel" spec -> return', courseplay.DBG_REVERSE);
return;
end;
-- Sugarcane trailer for some reason also have a shovel specialization but we still want to use
-- them as trailers and reverse them, for which we need the realTurningNode which is set below.
-- So only ignore tools which do have a shovel but no wheel...
ifworkTool.cp.hasSpecializationShovelandnotcourseplay:isWheeledWorkTool(workTool) then
courseplay:debug('--> workTool has "Shovel" spec and has no wheels -> return', courseplay.DBG_REVERSE);
return;
end;
ifnotcourseplay:isWheeledWorkTool(workTool) orcourseplay:isHookLift(workTool) orcourseplay:isAttacherModule(workTool) then
courseplay:debug('--> workTool doesn\'t need reverse properties -> return', courseplay.DBG_REVERSE);
return;
end;
--------------------------------------------------
localattacherVehicle=workTool:getAttacherVehicle();
ifnotworkTool.cp.distancesthen
workTool.cp.distances=courseplay:getDistances(workTool);
end;
-- TODO: figure out why these are only set for reversing, one would think they are pretty generic
-- and should be set in all cases...
workTool.cp.realTurningNode=courseplay:getRealTurningNode(workTool);
workTool.cp.realUnloadOrFillNode=courseplay:getRealUnloadOrFillNode(workTool);
ifattacherVehicle==vehicleorattacherVehicle.cp.isAttacherModulethen
workTool.cp.frontNode=courseplay:getRealTrailerFrontNode(workTool);
else
workTool.cp.frontNode=courseplay:getRealDollyFrontNode(attacherVehicle);
ifworkTool.cp.frontNodethen
courseplay:debug(string.format('--> workTool %q has dolly', nameNum(workTool)), courseplay.DBG_REVERSE);
else
courseplay:debug(string.format('--> workTool %q has invalid dolly -> return', nameNum(workTool)), courseplay.DBG_REVERSE);
return;
end;
end;
workTool.cp.nodeDistance=courseplay:getRealTrailerDistanceToPivot(workTool);
courseplay:debug("--> tz: "..tostring(workTool.cp.nodeDistance).." workTool.cp.realTurningNode: "..tostring(workTool.cp.realTurningNode), courseplay.DBG_REVERSE);
ifworkTool.cp.realTurningNode==workTool.cp.frontNodethen
courseplay:debug('--> workTool.cp.realTurningNode == workTool.cp.frontNode', courseplay.DBG_REVERSE);
workTool.cp.isPivot=false;
else
workTool.cp.isPivot=true;
end;
courseplay:debug(('--> isPivot=%s, frontNode=%s'):format(tostring(workTool.cp.isPivot), tostring(workTool.cp.frontNode)), courseplay.DBG_REVERSE);
end;