Skip to content

Commit

Permalink
added trailerSaddled semitrailerCar for reverse driving #510
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel32019 committed May 16, 2022
1 parent f1418c4 commit 7746ddf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
47 changes: 47 additions & 0 deletions scripts/Utils/AutoDriveUtilFuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,50 @@ function AutoDrive.hasVehicleRotatingYComponents(vehicle)
end
return ret
end

AutoDrive.implementsAllowedForReverseDriving = {
"trailer"
,"trailerlow"
,"trailerSaddled"
,"semitrailerCar"
}

function AutoDrive.isImplementAllowedForReverseDriving(vehicle,implement)
-- return true for implements allowed move reverse
local ret = false

if implement ~= nil and implement.spec_attachable ~= nil and implement.spec_attachable.attacherJoint ~= nil and implement.spec_attachable.attacherJoint.jointType ~= nil then
for i, name in ipairs(AutoDrive.implementsAllowedForReverseDriving) do
local key = "JOINTTYPE_"..string.upper(name)

if AttacherJoints[key] ~= nil and AttacherJoints[key] == implement.spec_attachable.attacherJoint.jointType then
-- Logging.info("[AD] isImplementAllowedForReverseDriving implement allowed %s ", tostring(key))
return true
end
end
end

if implement ~= nil and implement.spec_attachable ~= nil
and AttacherJoints.JOINTTYPE_IMPLEMENT == implement.spec_attachable.attacherJoint.jointType
then
local breakforce = implement.spec_attachable:getBrakeForce()
-- Logging.info("[AD] isImplementAllowedForReverseDriving implement breakforce %s ", tostring(breakforce))
if breakforce ~= nil and breakforce > 0.07 * 10
and not (implement ~= nil and implement.getName ~= nil and implement:getName() == "GL 420") -- Grimme GL 420 needs special handling, as it has breakforce >0.07, but no trailed wheel
then
return true
end
end

if implement ~= nil and implement.spec_attachable ~= nil
and AttacherJoints.JOINTTYPE_SEMITRAILER == implement.spec_attachable.attacherJoint.jointType
then
local implementX, implementY, implementZ = getWorldTranslation(implement.components[1].node)
local _, _, diffZ = worldToLocal(vehicle.components[1].node, implementX, implementY, implementZ)
if diffZ < -3 then
return true
end
end
return ret
end

44 changes: 0 additions & 44 deletions scripts/Utils/PathFinderUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,47 +66,3 @@ function AutoDrive.boundingBoxFromCorners(cornerX, cornerZ, corner2X, corner2Z,
return boundingBox
end

AutoDrive.implementsAllowedForReverseDriving = {
"trailer"
,"trailerlow"
}

function AutoDrive.isImplementAllowedForReverseDriving(vehicle,implement)
-- return true for implements allowed move reverse
local ret = false

if implement ~= nil and implement.spec_attachable ~= nil and implement.spec_attachable.attacherJoint ~= nil and implement.spec_attachable.attacherJoint.jointType ~= nil then
for i, name in ipairs(AutoDrive.implementsAllowedForReverseDriving) do
local key = "JOINTTYPE_"..string.upper(name)

if AttacherJoints[key] ~= nil and AttacherJoints[key] == implement.spec_attachable.attacherJoint.jointType then
-- Logging.info("[AD] isImplementAllowedForReverseDriving implement allowed %s ", tostring(key))
return true
end
end
end

if implement ~= nil and implement.spec_attachable ~= nil
and AttacherJoints.JOINTTYPE_IMPLEMENT == implement.spec_attachable.attacherJoint.jointType
then
local breakforce = implement.spec_attachable:getBrakeForce()
-- Logging.info("[AD] isImplementAllowedForReverseDriving implement breakforce %s ", tostring(breakforce))
if breakforce ~= nil and breakforce > 0.07 * 10
and not (implement ~= nil and implement.getName ~= nil and implement:getName() == "GL 420") -- Grimme GL 420 needs special handling, as it has breakforce >0.07, but no trailed wheel
then
return true
end
end

if implement ~= nil and implement.spec_attachable ~= nil
and AttacherJoints.JOINTTYPE_SEMITRAILER == implement.spec_attachable.attacherJoint.jointType
then
local implementX, implementY, implementZ = getWorldTranslation(implement.components[1].node)
local _, _, diffZ = worldToLocal(vehicle.components[1].node, implementX, implementY, implementZ)
if diffZ < -3 then
return true
end
end

return ret
end

0 comments on commit 7746ddf

Please sign in to comment.