Open developermastermind07 opened 5 years ago
I was having this issue earlier and fixed it by removing all versions of dronekit and mavproxy and then making sure I reinstalled them using pip2: pip2 install mavproxy dronekit dronekit-sitl
. When you use pip
it defaults to installing the python3 version (if you have python3, whic I assume you do) and then when you run your code with python
it also defaults to python3. After reinstalling, I made sure I ran all dronekit code with python2
ex: python2 arm.pi --connect 127.0.0.1:14551
Also, I noticed you're using MISSION
as a vehicle mode. It should be GUIDED
:) Finally, I prefer to use sim_vehicle.py to run SITL, and to then just connect to mavproxy's udp out port when running your python code.
Running sim_vehicle.py
As your user
cd ~
git clone https://github.com/ArduPilot/ardupilot.git
ardupilot/Tools/autotest/sim_vehicle.py -v ArduCopter
Connecting to SITL run from sim_vehicle.py
python2 arm.pi --connect udp:127.0.0.1:14550
or in python:
connection_string = "udp:127.0.0.1:14550"
I find using sim_vehicle.py to be much more stable than running SITL and mavproxy by themselves. Hope this helped. -Gabe
@gabrielruoff : Yes i am using python3. Same script works for dronekit-sitl but not working actual UAV. Also when i tried to connect directly to USB port using above script still it fails to connect. ex python2 arm.pi --connect /dev/ttyUSB0
Is there any issue of python3 ?
after connect we can set mode but here i am not even able to connect to the UAV
Yes i am using python3. Same script works for dronekit-sitl but not working actual UAV. Also when i tried to connect directly to USB port using above script still it fails to connect.
If you're connecting to an actual vehicle you need to pass the port to which the vehicle is connected through --connect, not '127.0.0.1' which is a local network address. Only SITL runs on 127.0.0.1, not the actual vehicle. If you're using USB try python2 arm.py --connect /dev/ttyUSB0
or in python: connection_string = '/dev/ttyUSB0'
@developermastermind07 I have a similar problem, shown like:
"Traceback (most recent call last):
File "drone_delivery.py", line 232, in
Try keeping wait ready False It worked for me
it's a great suggestion ,Thanks!
Connecting to vehicle on: 127.0.0.1:14551 Traceback (most recent call last): File "arm.py", line 34, in
vehicle = connect(connection_string, wait_ready=True)
File "C:\Program Files\python\lib\site-packages\dronekit__init.py", line 31
72, in connect
timeout=timeout)
File "C:\Program Files\python\lib\site-packages\dronekit\init__.py", line 23
75, in wait_ready
timeout)
dronekit.TimeoutError: wait_ready experienced a timeout after 30 seconds.
Using mavproxy i connected to UAV/drone which is connected COM6 port. Using out option i am forwarding output to 127.0.0.1:14551 port. When dronekit trying to connect to this one throwing timeout exception.
My script is :
from future import print_function import time from dronekit import connect, VehicleMode, LocationGlobalRelative,LocationGlobal
Set up option parsing to get connection string
import argparse parser = argparse.ArgumentParser(description='Commands vehicle using vehicle.simple_goto.') parser.add_argument('--connect', help="Vehicle connection target string. If not specified, SITL automatically started and used.") args = parser.parse_args()
connection_string = args.connect sitl = None
Start SITL if no connection string specified
if not connection_string: import dronekit_sitl sitl = dronekit_sitl.start_default() connection_string = sitl.connection_string()
print('test')
Connect to the Vehicle
print('Connecting to vehicle on: %s' % connection_string) vehicle = connect(connection_string, wait_ready=True)
time.sleep(5)
new_home_location = LocationGlobal(18.578516,73.8790863,0)
vehicle.home_location = new_home_location
time.sleep(5)
while not vehicle.is_armable: print(" Waiting for vehicle to initialise...") time.sleep(1)
print("Arming motors")
Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("MISSION") vehicle.armed = True
Confirm vehicle armed before attempting to take off
while not vehicle.armed: print(" Waiting for arming...") time.sleep(1)
time.sleep(30)
vehicle.armed = False vehicle.close() if sitl: sitl.stop()
And executed by following command :
python script_test.py --connect 127.0.0.1:14551