Skip to content

Commit

Permalink
Merge pull request #54 from Rione/multicast
Browse files Browse the repository at this point in the history
Multicast
  • Loading branch information
Tamagoham authored Oct 11, 2024
2 parents b72160a + 2836b72 commit bb4998e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

func FPSCounter(chfps chan bool, ourteam int) {
imu_reset_time = time.Now()
for {
//Calculate Online Robot IDs
var online_robot_id_str string
Expand All @@ -30,8 +29,7 @@ func FPSCounter(chfps chan bool, ourteam int) {

framecounter = 0

//Time to second
log.Printf("Estimated FPS: %d FPS // Last IMU Reset Time %s ago", fps, time.Duration(time.Since(imu_reset_time).Seconds())*time.Second)
log.Printf("Estimated FPS: %d FPS", fps)
log.Printf("Vision: %t, Connected Robots: %s", isvisionrecv, online_robot_id_str)
var our_yellows int
var our_reds int
Expand Down Expand Up @@ -119,17 +117,28 @@ func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, d
addr_controller := ipv4 + ":" + port_controller
addr_gui := ipv4 + ":" + port_gui

ip_other := NW_OUT_MCAST_IPADDR
port_other := NW_OUT_MCAST_PORT
addr_other := ip_other + ":" + port_other

log.Println("Send to:", addr)

conn, err := net.Dial("udp", addr)
CheckError(err)
conn_controller, err := net.Dial("udp", addr_controller)
CheckError(err)
conn_gui, err := net.Dial("udp", addr_gui)
CheckError(err)

conn_other, err := net.Dial("udp", addr_other)
CheckError((err))

defer conn.Close()
defer conn_controller.Close()
defer conn_gui.Close()

defer conn_other.Close()

var counter int

for {
Expand Down Expand Up @@ -204,6 +213,7 @@ func RunServer(chserver chan bool, reportrate uint, ourteam int, goalpose int, d
conn.Write([]byte(Data))
conn_controller.Write([]byte(Data))
conn_gui.Write([]byte(Data))
conn_other.Write([]byte(Data))
}

time.Sleep(time.Duration(reportrate) * time.Millisecond)
Expand Down
20 changes: 8 additions & 12 deletions variables.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package main

import (
"time"

"github.com/Rione-SSL/RACOON-MW/proto/pb_gen"
)

var BALL_MOVING_THRESHOULD_SPEED float32 = 1000

var NW_ROBOT_UPDATE_INTERFACE_NAME string = "nil"
var NW_VISION_REFEREE_INTERFACE_NAME string = "nil"
var NW_AI_IPADDR string = "127.0.0.1"
var NW_AI_PORT string = "30011"
var NW_AI_PORT_CONTROLLER string = "30012"
var NW_AI_PORT_GUI string = "30013"

var NW_AI_IPADDR string = "127.0.0.1" //DEPRECATED
var NW_AI_PORT string = "30011" //DEPRECATED
var NW_AI_PORT_CONTROLLER string = "30012" //DEPRECATED
var NW_AI_PORT_GUI string = "30013" //DEPRECATED

var NW_REF_MAX_DATAGRAM_SIZE int = 8192 * 2

var IMU_RESET_INTERVAL time.Duration = 5000 * time.Millisecond
var NW_OUT_MCAST_IPADDR string = "224.12.3.21"
var NW_OUT_MCAST_PORT string = "30006"

var MAX_AVAILABLE_TIMEOUTS int = 5

Expand Down Expand Up @@ -100,11 +101,6 @@ var filtered_enemy_x [16]float32
var filtered_enemy_y [16]float32
var filtered_enemy_theta [16]float32

var ball_x_history []float32
var ball_y_history []float32

var imu_reset_time time.Time

var robot_online [16]bool

var teamcolor_from_ref int = -1
Expand Down

0 comments on commit bb4998e

Please sign in to comment.