Skip to content

Commit

Permalink
Drop delay for silage bales on baler-wrapper-combo after turns (Cours…
Browse files Browse the repository at this point in the history
…eplay#3632)

* Added drop delay on baler-wrapper-combos

Baler-wrapper-combo alsways drops bales on headlands after turn. Added delay to fix this issue.

* Increased code efficiency

Calculation only takes place if wrapper needs to be unloaded. Reduces calculation amount significantly.
  • Loading branch information
ishtarcl authored and pvaiko committed Apr 18, 2019
1 parent 2500eb2 commit ee5a154
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion BaleWrapperAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ end
function BaleWrapperAIDriver:driveFieldwork()
-- Don't drop the bale in the turn
if not self.turnIsDriving then

-- stop while wrapping only if we deon't have a baler. If we do we should continue driving and working
-- on the next bale, the baler code will take care about stopping if we need to
if self.baleWrapper.spec_baleWrapper.baleWrapperState ~= BaleWrapper.STATE_NONE and not self.baler then
self:setSpeed(0)
end
-- Yes, Giants has a typo in the state
if self.baleWrapper.spec_baleWrapper.baleWrapperState == BaleWrapper.STATE_WRAPPER_FINSIHED then
self.baleWrapper:doStateChange(BaleWrapper.CHANGE_WRAPPER_START_DROP_BALE)
-- inserts unload threshold after turn so bales don't drop on headlands
if self.turnStartedAt and self.realTurnDurationMs then
local unloadThreshold = 4000 --delay in msecs, 4 secs seems to work well
dropTime = self.turnStartedAt + self.realTurnDurationMs + unloadThreshold
else
dropTime = 0 --avoids problems in case of condition variables not existing / empty e.g. before the first turn
end
if self.vehicle.timer > dropTime then
self.baleWrapper:doStateChange(BaleWrapper.CHANGE_WRAPPER_START_DROP_BALE)
end

end
end
BalerAIDriver.driveFieldwork(self)
Expand Down
1 change: 1 addition & 0 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ function FieldworkAIDriver:measureTurnTime()
if self.turnStartedAt then
-- use sliding average to smooth jumps
self.turnDurationMs = (self.turnDurationMs + self.vehicle.timer - self.turnStartedAt) / 2
self.realTurnDurationMs = self.vehicle.timer - self.turnStartedAt
self:debug('Measured turn duration is %.0f ms', self.turnDurationMs)
end
elseif not self.turnWasDriving and self.turnIsDriving then
Expand Down

0 comments on commit ee5a154

Please sign in to comment.