Sometimes Takeoff Hangs on Sending Service Call


Sometimes when we launch our program the drone get’s hung up on sending the service call for the takeoff and the drone will just hover.

However, once we take the pixhawk off of offboard it will say the response was received and that the takeoff was successful. Any idea what could be going on? Any help would be greatly appreciated, thanks!



Which device are you using as companion computer?
What is your flytos version?
Please attach flytos runlog, whenever this happens again.
How are you triggering the takeoff API? via rest/cpp/python?
Are you using APM/PX4?
Can you share your code?
Takeoff API is synchronous call, and will not return unless the takeoff alt is achieved. What is your takeoff alt? Have you tried waiting for sometime, for the service to return?


I’m using the Nvidia TX2 as a companion computer.
The flytos version we’re using is 1.34
We are triggering the takeoff API via rospy.
We are using the PX4.
Yes, I can share the code:

This is our code which calls the takeoff command:

import rospy
import time
import droneControl as dC
import objectTracker as oT

def main():
drone = dC.drone()
cam =
print “Starting Local position” + str(drone.localPosition)
print “Starting global position” + str(drone.globalPosition)

cam.lowerMask = (160,45,138)
cam.upperMask = (180, 255, 255)

missionCont = True

print "testing camera"

    missionCont = False
    print "Camera Issue, scrubbing takeoff"

if missionCont:

    localPosAir = drone.localPosition
    globalPosAir = drone.globalPosition

    print "Local Position after takeoff" + str(localPosAir)
    print "Gobal position after takeoff" + str(globalPosAir)

start_time = time.time()
while time.time() - start_time < 30 and missionCont:
        print "Taking Image"
        print "Abort mission, camera issue detected"

    if cam.objInImage:
        print "Going up!"
            drone.setpoint_local_position(localPosAir[0], localPosAir[1], localPosAir[2] - 3, yaw=0,
                                          async=False, relative=False, yaw_valid=False, body_frame=False)

        print "No object in frame, going down"
            drone.setpoint_local_position(localPosAir[0], localPosAir[1], localPosAir[2]- 1, yaw=0,
                                          async=False, relative=False, yaw_valid=False, body_frame=False)
print "Ending local position" + str(drone.localPosition)
print "Ending global position" + str(drone.globalPosition)

if name == “main”:

The takeoff alt is 3 meters.

We have waited sometime for the service to return, but it just will hover and not increase or decrease it’s altitude.

Thanks for the response!


Also, I forgot to include this portion of the code:

def takeOff(self, alt):
print "Calling Takeoff Service: " + str(time.time())
rospy.wait_for_service(’/’+ self.global_namespace +’/navigation/take_off’)
print "Service recieved: " + str(time.time())
print "Sending service call to " + str(alt) + ": " + str(time.time())
handle = rospy.ServiceProxy(’/’+ self.global_namespace +’/navigation/take_off’, TakeOff)
resp = handle(takeoff_alt=alt)
print "Response recieved: " + str(time.time())
except rospy.ServiceException, e:
rospy.logerr(“takeoff service call failed %s”, e)
# cannot continue without taking off
return None
print "Took off successfully: " + str(time.time())
print "Sleeping for 3 seconds."
print “Exciting takeoff method.”

(We call the takeoff service from a seperate class that we created. Feel free to tell me if you need/want to see the rest of the code. Thanks again!)



Sorry for the delayed response. I would suggest you to try our cpp demoapp or python demoapp.
I have tested demoapp1(cpp and python) in FlytSim, and they are working just fine.

Also, I would request you share code as a file or use Preformatted text as format option, to strip the formatting done by the editor.