I am trying to run dronekit code on dronekit-sitl but am running into quite a few problems.
I am running dronekit-sitl on Python 3 in Windows 10 (I know python 3 is not officially supported) and running MAVproxy to connect to SITL and open a few ports for Mission Planner and for running a python script. Unfortunately I am unable to change the flight mode, either through the terminal running mavproxy using “mode LAND” and through dronekit. It gives a message on the MAVproxy Console program Got COMMAND_ACK: DO_SET_MODE: UNSUPPORTED.
It has been a while since I have worked on dronekit and mavproxy and to me it has changed a lot. I have worked on dronekit and mavproxy on python3 before and had made a tutorial video of setting everything up Ardupilot Software-in-the-loop (SITL) Tutorial - Python 3. I tried to retrace my steps but MAVproxy is giving me quite a few problems.
Also when every I try to run mavproxy.py it just opens the python file in the editor and I have to go in the python scripts folder to run it, which didn’t use to happen.
I know that I can address this issue with the following PR
This issue is a matter by PYMAVLINK.
The new PYMAVLINK is not available with the old firmware.
You can either downgrade PYMAVLINK as you have done, or change it as in my PR.
I think dronekit is a bit obsolete. As i understand it, it is not updated anymore. Some time ago there has been a bit of a discussion to bring it back to life but i guess it didn’t happen.
You better not use it and go direct to pymavlink i think.
@Jai.GAY Never seen this issue, even without FTP to download parameters with wait_ready=True, it took less than 30 seconds to connect to the vehicle.
I suggest you build SITL from source code.
You can follow here and then here.
Probably it is. You can follow exact steps you did before on your computer to narrow down the issue.
Dronekit should work properly on rpi because i did it before, but never started sitl in rpi.
You can run SITL on computer (i suggest you to build from source) and run your script (dronekit) on rpi.
could be due to this statement, not very sure, now consistent 22.xx secs
from future import print_function
Now new problem is forever loop in while statement
EKF OK?: False
Is Armable?: False
Armed: False
# Check that vehicle is armable
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Vehicle is ready for arm")
So you are connecting to a device, it waits you to push hardware safety switch.
Also, I don’t know your arm conditions, without GPS fix, you may wait forever.
This is more like it.
Probably this is due to GPS fix.
You can take a look at examples in here. They are really easy to follow.
Thanks for the examples, I removed pre-arm check for GPS related, still
Is Armable?: False
if I comment off and ignore the while loop check, I can arm.
connectMyCopter
/dev/ttyAMA0
921600
Connecting to vehicle on: /dev/ttyAMA0
Get all vehicle attribute values:
Autopilot Firmware version: APM:UnknownVehicleType13-4.1.0
Major version number: 4
Minor version number: 1
Patch version number: 0
Release type: rc
Release version: 0
Stable release?: True
Autopilot capabilities
Supports MISSION_FLOAT message type: True
Supports PARAM_FLOAT message type: True
Supports MISSION_INT message type: True
Supports COMMAND_INT message type: True
Supports PARAM_UNION message type: False
Supports ftp for file transfers: True
Supports commanding attitude offboard: True
Supports commanding position and velocity targets in local NED frame: True
Supports set position + velocity targets in global scaled integers: True
Supports terrain protocol / data handling: True
Supports direct actuator control: False
Supports the flight termination command: True
Supports mission_float message type: True
Supports onboard compass calibration: True
Global Location: LocationGlobal:lat=0.0,lon=0.0,alt=None
Global Location (relative altitude): LocationGlobalRelative:lat=0.0,lon=0.0,alt=-0.536
Local Location: LocationLocal:north=None,east=None,down=None
Attitude: Attitude:pitch=0.0202799346298,yaw=-2.34485840797,roll=0.0222185738385
Velocity: [0.0, 0.0, 0.0] GPS: GPSInfo:fix=1,num_sat=0
Gimbal status: Gimbal: pitch=None, roll=None, yaw=None
Battery: Battery:voltage=16.126,current=1.18,level=98 EKF OK?: False
Last Heartbeat: 0.792305155
Rangefinder: Rangefinder: distance=None, voltage=None
Rangefinder distance: None
Rangefinder voltage: None
Heading: 225 Is Armable?: False
System status: STANDBY
Groundspeed: 0.00942026544362
Airspeed: 0.0
Mode: ALT_HOLD
Armed: False
ARM
Vehicle is ready for arm
Wait for drone to transit to arm
vehicle is now armed.
Propellers are spinning
Wait for drone to transit to disarm
Wait for drone to transit to disarm
Wait for drone to transit to disarm
close
End of python test script
The vehicle is not armable in GUIDED mode since this mode requires GPS fix. After that vehicle mode changed to STABILIZE and this mode doesn’t require GPS and the vehicle is armable in this mode.
Thanks, changing to STABILIZE mode also hang inside while loop.
if not vehicle.is_armable:
if not vehicle.mode.name == 'STABILIZE':
vehicle.mode = VehicleMode("STABILIZE")
while not vehicle.mode.name == 'STABILIZE': #Wait until mode has changed
print(" Waiting for mode change ...")
time.sleep(1)
# Check that vehicle is armable, hangs
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Vehicle is ready for arm")