ROS in 5 days: not publishing in /drone/takeoff

Hey Mr. Bayode,
While I was working on exercise 7.6, I was trying to make the drone take off but it isn’t working. I have tried it with the action server running. I echoed the topic c /drone/takeoff and it seem like the client isn’t publishing anything into the topic at all. I would be glad if you could help me.

#! /usr/bin/env python
import rospy
from std_msgs.msg import Empty

takeoff = rospy.Publisher(’/drone/takeoff’, Empty, queue_size=1)

Thank You,
Prashiddha Dhoj Thapa

Hi @p.thapa,

Welcome to the community!

Please check the following:

  • How are you running your Python code? What output is it generating? Any errors?
  • Are you able to run the following from the terminal successfully?
user:~$ rostopic pub /drone/takeoff std_msgs/Empty "{}"
publishing and latching message. Press ctrl-C to terminate
user:~$ rostopic pub /drone/land std_msgs/Empty "{}"
publishing and latching message. Press ctrl-C to terminate

Yes, I can run the command from the terminal but cannot publish into the topic from python. The program runs without error except at the end which says the state is 3 (warning). The code should also move the drone but it stays stationary on the ground.

#! /usr/bin/env python
import rospy
import time
import actionlib
from geometry_msgs.msg import Twist
from std_msgs.msg import Empty
from ardrone_as.msg import ArdroneAction, ArdroneGoal, ArdroneResult, ArdroneFeedback
nImage = 1

def feedback_callback(feedback):
    global nImage
    print('[Feedback] image n.%d received'%nImage)
    nImage += 1

client = actionlib.SimpleActionClient('/ardrone_action_server', ArdroneAction)
goal = ArdroneGoal()
goal.nseconds = 10
client.send_goal(goal, feedback_cb=feedback_callback)
pub = rospy.Publisher('cmd_vel', Twist, queue_size = 1)
takeoff = rospy.Publisher('drone/takeoff', Empty, queue_size=1)
land = rospy.Publisher('drone/land', Empty, queue_size=1)
rate = rospy.Rate(1)
var = Twist()
i = 1
while client.get_state()<2:
    if i%2 == 0:
        var.linear.x = 1
        var.linear.z = 0.5
        var.linear.x = -0.3
        var.linear.z = 0
    i = i + 1
var.linear.x = 0
var.linear.z = 0
print('[Result] State: %d'%(client.get_state()))

Things you can check:

  • You need to have the action server running (in a separate shell) as indicated.
  • Try creating a publisher to /drone/takeoff/ instead of drone/takeoff/. Same with the “land” topic.
  • Publishing once to a topic might not work, the way you have done it. This was mentioned in the Data for the exercise. See how to publish once to a topic and ensure it works:


I tried to publish more than once into /drone/takeoff, /drone/land and /cmd_vel, but sadly the drone is not moving at all. I tried into the main and using a class. I checked the teleop__twist__keyboard program and I am doing the right thing. I call the takeoff and land topics using the command line and they work.

Please any advice?


Hi Bladimir,

Are you trying to publish more than one message to /drone/takeoff? Do you have your action server/client running?