Skip to content

Commit

Permalink
WIP code dump for "cherry" picking ...
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Oct 9, 2023
1 parent 12623d2 commit c20db6a
Show file tree
Hide file tree
Showing 57 changed files with 3,792 additions and 1,157 deletions.
13 changes: 11 additions & 2 deletions modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ Changelog 7.1.0.0:

<sourceFile filename="scripts/ai/AIUtil.lua"/>
<sourceFile filename="scripts/ai/ImplementUtil.lua"/>
<sourceFile filename="scripts/ai/PathfinderController.lua"/>
<sourceFile filename="scripts/ai/ProximityController.lua"/>
<sourceFile filename="scripts/ai/FieldWorkerProximityController.lua"/>
<sourceFile filename="scripts/ai/CollisionAvoidanceController.lua"/>
Expand Down Expand Up @@ -325,6 +326,7 @@ Changelog 7.1.0.0:
<sourceFile filename="scripts/ai/controllers/BunkerSiloCompacterController.lua"/>
<sourceFile filename="scripts/ai/controllers/ConveyorController.lua"/>
<sourceFile filename="scripts/ai/controllers/ShovelController.lua"/>
<sourceFile filename="scripts/ai/controllers/SugarCaneTrailerController.lua"/>
<sourceFile filename="scripts/ai/controllers/AttachableController.lua"/>
<sourceFile filename="scripts/ai/controllers/AttacherJointController.lua"/>
<sourceFile filename="scripts/ai/controllers/DynamicMountAttacherController.lua"/>
Expand All @@ -344,7 +346,10 @@ Changelog 7.1.0.0:
<sourceFile filename="scripts/ai/AIDriveStrategyBunkerSilo.lua"/>
<sourceFile filename="scripts/ai/AIDriveStrategySiloLoader.lua"/>
<sourceFile filename="scripts/ai/AIDriveStrategyShovelSiloLoader.lua"/>

<sourceFile filename="scripts/ai/strategies/AIDriveStrategySelfUnload.lua"/>
<sourceFile filename="scripts/ai/strategies/AIDriveStrategyUnloadOnField.lua"/>
<sourceFile filename="scripts/ai/strategies/AIDriveStrategyWaitingForHarvesterOrLoader.lua"/>

<sourceFile filename="scripts/ai/parameters/AIParameterSettingInterface.lua"/>
<sourceFile filename="scripts/ai/parameters/AIParameterSetting.lua"/>
<sourceFile filename="scripts/ai/parameters/AIParameterSettingList.lua"/>
Expand All @@ -359,14 +364,18 @@ Changelog 7.1.0.0:
<sourceFile filename="scripts/ai/jobs/CpAIJobCombineUnloader.lua"/>
<sourceFile filename="scripts/ai/jobs/CpAIJobBunkerSilo.lua"/>
<sourceFile filename="scripts/ai/jobs/CpAIJobSiloLoader.lua"/>


<sourceFile filename="scripts/ai/tasks/CpAITask.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskFieldWork.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskBaleFinder.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskCombineUnloader.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskDriveTo.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskAttachHeader.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskBunkerSilo.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskSiloLoader.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskSelfUnload.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskUnloadOnField.lua"/>
<sourceFile filename="scripts/ai/tasks/CpAITaskWaitingForHarvesterOrLoader.lua"/>

<sourceFile filename="scripts/gui/CpGuiUtil.lua"/>
<sourceFile filename="scripts/gui/CoursePlot.lua"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/CpUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function CpUtil.getVariable(variableName)
end

--- (Safely) get the name of a vehicle or implement.
---@param object table vehicle or implement
---@param object table|nil vehicle or implement
function CpUtil.getName(object)
if object == nil then
return 'Unknown'
Expand Down
17 changes: 6 additions & 11 deletions scripts/ai/AIDriveStrategyAttachHeader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ which needs to be attached to the harvester.
]]--

---@class AIDriveStrategyAttachHeader : AIDriveStrategyCourse
AIDriveStrategyAttachHeader = {}
local AIDriveStrategyAttachHeader_mt = Class(AIDriveStrategyAttachHeader, AIDriveStrategyCourse)
AIDriveStrategyAttachHeader = CpObject(AIDriveStrategyCourse)

AIDriveStrategyAttachHeader.myStates = {
WAITING_FOR_DETACH_TO_FINISH = {},
Expand All @@ -47,16 +46,12 @@ AIDriveStrategyAttachHeader.MODES = {
AIDriveStrategyAttachHeader.DRIVING_AWAY_FROM_HEADER_FORWARD_DISTANCE = 6


function AIDriveStrategyAttachHeader.new(customMt)
if customMt == nil then
customMt = AIDriveStrategyAttachHeader_mt
end
local self = AIDriveStrategyCourse.new(customMt)
function AIDriveStrategyAttachHeader:init(...)
AIDriveStrategyCourse.init(self, ...)
AIDriveStrategyCourse.initStates(self, AIDriveStrategyAttachHeader.myStates)
self.state = self.states.INITIAL
self.debugChannel = CpDebug.DBG_FIELDWORK
self.mode = self.MODES.ATTACH_HEADER_FROM_ATTACHED_TRAILER
return self
end

--- The fieldwork course is not needed for this strategy.
Expand All @@ -68,7 +63,7 @@ function AIDriveStrategyAttachHeader:delete()
if self.cutterNode then
CpUtil.destroyNode(self.cutterNode)
end
AIDriveStrategyAttachHeader:superClass().delete(self)
AIDriveStrategyCourse.delete(self)
end

function AIDriveStrategyAttachHeader:initializeImplementControllers(vehicle)
Expand All @@ -93,7 +88,7 @@ function AIDriveStrategyAttachHeader:initializeImplementControllers(vehicle)
end

function AIDriveStrategyAttachHeader:setAllStaticParameters()
AIDriveStrategyAttachHeader:superClass().setAllStaticParameters(self)
AIDriveStrategyCourse.setAllStaticParameters(self)
-- make sure we have a good turning radius set
self.turningRadius = AIUtil.getTurningRadius(self.vehicle)
self.proximityController:registerIgnoreObjectCallback(self, self.ignoreProximityObject)
Expand All @@ -106,7 +101,7 @@ end

function AIDriveStrategyAttachHeader:update(dt)
-- to always have a valid course (for the traffic conflict detector mainly)
AIDriveStrategyAttachHeader:superClass().update(self, dt)
AIDriveStrategyCourse.update(self, dt)
self:updateImplementControllers(dt)
if CpDebug:isChannelActive(CpDebug.DBG_PATHFINDER, self.vehicle) then
if self.pathfinder then
Expand Down
21 changes: 7 additions & 14 deletions scripts/ai/AIDriveStrategyBunkerSilo.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
This file is part of Courseplay (https://github.com/Courseplay/courseplay)
This file is part of Courseplay (https://github.com/Courseplay/Courseplay_FS22)
Copyright (C) 2022 Peter Vaiko
This program is free software: you can redistribute it and/or modify
Expand All @@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

--- Drive strategy for bunker silos.
---@class AIDriveStrategyBunkerSilo : AIDriveStrategyCourse
AIDriveStrategyBunkerSilo = {}
local AIDriveStrategyBunkerSilo_mt = Class(AIDriveStrategyBunkerSilo, AIDriveStrategyCourse)
AIDriveStrategyBunkerSilo = CpObject(AIDriveStrategyCourse)

AIDriveStrategyBunkerSilo.myStates = {
DRIVING_TO_SILO = {},
Expand All @@ -38,12 +37,8 @@ AIDriveStrategyBunkerSilo.isStuckBackOffset = 12
AIDriveStrategyBunkerSilo.maxDriveIntoTheSiloAttempts = 2
AIDriveStrategyBunkerSilo.endReachedOffset = 3

function AIDriveStrategyBunkerSilo.new(customMt)
if customMt == nil then
customMt = AIDriveStrategyBunkerSilo_mt
end
---@type AIDriveStrategyBunkerSilo
local self = AIDriveStrategyCourse.new(customMt)
function AIDriveStrategyBunkerSilo:init(...)
AIDriveStrategyCourse.init(self, ...)
AIDriveStrategyCourse.initStates(self, AIDriveStrategyBunkerSilo.myStates)
self.state = self.states.DRIVING_TO_SILO

Expand All @@ -60,8 +55,6 @@ function AIDriveStrategyBunkerSilo.new(customMt)

self.isStuckTimer = Timer.new(self.isStuckMs)
self.driveIntoSiloAttempts = 0

return self
end

function AIDriveStrategyBunkerSilo:delete()
Expand All @@ -79,7 +72,7 @@ function AIDriveStrategyBunkerSilo:delete()
self.turnNode = nil
end

AIDriveStrategyBunkerSilo:superClass().delete(self)
AIDriveStrategyCourse.delete(self)
end

function AIDriveStrategyBunkerSilo:startWithoutCourse(jobParameters)
Expand Down Expand Up @@ -285,12 +278,12 @@ function AIDriveStrategyBunkerSilo:isTemporaryOutOfSiloDrivingAllowed()
end

function AIDriveStrategyBunkerSilo:checkProximitySensors(moveForwards)
AIDriveStrategyBunkerSilo:superClass().checkProximitySensors(self, moveForwards)
AIDriveStrategyCourse.checkProximitySensors(self, moveForwards)

end

function AIDriveStrategyBunkerSilo:update(dt)
AIDriveStrategyBunkerSilo:superClass().update(self, dt)
AIDriveStrategyCourse.update(self, dt)
self:updateImplementControllers(dt)

if CpDebug:isChannelActive(self.debugChannel, self.vehicle) then
Expand Down
Loading

0 comments on commit c20db6a

Please sign in to comment.