Drone programming primer scripts for real drone


#1

Kind of a dumb question but how exactly can I take the scripts/missions that we created in the “Drone Programming Primer” course and apply them to my F450 drone that I built in “How to build a raspberry pi drone”?

I’m only familiar with using Putty to ssh into my raspberry pi drone, but I want to be able to run an autonomous mission via a python code like we did in the “autonomous dronekit mission with AUTO mode”.

Thank you.


#2

Afer you ssh into the RPi, use a command such as

python takeoff_and_land.py --connect 127.0.0.1:14550

Refer to the section “Script for Autonomous Mission Takeoff and Land” [9:30].

Remember to leash it and override with the transmitter if needed!

I would also recommend configuring your vehicle with a failsafe mode.


#3

@caleberg Relatedly, I’m hoping to get a bit of guidance how to send DK script to a Pixhawk/Cube from an RPi companion. I already see how to connect and configure them here: (https://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html).


#4

Thanks. I noticed in the 9:33 mark of that video he has established connection through his Ubuntu environment to the RPI drone and runs the takeoff and land script that way. Do you happen to know how that is done?


#5

I’m sorry I don’t understand - that is what I stated above. Perhaps you could be more specific what you are unclear about?


#6

Hi there @Jspatafore49

That was done by SSH’ing to the Raspberry Pi on the drone from an Ubuntu laptop. It’s like the same PuTTy process done on windows just on an Ubuntu machine.

The way you would run scripts from the Drone Programming Primer on a real drone would be to:

  1. Write the scripts onto the Raspberry Pi of the drone
  2. Call the scripts via some sort of SSH connection from a Laptop -> To the Raspberry Pi

Step two can be a bit tricky if you aren’t close to a WiFi source you have access to. In that video, both my drone and my laptop were connected to my home WiFi network so no special network configurations were needed.


#7

I agree it would be awesome to have RPi->Pixhawk guides at the Dojo. That is definitely on my list!


#8

@Jspatafore49 Check out how to create an ad hoc network.
@caleberg Could you clarify advantages/disadvantages of using adhoc vs radio telemetry/UART in the field when using QGC/Mission Planner and ssh to the scripts?


#9

Okay thank you @caleberg and @jax200. I didn’t realize you could SSH into the drone from the Ubuntu platform. I thought PuTTy had to be involved from a windows platform.


#11

I did try this python takeoff_and_land.py script and seem to be getting an error:

pi@navio:~/dk $ python takeoff_and_land.py --connect 127.0.0.1:14550

Link timeout, no heartbeat in last 5 seconds
No heartbeat in 30 seconds, aborting.
Traceback (most recent call last):
File “takeoff_and_land.py”, line 55, in
vehicle=connectMyCopter()
File “takeoff_and_land.py”, line 19, in connectMyCopter
vehicle = connect(connection_string, wait_ready=True)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit/init.py”, line 2845, in connect
vehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit/init.py”, line 2117, in initialize
raise APIException(‘Timeout in initializing connection.’)
dronekit.APIException: Timeout in initializing connection.

I’ve seen another thread on the forum with people having this issue, and it seemed the solution was to update ArduCopter to 4.0? I believe I am running 3.5.


#12

Try searching the forum for “heartbeat” and a number of cases will appear. This one might be of interest: “Connect() Link timeout, no heartbeat in last 5 seconds”.
Try searching on “version” and " IMPORTANT NOTE ON NAVIO2 ARDUPILOT VERSION".