Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
0456: fix JD S690i wrong motor data
Browse files Browse the repository at this point in the history
speed level 1 had a wrong max torque
fixes #415
  • Loading branch information
Jakob Tischler committed Apr 3, 2014
1 parent 9b7aa34 commit 579d019
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 93 deletions.
4 changes: 3 additions & 1 deletion combines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ function courseplay:calculateInitialCombineOffset(self, combine)
end;

--special tools, special cases
if combine.cp.isJohnDeereS650 then
if combine.cp.isJohnDeereS690i then
self.cp.combineOffset = 9.5;
elseif combine.cp.isJohnDeereS650 then
self.cp.combineOffset = 7.7;
elseif combine.cp.isCaseIH7130 then
self.cp.combineOffset = 8.0;
Expand Down
155 changes: 71 additions & 84 deletions drive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,10 @@ function courseplay:drive(self, dt)
courseplay:unregister_at_combine(self, self.cp.activeCombine)
end

-- switch lights on!
-- Turn on sound / control lights
if not self.isControlled then
-- we want to hear our courseplayers
setVisibility(self.aiMotorSound, true)
if courseplay.lightsNeeded then
self:setLightsVisibility(true);
else
self:setLightsVisibility(false);
end;
setVisibility(self.aiMotorSound, true); --TODO (Jakob): still needed in FS13?
self:setLightsVisibility(courseplay.lightsNeeded);
end;

-- current position
Expand Down Expand Up @@ -668,6 +663,7 @@ function courseplay:drive(self, dt)
allowedToDrive = courseplay:brakeToStop(self)
end

-- MODE 9 --TODO (Jakob): why is this in drive instead of mode9?
local WpUnload = false
if self.cp.shovelEmptyPoint ~= nil and self.recordnumber >=3 then
WpUnload = self.recordnumber == self.cp.shovelEmptyPoint
Expand Down Expand Up @@ -700,6 +696,7 @@ function courseplay:drive(self, dt)
end
end
end
-- MODE 9 END



Expand Down Expand Up @@ -829,8 +826,8 @@ function courseplay:drive(self, dt)
else
courseplay:setSpeed(self, refSpeed, self.cp.speeds.sl)
end
-- go, go, go!

-- DISTANCE TO CHANGE WAYPOINT
if self.recordnumber == 1 or self.recordnumber == self.maxnumber - 1 or self.Waypoints[self.recordnumber].turn then
if self.cp.hasSpecializationArticulatedAxis then
distToChange = self.cp.mode == 9 and 2 or 1; -- ArticulatedAxis vehicles
Expand Down Expand Up @@ -1063,96 +1060,86 @@ function courseplay:deleteCollisionVehicle(vehicle)
end
end

function courseplay:setSpeed(self, refSpeed, sl)
if self.lastSpeedSave ~= self.lastSpeedReal*3600 then
if refSpeed*3600 == 1 then
refSpeed = 1.6 / 3600
function courseplay:setSpeed(vehicle, refSpeed, sl)
if vehicle.lastSpeedSave ~= vehicle.lastSpeedReal*3600 then
local refSpeedKph = refSpeed * 3600;
local lastSpeedKph = vehicle.lastSpeed * 3600;

if refSpeedKph == 1 then
refSpeed = 1.6 / 3600;
refSpeedKph = 1.6;
end
local trueRpm = self.motor.lastMotorRpm*100/self.cp.orgRpm[3]
local targetRpm = self.motor.maxRpm[sl]*100/self.cp.orgRpm[3]
local newLimit = 0
local oldLimit = 0
if self.ESLimiter ~= nil then
oldLimit = self.ESLimiter.percentage[sl+1]
local trueRpm = vehicle.motor.lastMotorRpm*100/vehicle.cp.orgRpm[3];
local targetRpm = vehicle.motor.maxRpm[sl]*100/vehicle.cp.orgRpm[3];
local newLimit = 0;
local oldLimit = 0 ;
if vehicle.ESLimiter ~= nil then
oldLimit = vehicle.ESLimiter.percentage[sl+1];
else
oldLimit = targetRpm
end
oldLimit = targetRpm;
end;

if refSpeed*3600 - self.lastSpeed*3600 > 15 then
local speedDelta = refSpeedKph - lastSpeedKph; -- accelerate
if speedDelta > 15 then
if sl == 2 then
newLimit = 75
newLimit = 75;
else
newLimit = 100
end
elseif refSpeed*3600 - self.lastSpeed*3600 > 4 then
newLimit = oldLimit + 1
elseif refSpeed*3600 - self.lastSpeed*3600 > 0.5 then
newLimit = oldLimit + 0.1
elseif refSpeed*3600 - self.lastSpeed*3600 > 0 then
newLimit = oldLimit
end
newLimit = 100;
end;
elseif speedDelta > 4 then
newLimit = oldLimit + 1;
elseif speedDelta > 0.5 then
newLimit = oldLimit + 0.1;
elseif speedDelta > 0 then
newLimit = oldLimit;
end;
if oldLimit - trueRpm > 10 then
if refSpeed*3600 - self.lastSpeed*3600 < 1 then
newLimit = trueRpm

end
end
if self.lastSpeed*3600 - refSpeed*3600 > 8 and self.cp.isTurning == nil then
if speedDelta < 1 then
newLimit = trueRpm;
end;
end;

speedDelta = lastSpeedKph - refSpeedKph; --decelerate
if speedDelta > 8 and vehicle.cp.isTurning == nil then
if sl == 1 then
newLimit = 20
else
newLimit = oldLimit - 3
end
elseif self.lastSpeed*3600 - refSpeed*3600 > 3 then
newLimit = oldLimit -1
elseif self.lastSpeed*3600 - refSpeed*3600 > 1 then
newLimit = oldLimit -0.75
elseif self.lastSpeed*3600 - refSpeed*3600 > 0.5 then
newLimit = oldLimit -0.25
elseif self.lastSpeed*3600 - refSpeed*3600 > 0 then
newLimit = oldLimit
end

if newLimit > 100 then
newLimit = 100
elseif newLimit < 0 then
newLimit = 0
end
newLimit = 20;
else
newLimit = oldLimit - 3;
end;
elseif speedDelta > 3 then
newLimit = oldLimit - 1;
elseif speedDelta > 1 then
newLimit = oldLimit - 0.75;
elseif speedDelta > 0.5 then
newLimit = oldLimit - 0.25;
elseif speedDelta > 0 then
newLimit = oldLimit;
end;

if self.ESLimiter ~= nil and self.ESLimiter.maxRPM[5] ~= nil then
self:setNewLimit(sl+1, newLimit , false, true)
elseif self.ESLimiter ~= nil and self.ESLimiter.maxRPM[5] == nil then
newLimit = Utils.clamp(newLimit, 0, 100);

if vehicle.ESLimiter ~= nil and vehicle.ESLimiter.maxRPM[5] ~= nil then
vehicle:setNewLimit(sl + 1, newLimit, false, true);
elseif vehicle.ESLimiter ~= nil and vehicle.ESLimiter.maxRPM[5] == nil then
--ESlimiter < V3
else
local maxRpm = newLimit * self.cp.orgRpm[3]/100

-- don't drive faster/slower than you can!
if maxRpm > self.cp.orgRpm[3] then
maxRpm = self.cp.orgRpm[3]
elseif maxRpm < self.motor.minRpm then
maxRpm = self.motor.minRpm
end
self.motor.maxRpm[sl]= maxRpm
end
vehicle.motor.maxRpm[sl] = Utils.clamp(newLimit * vehicle.cp.orgRpm[3]/100, vehicle.motor.minRpm, vehicle.cp.orgRpm[3]);
end;

self.lastSpeedSave = self.lastSpeedReal*3600
end
vehicle.lastSpeedSave = vehicle.lastSpeedReal*3600;
end;

-- slipping notification
-- print(string.format('%s: lastSpeedSave=%.1f', nameNum(self), self.lastSpeedSave));
if self.lastSpeedSave < 0.5 and not self.cp.inTraffic and not self.Waypoints[self.recordnumber].wait then
if self.cp.timers.slippingWheels == nil or self.cp.timers.slippingWheels == 0 then
courseplay:setCustomTimer(self, 'slippingWheels', 5);
-- print(string.format('\tsetCustomTimer(..., "slippingWheels", 5)'));
elseif courseplay:timerIsThrough(self, 'slippingWheels') then
courseplay:setGlobalInfoText(self, 'SLIPPING_0');
-- print(string.format('\ttimerIsThrough -> SLIPPING'));
if vehicle.lastSpeedSave < 0.5 and not vehicle.cp.inTraffic and not vehicle.Waypoints[vehicle.recordnumber].wait then
if vehicle.cp.timers.slippingWheels == nil or vehicle.cp.timers.slippingWheels == 0 then
courseplay:setCustomTimer(vehicle, 'slippingWheels', 5);
elseif courseplay:timerIsThrough(vehicle, 'slippingWheels') then
courseplay:setGlobalInfoText(vehicle, 'SLIPPING_0');
end;

-- reset timer
elseif self.cp.timers.slippingWheels ~= 0 then
self.cp.timers.slippingWheels = 0;
-- print(string.format('\treset timer'));
elseif vehicle.cp.timers.slippingWheels ~= 0 then
vehicle.cp.timers.slippingWheels = 0;
end;
end;

Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="13">
<version>3.41.0455</version>
<version>3.41.0456</version>
<author><![CDATA[Jakob Tischler, Thomas Gärtner,
Horoman, Satis]]></author>
<title>
Expand Down
2 changes: 1 addition & 1 deletion mode1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function courseplay:handle_mode1(self)
local ctx, cty, ctz = getWorldTranslation(self.rootNode);
local distance_to_trigger = courseplay:distance(ctx, ctz, trigger_x, trigger_z);

-- Star reversion value is to check if we have started to reverse
-- Start reversion value is to check if we have started to reverse
-- This is used in case we already registered a tipTrigger but changed the direction and might not be in that tipTrigger when unloading. (Bug Fix)
local startReversing = self.Waypoints[self.recordnumber].rev and not self.Waypoints[self.cp.last_recordnumber].rev and not self.cp.BGASelectedSection;
if startReversing then
Expand Down
6 changes: 4 additions & 2 deletions mode2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ function courseplay:unload_combine(self, dt)
if combine.cp.isChopper then
local fruitSide = courseplay:sideToDrive(self, combine, -10,true);

--new chopper turn maneuver by Thomas G�rtner
--new chopper turn maneuver by Thomas Gärtner
if fruitSide == "left" then -- chopper will turn left

if self.cp.combineOffset > 0 then -- I'm left of chopper
Expand Down Expand Up @@ -1324,7 +1324,9 @@ function courseplay:calculateCombineOffset(self, combine)
end;

--special tools, special cases
if self.cp.combineOffsetAutoMode and combine.cp.isJohnDeereS650 then
if self.cp.combineOffsetAutoMode and combine.cp.isJohnDeereS690i then
offs = 9.5;
elseif self.cp.combineOffsetAutoMode and combine.cp.isJohnDeereS650 then
offs = 7.7;
elseif self.cp.combineOffsetAutoMode and combine.cp.isCaseIH7130 then
offs = 8.0;
Expand Down
12 changes: 10 additions & 2 deletions specialTools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ function courseplay:setNameVariable(workTool)
--------------------------------------------------------------


--John Deere S690i [Big Boss Modding]
if Utils.endsWith(workTool.configFileName, 'JohnDeereS690i.xml') or Utils.endsWith(workTool.configFileName, 'JohnDeereS690i_TT.xml') then
workTool.cp.isJohnDeereS690i = true;

--John Deere S650 [Big Boss Modding]
if Utils.endsWith(workTool.configFileName, 'JohnDeereS650NW.xml') then
elseif Utils.endsWith(workTool.configFileName, 'JohnDeereS650NW.xml') then
workTool.cp.isJohnDeereS650 = true;

-- Claas Quantum 3800K [Vertex Design]
Expand Down Expand Up @@ -1171,7 +1175,11 @@ end
function courseplay:askForSpecialSettings(self,object)
local automaticToolOffsetX;

if self.cp.isWeidemann4270CX100T then
if self.cp.isJohnDeereS690i and not self.isRealistic then
if self.motor.maxTorques[1] > 0 then
self.motor.maxTorques[1] = -self.motor.maxTorques[1];
end;
elseif self.cp.isWeidemann4270CX100T then
local frontPart_vis = getParent(self.movingTools[1].node)
local frontPart = getParent(frontPart_vis)
self.aiTrafficCollisionTrigger = getChild(frontPart, "trafficCollisionTrigger");
Expand Down
33 changes: 31 additions & 2 deletions turn.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
function courseplay:turn(self, dt) --!!!
--[[ TURN STAGES:
0: raise implements
1: start forward turn
2:
3: reversing
4:
5:
6:
]]

local newTargetX, newTargetY, newTargetZ;
local moveForwards = true;
local updateWheels = true;
Expand All @@ -10,7 +20,12 @@ function courseplay:turn(self, dt) --!!!
turnOutTimer = 0
end
self.cp.turnTimer = self.cp.turnTimer - dt;


-- TURN STAGES 1 - 6
if self.cp.turnTimer < 0 or self.cp.turnStage > 0 then

-- TURN STAGES 2 - 6
if self.cp.turnStage > 1 then
local x,y,z = getWorldTranslation(self.rootNode);
local dirX, dirZ = self.aiTractorDirectionX, self.aiTractorDirectionZ;
Expand All @@ -19,6 +34,8 @@ function courseplay:turn(self, dt) --!!!
newTargetX = self.aiTractorTargetX;
newTargetY = y;
newTargetZ = self.aiTractorTargetZ;

-- TURN STAGE 2
if self.cp.turnStage == 2 then
self.turnStageTimer = self.turnStageTimer - dt;
if self.cp.isTurning == "left" then
Expand Down Expand Up @@ -46,13 +63,17 @@ function courseplay:turn(self, dt) --!!!
self.turnStageTimer = Utils.getNoNil(self.turnStage3Timeout,20000)
end;
end;

-- TURN STAGE 3
elseif self.cp.turnStage == 3 then
self.turnStageTimer = self.turnStageTimer - dt;
if myDirX*dirX + myDirZ*dirZ > 0.95 or self.turnStageTimer < 0 then
self.cp.turnStage = 4;
else
moveForwards = false;
end;

-- TURN STAGE 4
elseif self.cp.turnStage == 4 then
local dx, dz = x-newTargetX, z-newTargetZ;
local dot = dx*dirX + dz*dirZ;
Expand All @@ -71,6 +92,8 @@ function courseplay:turn(self, dt) --!!!
end
self.cp.turnStage = 5;
end;

-- TURN STAGE 5
elseif self.cp.turnStage == 5 then
local backX, backY, backZ = localToWorld(self.rootNode,0,0,frontMarker);
local dx, dz = backX-newTargetX, backZ-newTargetZ;
Expand Down Expand Up @@ -109,6 +132,7 @@ function courseplay:turn(self, dt) --!!!
self.cp.waitForTurnTime = self.time + turnOutTimer;
end;

-- TURN STAGE 6
elseif self.cp.turnStage == 6 then
self.turnStageTimer = self.turnStageTimer - dt;
if self.turnStageTimer < 0 then
Expand Down Expand Up @@ -136,6 +160,8 @@ function courseplay:turn(self, dt) --!!!
if courseplay.debugChannels[12] then
drawDebugPoint(newTargetX, y+3, newTargetZ, 1, 1, 0, 1);
end;

-- TURN STAGE 1
elseif self.cp.turnStage == 1 then
-- turn
local dirX, dirZ = self.aiTractorDirectionX, self.aiTractorDirectionZ;
Expand All @@ -159,6 +185,8 @@ function courseplay:turn(self, dt) --!!!
self.aiTractorDirectionZ = -dirZ;
self.cp.turnStage = 2;
self.turnStageTimer = Utils.getNoNil(self.turnStage2Timeout,20000)

-- TURN STAGE ??? --TODO (Jakob): what's the situation here? turnStage not > 1 and not > 0 ? When do we get to this point?
else
self.cp.turnStage = 1;
if self.cp.noStopOnTurn == false then
Expand All @@ -167,6 +195,8 @@ function courseplay:turn(self, dt) --!!!
courseplay:lowerImplements(self, false, true)
updateWheels = false;
end;

-- TURN STAGE 0
else
local offset = Utils.getNoNil(self.cp.totalOffsetX, 0)
local x,y,z = localToWorld(self.rootNode, offset, 0, backMarker)
Expand Down Expand Up @@ -254,7 +284,6 @@ function courseplay:turn(self, dt) --!!!
self.aiTractorTargetX = newTargetX;
self.aiTractorTargetZ = newTargetZ;
end;

end

function courseplay:lowerImplements(self, direction, workToolonOff)
Expand Down Expand Up @@ -304,7 +333,7 @@ function courseplay:turnWithOffset(self)
local curPoint = self.Waypoints[self.recordnumber+1]
local cx, cz = curPoint.cx, curPoint.cz;
local offsetX = self.cp.totalOffsetX
if curPoint.turnEnd and curPoint.laneDir ~= nil then
if curPoint.turnEnd and curPoint.laneDir ~= nil then --TODO (Jakob): use point's direction to next point to get the proper offset
local dir = curPoint.laneDir;
local turnDir = curPoint.turn;

Expand Down

0 comments on commit 579d019

Please sign in to comment.