4 from ds4_driver.msg
import Feedback, Status
8 def __init__(self, status_topic='status', feedback_topic='set_feedback'):
19 self.
_pub_feedback = rospy.Publisher(feedback_topic, Feedback, queue_size=1)
20 rospy.Subscriber(status_topic, Status, self.
cb_status, queue_size=1)
26 now = rospy.Time.now()
32 feedback.set_rumble =
True 33 feedback.rumble_small = abs(msg.axis_left_y)
34 feedback.rumble_big = abs(msg.axis_right_y)
38 if touch.active
and msg.button_circle:
39 feedback.set_led =
True 40 self.
_led[
'r'] = touch.x 41 if touch.active
and msg.button_triangle:
42 feedback.set_led =
True 43 self.
_led[
'g'] = touch.x
44 if touch.active
and msg.button_cross:
45 feedback.set_led =
True 46 self.
_led[
'b'] = touch.x
47 feedback.led_r = self.
_led[
'r'] 48 feedback.led_g = self._led['g']
49 feedback.led_b = self.
_led[
'b']
52 if not self._prev.button_ps
and msg.button_ps:
53 feedback.set_led_flash =
True 54 if self.
_led[
'flashing']:
55 feedback.led_flash_off = 0
57 feedback.led_flash_on = 0.2
58 feedback.led_flash_off = 0.2
59 self.
_led[
'flashing'] =
not self.
_led[
'flashing']
61 self._pub_feedback.publish(feedback)
67 rospy.init_node(
'sample')
74 if __name__ ==
'__main__':
def __init__(self, status_topic='status', feedback_topic='set_feedback')