From 978aa027649d638acf3676d8810c108a7959c250 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Sat, 4 Jan 2025 19:55:15 +0100 Subject: [PATCH] Should fix Test a few wheel loader, frontloader and skid loaders. - The commands: `cpShovelPositionsSetState 1` and `cpShovelPositionsSetState 3` should be sufficient --- config/VehicleConfigurations.xml | 3 +++ scripts/specializations/CpShovelPositions.lua | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/config/VehicleConfigurations.xml b/config/VehicleConfigurations.xml index b594851fc..d26fa713c 100644 --- a/config/VehicleConfigurations.xml +++ b/config/VehicleConfigurations.xml @@ -466,6 +466,9 @@ You can define the following custom settings: shovelMovingToolIx = "1" /> + + diff --git a/scripts/specializations/CpShovelPositions.lua b/scripts/specializations/CpShovelPositions.lua index 170776c7c..e6afb29b6 100644 --- a/scripts/specializations/CpShovelPositions.lua +++ b/scripts/specializations/CpShovelPositions.lua @@ -448,8 +448,16 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height --- Controls the arm height setTranslation(armProjectionNode, 0, i1y, i1z) setTranslation(armToolRefNode, ax, ay, az) + local _, shy, shz = localToLocal(shovelTool.node, armVehicle.rootNode, 0, 0, 0) + local _, _, rz = localRotationToLocal(getParent(shovelTool.node), getParent(getParent(shovelTool.node)), 0, 0, 0) local dirZ, dirY = MathUtil.vector2Normalize(shz - az, shy - ay) + if math.abs(rz) > math.rad(160) then + --- We assume the shovel node is rotated by 180 degrees, + --- so we have to flip the calculation + dirZ, dirY = MathUtil.vector2Normalize(az - shz, ay - shy) + end + oldRotRelativeArmRot = MathUtil.getYRotationFromDirection(-dirZ, dirY) + math.pi/2 alpha = math.atan2(i1y - ay, i1z - az)