@@ -26,6 +26,7 @@ local Referee = require "base/referee"
26
26
local debug = require " base/debug"
27
27
local vis = require " base/vis"
28
28
local World = require " base/world"
29
+ local BallObserver = require " ballobserver"
29
30
local Event = require " gameevents"
30
31
31
32
local OUT_OF_FIELD_MIN_TIME = 0.25
@@ -54,7 +55,7 @@ local function isBallInField(ballPos)
54
55
end
55
56
56
57
function OutOfField :occuring ()
57
- local ballPos = World . Ball . pos
58
+ local ballPos = BallObserver . getRealisticBallPos ()
58
59
local previousPos = self .lastTouchPosition
59
60
60
61
local lastTeam = Referee .teamWhichTouchedBallLast ()
@@ -78,17 +79,17 @@ function OutOfField:occuring()
78
79
else
79
80
self .maxHeightAfterBlueTouch = 0
80
81
end
81
- elseif isBallInField () then
82
+ elseif isBallInField (ballPos ) then
82
83
self .maxHeightAfterYellowTouch = math.max (self .maxHeightAfterYellowTouch , World .Ball .posZ )
83
84
self .maxHeightAfterBlueTouch = math.max (self .maxHeightAfterBlueTouch , World .Ball .posZ )
84
85
end
85
86
86
- if isBallInField () then
87
+ if isBallInField (ballPos ) then
87
88
self .wasInFieldBefore = true
88
89
elseif self .wasInFieldBefore then
89
90
self .outOfFieldTime = World .Time
90
91
self .wasInFieldBefore = false
91
- self .outOfFieldPos = World . Ball . pos :copy ()
92
+ self .outOfFieldPos = ballPos :copy ()
92
93
self .waitingForDecision = true
93
94
end
94
95
end
@@ -100,7 +101,7 @@ function OutOfField:occuring()
100
101
end
101
102
end
102
103
end
103
- if isBallInField () and not self .waitingForDecision then
104
+ if isBallInField (ballPos ) and not self .waitingForDecision then
104
105
self .rawOutOfFieldCounter = 0
105
106
end
106
107
@@ -120,7 +121,7 @@ function OutOfField:occuring()
120
121
return
121
122
end
122
123
123
- vis .addCircle (" ball out of play" , World . Ball . pos , 0.02 , vis .colors .blue , true )
124
+ vis .addCircle (" ball out of play" , ballPos , 0.02 , vis .colors .blue , true )
124
125
local event
125
126
if math.abs (self .outOfFieldPos .y ) > World .Geometry .FieldHeightHalf then -- out of goal line
126
127
event = Event .ballLeftField (lastRobot .isYellow , lastRobot .id , self .outOfFieldPos , true )
@@ -140,7 +141,7 @@ function OutOfField:occuring()
140
141
and math.abs (ballPos .y ) > World .Geometry .FieldHeightHalf
141
142
and math.abs (ballPos .y ) < World .Geometry .FieldHeightHalf + 0.2
142
143
143
- local closeToGoal = World . Ball . pos :distanceToLineSegment (World .Geometry [side .. " GoalLeft" ], World .Geometry [side .. " GoalRight" ]) < CLOSE_TO_GOAL_THRESHOLD
144
+ local closeToGoal = ballPos :distanceToLineSegment (World .Geometry [side .. " GoalLeft" ], World .Geometry [side .. " GoalRight" ]) < CLOSE_TO_GOAL_THRESHOLD
144
145
145
146
if closeToGoal or insideGoal
146
147
or math.abs (ballPos .y ) > World .Geometry .FieldHeightHalf + 0.2 then -- math.abs(World.Ball.pos.x) < World.Geometry.GoalWidth/2
0 commit comments