Sometimes Takeoff Hangs on Sending Service Call


#1

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!


#2

Hi,

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?


#3

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 = oT.camera()
rospy.init_node(‘node’)
print “Starting Local position” + str(drone.localPosition)
print “Starting global position” + str(drone.globalPosition)

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

missionCont = True

print "testing camera"

try:
    cam.procImage()
except:
    missionCont = False
    print "Camera Issue, scrubbing takeoff"
    cam.releaseStream()

if missionCont:
    drone.takeOff(3)

    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:
    try:
        print "Taking Image"
        cam.procImage()
        cam.writeImage()
    except:
        print "Abort mission, camera issue detected"
        break

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

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

if name == “main”:
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!


#4

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())
try:
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."
time.sleep(3)
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!)


#5

Hi,

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.