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

Commit

Permalink
6.01.00164.1 Fine tuning
Browse files Browse the repository at this point in the history
Don't stop for swath in headland turns
Wait for engine to start before start moving
Lowering duration measurement start fixed
  • Loading branch information
pvaiko committed Apr 6, 2019
1 parent 8443c3c commit d4b0d41
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
22 changes: 16 additions & 6 deletions AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ function AIDriver:driveCourse(dt)
self:hold()
end

if not self:getIsEngineReady() then
if self:getSpeed() > 0 and self.allowedToDrive then
self:startEngineIfNeeded()
self:hold()
self:debugSparse('Wait for the engine to start')
end
end

-- use the recorded speed by default
if not self:hasTipTrigger() then
self:setSpeed(self:getRecordedSpeed())
Expand All @@ -311,10 +319,6 @@ function AIDriver:driveCourse(dt)

self:stopEngineIfNotNeeded()

if self:getSpeed() > 0 and self.allowedToDrive then
self:startEngineIfNeeded()
end

if isReverseActive then
-- we go wherever goReverse() told us to go
self:driveVehicleInDirection(dt, self.allowedToDrive, moveForwards, lx, lz, self:getSpeed())
Expand Down Expand Up @@ -1149,14 +1153,20 @@ function AIDriver:getClosestPointOnFieldBoundary(x, z, fieldNum)
end

function AIDriver:startEngineIfNeeded()
if self.vehicle.spec_motorized and not self.vehicle.spec_motorized.isMotorStarted then
if self.vehicle.spec_motorized and not self.vehicle.spec_motorized:getIsMotorStarted() then
self.vehicle:startMotor()
end
-- reset motor auto stop timer when someone starts the engine so we won't stop it for while just because
-- reset motor auto stop timer when someone starts the engine so we won't stop it for a while just because
-- our speed is 0 (for example while waiting for the implements to lower)
self.lastMovingTime = self.vehicle.timer
end

function AIDriver:getIsEngineReady()
local spec = self.vehicle.spec_motorized
return spec and (spec:getIsMotorStarted() and spec:getMotorStartTime() < g_currentMission.time)
end;


--- Is auto stop engine enabled?
function AIDriver:isEngineAutoStopEnabled()
return self.vehicle.cp.saveFuelOptionActive
Expand Down
13 changes: 5 additions & 8 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ function FieldworkAIDriver:driveFieldwork()
self:calculateLoweringDuration()
else
self:debugSparse('waiting for all tools to lower')
self:startLoweringDurationTimer()
self:setSpeed(0)
self:checkFillLevels()
end
Expand Down Expand Up @@ -694,13 +693,10 @@ function FieldworkAIDriver:updateLightsOnField()
end

function FieldworkAIDriver:startLoweringDurationTimer()
-- if not started yet
if not self.startedLoweringAt then
-- then start but only after everything is unfolded as we don't want to include the
-- unfold duration (since we don't fold at the end of the row).
if self:isAllUnfolded() then
self.startedLoweringAt = self.vehicle.timer
end
-- then start but only after everything is unfolded as we don't want to include the
-- unfold duration (since we don't fold at the end of the row).
if self:isAllUnfolded() then
self.startedLoweringAt = self.vehicle.timer
end
end

Expand Down Expand Up @@ -786,6 +782,7 @@ function FieldworkAIDriver:lowerImplements()
implement.object:aiImplementStartLine()
end
self.vehicle:raiseStateChange(Vehicle.STATE_CHANGE_AI_START_LINE)
self:startLoweringDurationTimer()
end

function FieldworkAIDriver:raiseImplements()
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="40">
<version>6.01.00163</version>
<version>6.01.00164.1</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
4 changes: 3 additions & 1 deletion turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,9 @@ function courseplay:turn(vehicle, dt)
directionForce = -vehicle.cp.mrAccelrator -- The progressive breaking function returns a postive number which accelerates the tractor
end
end
allowedToDrive = vehicle.cp.driver and not vehicle.cp.driver:holdInTurnManeuver(vehicle.cp.turnStage == 0) and allowedToDrive
-- hold while straw swatch is active (not during headland turn maneuvers though)
local holdInTurn = not vehicle.cp.headlandTurn and vehicle.cp.driver and vehicle.cp.driver:holdInTurnManeuver(vehicle.cp.turnStage == 0)
allowedToDrive = not holdInTurn and allowedToDrive

--courseplay.debugVehicle(14, vehicle, 'turn speed = %.1f, allowedToDrive %s', refSpeed, allowedToDrive)
--vehicle,dt,steeringAngleLimit,acceleration,slowAcceleration,slowAngleLimit,allowedToDrive,moveForwards,lx,lz,maxSpeed,slowDownFactor,angle
Expand Down

0 comments on commit d4b0d41

Please sign in to comment.