-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistener
33 lines (25 loc) · 929 Bytes
/
listener
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import rospy
import math
import time
from krssg_ssl_msgs.msg import SSL_DetectionFrame
from grsim_ros_bridge_msgs.msg import *
robots_pose = [[],[],[],[],[]]
robots_coordinates = [[],[],[],[],[]]
ball = []
j =0
def callback(data):
global ball, robots, j
if len(data.balls) > 0:
ball = [data.balls[0].x, data.balls[0].y]
if len(data.robots_blue) > 0:
i = 0
while i < len(data.robots_blue):
robot_idx = data.robots_blue[i].robot_id
robots_pose[robot_idx] = [data.robots_blue[i].x, data.robots_blue[i].y, data.robots_blue[i].orientation]
robots_coordinates[robot_idx] = [data.robots_blue[i].x, data.robots_blue[i].y]
i = i+1
if __name__ == '__main__':
while not rospy.is_shutdown():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("/vision", SSL_DetectionFrame, callback)