Adding take off and landing into teleop_twist_keyboard.py
I have successfully sourced and compiled so I can fly my bebop drone using the teleop_twist_keyboard python script.
However I am currently having to run a separate terminal to make the bebop land and take off. Can someone help with how to edit the python script so I can assign the keys 1 ans 2 to mean take off and land respectively.
I have tried various combinations none with any luck (in addition to the original teleop twist keyboard script)
def takeoff():
pub = rospy.Publisher("bebop/takeoff", Empty, queue_size=10 )
rospy.init_node('takeoff', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
pub.publish(Empty())
rate.sleep()
if __name__ == '__main__':
try:
takeoff()
except rospy.ROSInterruptException:
pass
def land():
pub = rospy.Publisher("ardrone/land", Empty, queue_size=10 )
rospy.init_node('land', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
pub.publish(Empty())
rate.sleep()
if __name__ == '__main__':
try:
land()
except rospy.ROSInterruptException:
pass
1= takeoff()
2= land()
(didnt expect this one to work )Also tried:
moveBindings = {
'i':(1,0,0,0),
'o':(1,0,0,-1),
'j':(0,0,0,1),
'l':(0,0,0,-1),
'u':(1,0,0,1),
',':(-1,0,0,0),
'.':(-1,0,0,1),
'm':(-1,0,0,-1),
'O':(1,-1,0,0),
'I':(1,0,0,0),
'J':(0,1,0,0),
'L':(0,-1,0,0),
'U':(1,1,0,0),
'<':(-1,0,0,0),
'>':(-1,-1,0,0),
'M':(-1,1,0,0),
't':(0,0,1,0),
'b':(0,0,-1,0),
'1'= rostopic pub --once [namespace]/takeoff std_msgs/Empty,
'2'= rostopic pub --once [namespace]/land std_msgs/Empty }`enter code here`
This repo isn't exactly what you're looking for (it's for the AR.Drone 2.0), but it may be helpful. Also, checkout Mike Hamer's tutorial for the 2.0 as well.
Also, you said
what are these exactly? Can you update your question with your attempts?
Thanks for the link but these do not explain how to change a python script. They are relating to configuring a joystick which I am not using. Thanks though.
There is a keyboard teleop node too. And as I asked earlier, can you please update your question with what you've tried.
Thanks for the update, but in order to make the question readable please use the Preformatted Text (
1010101
) button to properly format your code.