@@ -11,27 +11,27 @@ import (
1111 "time"
1212)
1313
14- type RobotCountMaintainer struct {
14+ type RobotCountHandler struct {
1515 c * SimulationController
1616
1717 lastTimeSendCommand time.Time
1818 robotCountMismatchSince map [referee.Team ]time.Time
1919}
2020
21- func NewRobotCountMaintainer (c * SimulationController ) (r * RobotCountMaintainer ) {
22- r = new (RobotCountMaintainer )
21+ func NewRobotCountHandler (c * SimulationController ) (r * RobotCountHandler ) {
22+ r = new (RobotCountHandler )
2323 r .c = c
2424 return r
2525}
2626
27- func (r * RobotCountMaintainer ) Reset () {
27+ func (r * RobotCountHandler ) Reset () {
2828 r .lastTimeSendCommand = time .Now ()
2929 r .robotCountMismatchSince = map [referee.Team ]time.Time {}
3030 r .robotCountMismatchSince [referee .Team_BLUE ] = time.Time {}
3131 r .robotCountMismatchSince [referee .Team_YELLOW ] = time.Time {}
3232}
3333
34- func (r * RobotCountMaintainer ) handleRobotCount () {
34+ func (r * RobotCountHandler ) handleRobotCount () {
3535
3636 if time .Now ().Sub (r .lastTimeSendCommand ) < 500 * time .Millisecond {
3737 // Placed ball just recently
@@ -59,7 +59,7 @@ func (r *RobotCountMaintainer) handleRobotCount() {
5959 r .updateRobotCount (yellowRobots , int (* r .c .lastRefereeMsg .Yellow .MaxAllowedBots ), referee .Team_YELLOW )
6060}
6161
62- func (r * RobotCountMaintainer ) updateRobotCount (robots []* tracker.TrackedRobot , maxRobots int , team referee.Team ) {
62+ func (r * RobotCountHandler ) updateRobotCount (robots []* tracker.TrackedRobot , maxRobots int , team referee.Team ) {
6363 substCenterPos := geom .NewVector2 (0 , float64 (* r .c .fieldSize .FieldWidth )/ 2000 + float64 (* r .c .fieldSize .BoundaryWidth )/ 2000.0 - 0.1 )
6464 substCenterNeg := geom .NewVector2Float32 (0 , - * substCenterPos .Y )
6565 substRectPos := geom .NewRectangleFromCenter (substCenterPos , 2 , float64 (* r .c .fieldSize .BoundaryWidth )/ 1000 + 0.2 )
@@ -106,7 +106,7 @@ func (r *RobotCountMaintainer) updateRobotCount(robots []*tracker.TrackedRobot,
106106 }
107107}
108108
109- func (r * RobotCountMaintainer ) nextFreeRobotId (team referee.Team ) * referee.RobotId {
109+ func (r * RobotCountHandler ) nextFreeRobotId (team referee.Team ) * referee.RobotId {
110110 for i := 0 ; i < 16 ; i ++ {
111111 id := uint32 (i )
112112 robotId := & referee.RobotId {
@@ -120,7 +120,7 @@ func (r *RobotCountMaintainer) nextFreeRobotId(team referee.Team) *referee.Robot
120120 return nil
121121}
122122
123- func (r * RobotCountMaintainer ) isRobotIdFree (id * referee.RobotId ) bool {
123+ func (r * RobotCountHandler ) isRobotIdFree (id * referee.RobotId ) bool {
124124
125125 for _ , robot := range r .c .lastTrackedFrame .TrackedFrame .Robots {
126126 if * robot .RobotId .Id == * id .Id && * robot .RobotId .Team == * id .Team {
@@ -130,7 +130,7 @@ func (r *RobotCountMaintainer) isRobotIdFree(id *referee.RobotId) bool {
130130 return true
131131}
132132
133- func (r * RobotCountMaintainer ) isFreeOfObstacles (pos * geom.Vector2 ) bool {
133+ func (r * RobotCountHandler ) isFreeOfObstacles (pos * geom.Vector2 ) bool {
134134 for _ , robot := range r .c .lastTrackedFrame .TrackedFrame .Robots {
135135 if robot .Pos .DistanceTo (pos ) < 0.2 {
136136 return false
@@ -145,7 +145,7 @@ func (r *RobotCountMaintainer) isFreeOfObstacles(pos *geom.Vector2) bool {
145145 return true
146146}
147147
148- func (r * RobotCountMaintainer ) sortRobotsByDistanceToSubstitutionPos (robots []* tracker.TrackedRobot ) {
148+ func (r * RobotCountHandler ) sortRobotsByDistanceToSubstitutionPos (robots []* tracker.TrackedRobot ) {
149149 negSubstPos := geom .NewVector2 (0 , - float64 (* r .c .fieldSize .FieldWidth )/ 2000 )
150150 posSubstPos := geom .NewVector2 (0 , + float64 (* r .c .fieldSize .FieldWidth )/ 2000 )
151151 sort .Slice (robots , func (i , j int ) bool {
@@ -155,7 +155,7 @@ func (r *RobotCountMaintainer) sortRobotsByDistanceToSubstitutionPos(robots []*t
155155 })
156156}
157157
158- func (r * RobotCountMaintainer ) removeRobot (id * referee.RobotId ) {
158+ func (r * RobotCountHandler ) removeRobot (id * referee.RobotId ) {
159159 log .Printf ("Remove robot %v" , id )
160160
161161 present := false
@@ -173,7 +173,7 @@ func (r *RobotCountMaintainer) removeRobot(id *referee.RobotId) {
173173 r .sendControlCommand (& command )
174174}
175175
176- func (r * RobotCountMaintainer ) addRobot (id * referee.RobotId , pos * geom.Vector2 ) {
176+ func (r * RobotCountHandler ) addRobot (id * referee.RobotId , pos * geom.Vector2 ) {
177177 log .Printf ("Add robot %v @ %v" , id , pos )
178178
179179 present := true
@@ -195,7 +195,7 @@ func (r *RobotCountMaintainer) addRobot(id *referee.RobotId, pos *geom.Vector2)
195195 r .sendControlCommand (& command )
196196}
197197
198- func (r * RobotCountMaintainer ) sendControlCommand (command * SimulatorCommand ) {
198+ func (r * RobotCountHandler ) sendControlCommand (command * SimulatorCommand ) {
199199
200200 if data , err := proto .Marshal (command ); err != nil {
201201 log .Println ("Could not marshal command: " , err )
0 commit comments