forked from KRSSG/robocup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
triangle2.py
71 lines (65 loc) · 2.02 KB
/
triangle2.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
print "In test GOToPoint"
from kubs import kubs, cmd_node
from velocity.run import *
import rospy,sys
from krssg_ssl_msgs.msg import point_2d
from krssg_ssl_msgs.msg import BeliefState
from krssg_ssl_msgs.msg import gr_Commands
from krssg_ssl_msgs.msg import gr_Robot_Command
from krssg_ssl_msgs.msg import point_SF
from krssg_ssl_msgs.msg import target_triangle
from utils.config import *
import memcache
shared = memcache.Client(['127.0.0.1:11211'], debug = False)
import sys
BOT_ID = 1
print "bot_id received",BOT_ID
pub = rospy.Publisher('/grsim_data', gr_Commands, queue_size=1000)
GOAL_POINT = point_2d()
GOAL_POINT.x = 1000
GOAL_POINT.y = 1200
REPLANNED = 0
homePos = None
awayPos = None
BState = shared.get('state')
kub = kubs.kubs(BOT_ID, BState, pub)
def reset():
global start_time
start_time = rospy.Time.now()
start_time = 1.0*start_time.secs + 1.0*start_time.nsecs/pow(10,9)
def target_Callback(msg):
global GOAL_POINT
GOAL_POINT.x = msg.tx1
GOAL_POINT.y = msg.ty1
def BS_callback(data):
global homePos, REPLANNED
global awayPos, start_time, BState, kub, GOAL_POINT
BState = data
homePos = data.homePos
awayPos = data.awayPos
t = rospy.Time.now()
t = t.secs + 1.0*t.nsecs/pow(10,9)
# print(" t - start = ",t-start_time)
[vx, vy, vw, REPLANNED] = Get_Vel(start_time, t, BOT_ID, GOAL_POINT, homePos, awayPos) #vx, vy, vw, replanned
# print("-------------------REPLANNED = ",REPLANNED)
if(REPLANNED):
reset()
# print("vx = ",vx)
# print("vy = ",vy)
# print("kubs_id = ",kub.kubs_id)
try:
kub.move(vx, vy)
kub.turn(vw)
kub.execute()
except Exception as e:
print("In except",e)
pass
if __name__ == "__main__":
global start_time
rospy.init_node('node_new_2',anonymous=False)
start_time = rospy.Time.now()
start_time = 1.0*start_time.secs + 1.0*start_time.nsecs/pow(10,9)
pub = rospy.Publisher('/grsim_data', gr_Commands, queue_size=1000)
rospy.Subscriber('/belief_state', BeliefState, BS_callback, queue_size=1000)
rospy.Subscriber('/target_params', target_triangle, target_Callback, queue_size = 1000)
rospy.spin()