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 import rospy
29 import intera_dataflow
30 from intera_io import IODeviceInterface
31 from intera_core_msgs.msg import IODeviceConfiguration
32 from robot_params import RobotParams
33
34
36 """
37 Interface class for cuff on the Intera robots.
38 """
39
41 """
42 Constructor.
43
44 @type limb: str
45 @param limb: limb side to interface
46 """
47 params = RobotParams()
48 limb_names = params.get_limb_names()
49 if limb not in limb_names:
50 rospy.logerr("Cannot detect Cuff's limb {0} on this robot."
51 " Valid limbs are {1}. Exiting Cuff.init().".format(
52 limb, limb_names))
53 return
54 self.limb = limb
55 self.device = None
56 self.name = "cuff"
57 self.cuff_config_sub = rospy.Subscriber('/io/robot/cuff/config', IODeviceConfiguration, self._config_callback)
58
59 intera_dataflow.wait_for(
60 lambda: not self.device is None, timeout=5.0,
61 timeout_msg=("Failed find cuff on limb '{0}'.".format(limb))
62 )
63 self._cuff_io = IODeviceInterface("robot", self.name)
64
66 """
67 config topic callback
68 """
69 if msg.device != []:
70 if str(msg.device.name) == self.name:
71 self.device = msg.device
72
81
90
99
101 """
102 Registers a supplied callback to a change in state of supplied
103 signal_name's value. Spawns a thread that will call the callback with
104 the updated value.
105
106 @type callback_function: function
107 @param callback_function: function handle for callback function
108 @type signal_name: str
109 @param signal_name: the name of the signal to poll for value change
110 @type poll_rate: int
111 @param poll_rate: the rate at which to poll for a value change (in a separate
112 thread)
113
114 @rtype: str
115 @return: callback_id retuned if the callback was registered, and an
116 empty string if the requested signal_name does not exist in the
117 Navigator
118 """
119 return self._cuff_io.register_callback(
120 callback_function=callback_function,
121 signal_name=signal_name,
122 poll_rate=poll_rate)
123
125 """
126 Deregisters a callback based on the supplied callback_id.
127
128 @type callback_id: str
129 @param callback_id: the callback_id string to deregister
130
131 @rtype: bool
132 @return: returns bool True if the callback was successfully
133 deregistered, and False otherwise.
134 """
135 return self._cuff_io.deregister_callback(callback_id)
136