4 from sensor_msgs.msg
import Joy
6 from std_srvs.srv
import Empty
9 def __init__(self, use_controller, joy_topic):
10 rospy.wait_for_service(
'update_params')
11 rospy.loginfo(
"found update_params service")
14 rospy.loginfo(
"waiting for emergency service")
15 rospy.wait_for_service(
'emergency')
16 rospy.loginfo(
"found emergency service")
20 rospy.loginfo(
"waiting for land service")
21 rospy.wait_for_service(
'land')
22 rospy.loginfo(
"found land service")
23 self.
_land = rospy.ServiceProxy(
'land', Empty)
25 rospy.loginfo(
"waiting for takeoff service")
26 rospy.wait_for_service(
'takeoff')
27 rospy.loginfo(
"found takeoff service")
28 self.
_takeoff = rospy.ServiceProxy(
'takeoff', Empty)
39 for i
in range(0, len(data.buttons)):
41 if i == 0
and data.buttons[i] == 1
and self.
_land !=
None:
43 if i == 1
and data.buttons[i] == 1:
45 if i == 2
and data.buttons[i] == 1
and self.
_takeoff !=
None:
47 if i == 4
and data.buttons[i] == 1:
48 value = int(rospy.get_param(
"ring/headlightEnable"))
50 rospy.set_param(
"ring/headlightEnable", 1)
52 rospy.set_param(
"ring/headlightEnable", 0)
58 if __name__ ==
'__main__':
59 rospy.init_node(
'crazyflie_demo_controller', anonymous=
True)
60 use_controller = rospy.get_param(
"~use_crazyflie_controller",
False)
61 joy_topic = rospy.get_param(
"~joy_topic",
"joy")
def __init__(self, use_controller, joy_topic)
def _joyChanged(self, data)