-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws_utilze.py
More file actions
executable file
·125 lines (102 loc) · 2.96 KB
/
ws_utilze.py
File metadata and controls
executable file
·125 lines (102 loc) · 2.96 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import os
import numpy as np
import json
from websocket import create_connection
global_stauts = None
def receive_global_status(general_status):
global global_stauts
global_stauts = general_status
# commu_ip = '192.168.2.217'
# commu_port = 11920
# rover_ip = '192.168.1.154'
# rover_port = 11920
# ws_rover = create_connection("ws://%s:%s/command"%(rover_ip,rover_port))
# ws_commu = create_connection("ws://%s:%s/command"%(commu_ip,commu_port))
def rover_do(joints, paras, speeds, ws_rover):
label = 'move_multi'
# joint 100: forward_backward
# joint 101: up_down
# joint 102: truning
# joint 103:
# angle distance
# ws = create_connection("ws://%s:%s/command"%(rover_ip,rover_port))
# data = {"@class": "commu.message.MoveMultiInfo",
# "angles": paras,
# "client": 0,
# "commu": 0,
# "id": "",
# "joints":joints,
# "label": "move_multi",
# "room": "room",
# "speeds": speeds,
# "topic": "command"}
data = {"@class": "commu.message.MoveMultiInfo",
"angle": paras[-1],
"client": 0,
"commu": 0,
"id": "",
"joint":joints[-1],
"label": "move",
"room": "room",
"speed": speeds[-1],
"topic": "command"}
if global_stauts["status"]!="stop":
ws_rover.send(json.dumps(data))
# pass
def move_multi_joint(joint, angle, speed, ws_commu):
# ws = create_connection("ws://%s:%s/command"%(commu_ip,commu_port))
# joints=[1,2,3,4]
# angles=[10,20,30,30]
# speeds=[10,20,30,30]
data = {
"@class":"commu.message.MoveMultiInfo",
"label":"move_multi",
"joints":joint,
"angles":angle,
"speeds":speed,
"id":"",
"topic":"command",
"client":0,
"room":"room",
"commu":0
}
print("status",global_stauts["status"])
if global_stauts["status"]!="stop":
ws_commu.send(json.dumps(data))
# result = ws_commu.recv()
# print("Received '%s'" % result)
# ws.close()
def say_sentence(sentence, ws_commu):
# ws = create_connection("ws://%s:%s/command"%(commu_ip,commu_port))
data = {"@class":"commu.message.SayInfo",
"label":"say",
"text":sentence,
# "voice":"eng_girl",
"voice":"yuuto",
"speed":1,"volume":1,"pitch":1,"pause":1000,
"device":"default",
"id":"",
"topic":
"command",
"client":0,
"room":"room",
"commu":0}
if global_stauts["status"]!="stop":
ws_commu.send(json.dumps(data) )
# result = ws_commu.recv()
# print("Received '%s'" % result)
# ws.close()
def move_multi_joint_stop(joint, angle, speed, ws_commu):
data = {
"@class":"commu.message.MoveMultiInfo",
"label":"move_multi",
"joints":joint,
"angles":angle,
"speeds":speed,
"id":"",
"topic":"command",
"client":0,
"room":"room",
"commu":0
}
ws_commu.send(json.dumps(data))