1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import threading
16 import uuid
17
18 import rospy
19
20 import intera_dataflow
21 from intera_io import IODeviceInterface
22
24 """
25 Interface class for a Navigator on the Intera Research Robot.
26
27 Signals:
28 button_square_changed - OFF/CLICK/LONG_PRESS/DOUBLE_CLICK
29 button_ok_changed
30 button_back_changed
31 button_show_changed
32 button_triangle_changed
33 button_circle_changed
34 wheel_changed - Wheel value
35
36 """
37
39 """
40 Constructor.
41
42 """
43 self._navigator_io = IODeviceInterface("robot", "navigator")
44 self._button_lookup = {0:'OFF', 1:'CLICK',
45 2:'LONG_PRESS', 3:'DOUBLE_CLICK'}
46
48 """
49 Returns a list of strings describing all available navigator items
50
51 @rtype: list
52 @return: a list of string representing navigator items
53 Each item name of the following format:
54 '<assembly>_button_<function>'
55 """
56 return self._navigator_io.list_signal_names()
57
59 """
60 Current state of the wheel providing wheel name
61 @type wheel_name: str
62 @param wheel_name: the wheel name
63
64 @rtype: uint
65 @return: an integer representing how far the wheel has turned
66 """
67 return self._get_item_state(wheel_name)
68
81
97
99 """
100 Registers a supplied callback to a change in state of supplied
101 signal_name's value. Spawns a thread that will call the callback with
102 the updated value.
103
104 @type callback_function: function
105 @param callback_function: function handle for callback function
106 @type signal_name: str
107 @param signal_name: the name of the signal to poll for value change
108 @type poll_rate: int
109 @param poll_rate: the rate at which to poll for a value change (in a separate
110 thread)
111
112 @rtype: str
113 @return: callback_id retuned if the callback was registered, and an
114 empty string if the requested signal_name does not exist in the
115 Navigator
116 """
117 return self._navigator_io.register_callback(
118 callback_function=callback_function,
119 signal_name=signal_name,
120 poll_rate=poll_rate)
121
123 """
124 Deregisters a callback based on the supplied callback_id.
125
126 @type callback_id: str
127 @param callback_id: the callback_id string to deregister
128
129 @rtype: bool
130 @return: returns bool True if the callback was successfully
131 deregistered, and False otherwise.
132 """
133 return self._navigator_io.deregister_callback(callback_id)
134
137