jgc_example.py 907 Bytes
Newer Older
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
#!/usr/bin/env python

import roslib; roslib.load_manifest('ros_extctrl')
import rospy
from ros_extctrl.msg import ExtCtrlStart, ExtCtrlStatus


def status_cb(data):
    print "ExtCtrl responded: %s" % data.status


def interact():
    # These should be a service.
    pub = rospy.Publisher('ec_start', ExtCtrlStart)
    sub = rospy.Subscriber('ec_status', ExtCtrlStatus, status_cb)
    while not rospy.is_shutdown():
        line = ''
        try:
            line = raw_input("Choose a controller to activate:")
        except EOFError:
            print('\nBye')
            break
        aua_id = 0
        try:
            aua_id = int(line)
        except ValueError:
            print("%s is not a number" % line)
            continue
        v = ExtCtrlStart()
        v.aua_id = aua_id
        pub.publish(v)


if __name__ == '__main__':
    rospy.init_node('extctrl_usage_example')
    interact()