diff --git a/controllerfeedback.go b/controllerfeedback.go index 73fcfac..55b9b31 100644 --- a/controllerfeedback.go +++ b/controllerfeedback.go @@ -56,4 +56,6 @@ func controllerFeedback(chctrlfb chan bool) { mutex.Unlock() } + + chctrlfb <- true } diff --git a/createprotos.go b/createprotos.go index 9575859..a9fccfe 100644 --- a/createprotos.go +++ b/createprotos.go @@ -54,18 +54,6 @@ func createRobotInfo(i int, ourteam int, simmode bool) *pb_gen.Robot_Infos { return pe } -func addRobotIpToRobotIps(robotip [16]*pb_gen.RobotIP_Infos) []*pb_gen.RobotIP_Infos { - RobotIps := []*pb_gen.RobotIP_Infos{} - - for _, robot := range robotip { - if robot != nil { - RobotIps = append(RobotIps, robot) - } - } - - return RobotIps -} - func addRobotInfoToRobotInfos(robotinfo [16]*pb_gen.Robot_Infos) []*pb_gen.Robot_Infos { RobotInfos := []*pb_gen.Robot_Infos{} @@ -226,7 +214,7 @@ func createOtherInfo(goalpos_n int32) *pb_gen.Other_Infos { return pe } -func createRefInfo(ourteam int, attackdirection int) *pb_gen.Referee_Info { +func createRefInfo(ourteam int, attackdirection int, ignore_ref_mismatch bool) *pb_gen.Referee_Info { var yellowcards uint32 var redcards uint32 var command *pb_gen.Referee_Info_Command @@ -257,24 +245,26 @@ func createRefInfo(ourteam int, attackdirection int) *pb_gen.Referee_Info { teaminfo_their = (*pb_gen.Referee_Info_TeamInfo)(ref_command.Blue) } - // Check if the team color is correct - if ourteam == 0 && ref_command.GetYellow().GetName() == "Ri-one" { - log.Println("[MW WARNING!!] INCORRECT TEAM COLOR! Referee says (Ri-one == YELLOW)") - } else if ourteam == 1 && ref_command.GetBlue().GetName() == "Ri-one" { - log.Println("[MW WARNING!!] INCORRECT TEAM COLOR! Referee says (Ri-one == Blue)") - } - - // Check if the attack direction is correct - if ourteam == 0 && *ref_command.BlueTeamOnPositiveHalf && attackdirection == 1 { - log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == true)") - } else if ourteam == 1 && !*ref_command.BlueTeamOnPositiveHalf && attackdirection == 1 { - log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == false)") - } - - if ourteam == 0 && !*ref_command.BlueTeamOnPositiveHalf && attackdirection == -1 { - log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == true)") - } else if ourteam == 1 && *ref_command.BlueTeamOnPositiveHalf && attackdirection == -1 { - log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == false)") + if !ignore_ref_mismatch { + // Check if the team color is correct + if ourteam == 0 && ref_command.GetYellow().GetName() == "Ri-one" { + log.Println("[MW WARNING!!] INCORRECT TEAM COLOR! Referee says (Ri-one == YELLOW)") + } else if ourteam == 1 && ref_command.GetBlue().GetName() == "Ri-one" { + log.Println("[MW WARNING!!] INCORRECT TEAM COLOR! Referee says (Ri-one == Blue)") + } + + // Check if the attack direction is correct + if ourteam == 0 && *ref_command.BlueTeamOnPositiveHalf && attackdirection == 1 { + log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == true)") + } else if ourteam == 1 && !*ref_command.BlueTeamOnPositiveHalf && attackdirection == 1 { + log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == false)") + } + + if ourteam == 0 && !*ref_command.BlueTeamOnPositiveHalf && attackdirection == -1 { + log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == true)") + } else if ourteam == 1 && *ref_command.BlueTeamOnPositiveHalf && attackdirection == -1 { + log.Println("[MW WARNING!!] INCORRECT ATTACK DIRECTION! Referee says (BlueTeamOnPositiveHalf == false)") + } } } else { diff --git a/main.go b/main.go index ee89225..84894f3 100644 --- a/main.go +++ b/main.go @@ -110,7 +110,7 @@ func CheckVisionRobot(chvisrobot chan bool) { } } -func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, debug bool, simmode bool) { +func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, debug bool, simmode bool, ignore_ref_mismatch bool) { ipv4 := NW_AI_IPADDR port := NW_AI_PORT port_controller := NW_AI_PORT_CONTROLLER @@ -171,7 +171,7 @@ func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, d RobotIpInfo := addRobotIPInfoToRobotIPInfos(robotip_infos) GeometryInfo := createGeometryInfo() - RefereeInfo := createRefInfo(ourteam, goalpose) + RefereeInfo := createRefInfo(ourteam, goalpose, ignore_ref_mismatch) OtherInfo := createOtherInfo(int32(goalpose)) //log.Println(OtherInfo.GetAttackDirection()) @@ -206,18 +206,19 @@ func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, d func main() { var ( - visionport = flag.Int("p", 10006, "Vision Multicast Port Number") - ourteam = flag.String("t", "blue", "Our Team (blue or yellow)") - goalpos = flag.String("g", "N", "Attack Direction(Enemy goal) Negative or Positive (N or P)") - reportrate = flag.Uint("r", 16, "How often report to RACOON-AI? (milliseconds)") - debug = flag.Bool("d", false, "Show All Send Packet") - simmode = flag.Bool("s", false, "Simulation Mode (Emulate Ball Sensor)") - replay = flag.Bool("replay", false, "Replay All Packet") - halfswitch = flag.String("c", "F", "Where to use (N, P, F) F to Full") - ballmovethreshold = flag.Float64("b", 1000, "Ball Detect Threshold (Default 1000") - nw_robot = flag.String("rif", "none", "NW Robot Update Interface Name (ex. en0)") - nw_vision = flag.String("vif", "none", "NW Vision and Referee receive Interface Name (ex. en1)") - debug_for_sono = flag.Bool("df", false, "Print ID0 Robot Cordination for Sono") + visionport = flag.Int("p", 10006, "Vision Multicast Port Number") + ourteam = flag.String("t", "blue", "Our Team (blue or yellow)") + goalpos = flag.String("g", "N", "Attack Direction(Enemy goal) Negative or Positive (N or P)") + reportrate = flag.Uint("r", 16, "How often report to RACOON-AI? (milliseconds)") + debug = flag.Bool("d", false, "Show All Send Packet") + simmode = flag.Bool("s", false, "Simulation Mode (Emulate Ball Sensor)") + replay = flag.Bool("replay", false, "Replay All Packet") + halfswitch = flag.String("c", "F", "Where to use (N, P, F) F to Full") + ballmovethreshold = flag.Float64("b", 1000, "Ball Detect Threshold (Default 1000") + nw_robot = flag.String("rif", "none", "NW Robot Update Interface Name (ex. en0)") + nw_vision = flag.String("vif", "none", "NW Vision and Referee receive Interface Name (ex. en1)") + debug_for_sono = flag.Bool("df", false, "Print ID0 Robot Cordination for Sono") + ignore_ref_mismatch = flag.Bool("igref", false, "Ignore Referee Team Color & Attack Direction Mismatch Errors") ) //OUR TEAM 0 = blue //OUR TEAM 1 = yellow @@ -273,7 +274,7 @@ func main() { chbattery := make(chan bool) go Update(chupdate) - go RunServer(chserver, *reportrate, ourteam_n, goalpos_n, *debug, *simmode) + go RunServer(chserver, *reportrate, ourteam_n, goalpos_n, *debug, *simmode, *ignore_ref_mismatch) go VisionReceive(chvision, *visionport, ourteam_n, goalpos_n, *simmode, *replay, halfswitch_n, *debug_for_sono) go CheckVisionRobot(chvisrobot) go FPSCounter(chfps, ourteam_n) diff --git a/variables.go b/variables.go index 9ef8131..9eebdc5 100644 --- a/variables.go +++ b/variables.go @@ -25,29 +25,16 @@ var balldetect [16]bool var visionwrapper [16]*pb_gen.SSL_WrapperPacket var visiondetection [16]*pb_gen.SSL_DetectionFrame -var trackerwrapper [16]*pb_gen.TrackerWrapperPacket -var trackerdetection [16]*pb_gen.TrackedFrame - var geometrydata *pb_gen.SSL_GeometryData var left_geo_goal_x float32 var left_geo_goal_y float32 -var num_bluerobots int -var num_yellowrobots int - var bluerobots [16]*pb_gen.SSL_DetectionRobot var yellowrobots [16]*pb_gen.SSL_DetectionRobot -var trackedblue [16]*pb_gen.TrackedRobot -var trackedyellow [16]*pb_gen.TrackedRobot - var ref_command *pb_gen.Referee var ball *pb_gen.SSL_DetectionBall -var trackedball *pb_gen.TrackedBall - -var only_use_tracker bool = false - var maxcameras int var filtered_ball_x float32 diff --git a/visionreceive.go b/visionreceive.go index cf4e7cb..e5260db 100644 --- a/visionreceive.go +++ b/visionreceive.go @@ -238,27 +238,21 @@ func VisionReceive(chvision chan bool, port int, ourteam int, goalpos int, simmo } } - num_yellowrobots = 0 - num_bluerobots = 0 - // Get Blue Robots for _, robot := range packet.Detection.GetRobotsBlue() { switch halfswitch_n { case 0: - num_bluerobots++ bluerobots[robot.GetRobotId()] = robot visible_in_vision_b[robot.GetRobotId()] = true case 1: if robot.GetX() > 0 { - num_bluerobots++ bluerobots[robot.GetRobotId()] = robot visible_in_vision_b[robot.GetRobotId()] = true } case -1: if robot.GetX() <= 0 { - num_bluerobots++ bluerobots[robot.GetRobotId()] = robot visible_in_vision_b[robot.GetRobotId()] = true } @@ -269,20 +263,17 @@ func VisionReceive(chvision chan bool, port int, ourteam int, goalpos int, simmo for _, robot := range packet.Detection.GetRobotsYellow() { switch halfswitch_n { case 0: - num_yellowrobots++ yellowrobots[robot.GetRobotId()] = robot visible_in_vision_y[robot.GetRobotId()] = true case 1: if robot.GetX() > 0 { - num_yellowrobots++ yellowrobots[robot.GetRobotId()] = robot visible_in_vision_y[robot.GetRobotId()] = true } case -1: if robot.GetX() <= 0 { - num_yellowrobots++ yellowrobots[robot.GetRobotId()] = robot visible_in_vision_y[robot.GetRobotId()] = true }