forked from stefantasy/ros_itchat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWXROS.py
executable file
·61 lines (45 loc) · 1.58 KB
/
WXROS.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
#!/usr/bin/env python
#coding=utf8
# license removed for brevity
import requests
import itchat
import rospy
roskey = u'ROS'
from std_msgs.msg import String
@itchat.msg_register(itchat.content.TEXT)
def wcMsg(msg):
global roskey
pub = rospy.Publisher('/test_string', String, queue_size=10)
tts = rospy.Publisher('/voice_system/tts_topic', String, queue_size=10)
nlu = rospy.Publisher('/voice_system/nlu_topic', String, queue_size=10)
rospy.init_node('weChat2ROS', anonymous=True)
rate = rospy.Rate(10) # 10hz
msg0 = msg['Text']
if msg0[0:8] == u'chroskey':
roskey = msg0[8:]
itchat.send(u'控制关键词已修改为'+roskey , 'filehelper')
if msg0[0:6] == u'roskey':
itchat.send(u'当前控制关键词为'+roskey , 'filehelper')
l = len(roskey)
msg1 = msg0[0:l]
msg2 = msg0[l:]
if msg2== u'前进' and msg1 == roskey:
itchat.send(u'ROS机器人-前进中', 'filehelper')
if msg2== u'后退' and msg1 == roskey:
itchat.send(u'ROS机器人-后退中', 'filehelper')
if msg2 == u'右转' and msg1 == roskey:
itchat.send(u'ROS机器人-右转中', 'filehelper')
if msg2 == u'左转' and msg1 == roskey:
itchat.send(u'ROS机器人-左转中', 'filehelper')
if msg2== u'停' and msg1 == roskey:
itchat.send(u'ROS机器人-不走了', 'filehelper')
if msg1 == roskey:
tts.publish(msg2)
nlu.publish(msg2)
rate.sleep()
msg1 = u''
pub.publish(msg0)
return
if __name__ == '__main__':
itchat.auto_login(True)
itchat.run()