dronekit / dronekit-python

DroneKit-Python library for communicating with Drones via MAVLink.
https://readthedocs.org/projects/dronekit-python/
Apache License 2.0
1.62k stars 1.45k forks source link

SITL test is failing: copter mode stuck on STABILIZE #1041

Open pietrodn opened 4 years ago

pietrodn commented 4 years ago

The SITL tests are currently failing on the master branch, both for Python 2 and Python 3. The cause is a SITL test that's not passing: test_goto.py.

The apparent reason of the error is that the test times out when setting the mode to GUIDED. I managed to run the unit test locally, and I can't get the SITL to switch to GUIDED: the vehicle remains stuck on STABILIZE. The GPS and the global location seem to be ok. The Vehicle is periodically receiving heartbeat updates containing the mode flag, so it's not a reception problem.

My hypothesis is that some update on the ArduPilot side, or in some dependencies, made the tests fail. From the commit history it's easy to see that the previous commits (that worked) are identical to the latest ones, which were simple documentation changes.

Any hints?

pietrodn commented 4 years ago

The problem is in pymavlink. The latest passing tests use pymavlink 2.4.0, and with that version the test still passes. I ran a bisect and pymavlink is OK until 2.4.8: the 2.4.9 release broke something.

pietrodn commented 4 years ago

Found the problematic commit: https://github.com/ArduPilot/pymavlink/commit/1fa59ff0bbc0999353b30feac3afe5cfd67c08a9

peterbarker commented 4 years ago

On Sat, 4 Jul 2020, Pietro De Nicolao wrote:

Found the problematic commit: ArduPilot/pymavlink@1fa59ff

Looks like my bad. What version of ardupilot's being run in SITL by default?!

I tend to run master ArduPilot when I'm using dronekit-python.

Fix here is probably to have dronekit-sitl pull a binary from ArduPilot's firmware.ardupilot.org; I have a branch here which does that.

Peter

pietrodn commented 4 years ago

By default dronekit-sitl runs ArduPilot Copter v3.3. Probably it’s better to test against an updated firmware version as you said πŸ‘

peterbarker commented 4 years ago

On Sun, 5 Jul 2020, Pietro De Nicolao wrote:

By default dronekit-sitl runs ArduPilot Copter v3.3. Probably it’s better to test against an updated firmware version as you said πŸ‘

https://github.com/dronekit/dronekit-sitl/pull/145

So that kinda-sorta works. At least far enough for the simple_goto.py dronekit-python example to work with no extra arguments.

Really not happy with the parameters stuff, obviously.

rmccarth commented 4 years ago

Hi, in the meantime should we revert to using 2.9.1? (I noticed there's a 2 year gap on pypi)

Nevermind. I was able to uninstall pymavlink with

pip3 uninstall pymavlink

and then reinstall the older version with

pip3 install pymavlink==2.4.8
sanky1234 commented 4 years ago

Hi, in the meantime should we revert to using 2.9.1? (I noticed there's a 2 year gap on pypi)

Nevermind. I was able to uninstall pymavlink with

pip3 uninstall pymavlink

and then reinstall the older version with

pip3 install pymavlink==2.4.8

Did this work for you by just reinstalling an old version of pymavlink? It wasn’t working for me.

rmccarth commented 4 years ago

Hi, in the meantime should we revert to using 2.9.1? (I noticed there's a 2 year gap on pypi) Nevermind. I was able to uninstall pymavlink with

pip3 uninstall pymavlink

and then reinstall the older version with

pip3 install pymavlink==2.4.8

Did this work for you by just reinstalling an old version of pymavlink? It wasn’t working for me.

Yeah reverting pymavlink to 2.4.8 did the trick for me. If you are having trouble in general I would suggest running the dronekit-python/examples/vehicle_state/vehicle_state.py to check if there is a bug in your code.

punkypankaj commented 4 years ago

Hi, in the meantime should we revert to using 2.9.1? (I noticed there's a 2 year gap on pypi) Nevermind. I was able to uninstall pymavlink with

pip3 uninstall pymavlink

and then reinstall the older version with

pip3 install pymavlink==2.4.8

Did this work for you by just reinstalling an old version of pymavlink? It wasn’t working for me.

Yeah reverting pymavlink to 2.4.8 did the trick for me. If you are having trouble in general I would suggest running the dronekit-python/examples/vehicle_state/vehicle_state.py to check if there is a bug in your code.

yes this reverting back to older version of pymavlink worked for me, i was having trouble in DO_SET_MODE change while executing the python script as it was stuck at stabalize, even now i can't change the mode in mavproxy but it works when i run the script

i was having pymavlink 2.4.12 and reverted back to pymavkink 2.4.8 for now at least im able to run the script and need to find the issue with mavproxy

walchko commented 3 years ago

pymavlink 2.4.14 is junk also ... reverting to 2.4.8 fixed it

danammeansbear commented 3 years ago

the fix doesnt work at this point, just ends up spitting a bunch of horse crap on my screen.

danammeansbear commented 3 years ago
'''

AttributeError: 'MAVLink_vibration_message' object has no attribute '_instance_field' ERROR:dronekit.mavlink:Exception in MAVLink input loop Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit\mavlink.py", line 211, in mavlink_thread_in fn(self) File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit__init.py", line 1370, in listener raise APIException('No heartbeat in %s seconds, aborting.' % dronekit.APIException: No heartbeat in 30 seconds, aborting. ERROR:dronekit.mavlink:Exception while receiving message: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit\mavlink.py", line 218, in mavlink_thread_in msg = self.master.recv_msg() File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 456, in recv_msg return None File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 372, in post_message File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 83, in add_message ''' AttributeError: 'MAVLink_heartbeat_message' object has no attribute '_instance_field' ERROR:dronekit.mavlink:Exception while receiving message: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit\mavlink.py", line 218, in mavlink_thread_in msg = self.master.recv_msg() File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 456, in recv_msg return None File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 372, in post_message File "C:\ProgramData\Anaconda3\lib\site-packages\pymavlink\mavutil.py", line 83, in add_message ''' AttributeError: 'MAVLink_heartbeat_message' object has no attribute '_instance_field' ERROR:dronekit.mavlink:Exception in MAVLink input loop Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit\mavlink.py", line 211, in mavlink_thread_in fn(self) File "C:\ProgramData\Anaconda3\lib\site-packages\dronekit\init__.py", line 1370, in listener raise APIException('No heartbeat in %s seconds, aborting.' % dronekit.APIException: No heartbeat in 30 seconds, aborting.

Mettikodeva commented 3 years ago

By default dronekit-sitl runs ArduPilot Copter v3.3. Probably it’s better to test against an updated firmware version as you said πŸ‘

how to run dronekit-sitl with updated firmware version? thanks

SarinleFreeman commented 2 years ago

Downgrading pymavlink didn't work for me on windows 11 as per #1169. It gave me the following error message:

`AttributeError: 'array.array' object has no attribute 'fromstring'

`

One fix is utilizing Ubuntu on your windows system. After setting up Ubuntu i downgraded pymavlink to 2.4.8 and mav_proxy to 1.7.1

sudo pip uninstall mavproxy sudo pip install pymavlink==2.4.8 sudo pip install mavproxy==1.7.1

I will continue my analysis on #1169 and see if i can find a solution for windows.

Xarbenence commented 1 year ago

I've been experiencing the same issue of telling my SITL to enter GUIDED mode, but it gets stuck in the loop waiting for the mode to change. I tried to downgrade to pymavlink==2.4.8, but I'm getting a legacy-install-failure. Has anyone experienced this? I'm on a Mac with an M1 chip, if that helps. I've also noticed that downgrading about anything via pip usually ends in an error, but not necessarily the same error.

alexsharper@dhcp-10-105-11-95 ~ % sudo pip3 install pymavlink==2.4.8 WARNING: The directory '/Users/alexsharper/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Collecting pymavlink==2.4.8 Downloading pymavlink-2.4.8.tar.gz (3.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 28.4 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Requirement already satisfied: future in /opt/homebrew/lib/python3.9/site-packages (from pymavlink==2.4.8) (0.18.3) Requirement already satisfied: lxml in /opt/homebrew/lib/python3.9/site-packages (from pymavlink==2.4.8) (4.9.2) Building wheels for collected packages: pymavlink Building wheel for pymavlink (setup.py) ... error error: subprocess-exited-with-error

Γ— python setup.py bdist_wheel did not run successfully. β”‚ exit code: 1 ╰─> [54 lines of output] running bdist_wheel running build running build_py Using message definitions from /private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/message_definitions Building /private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/message_definitions/v1.0/python_array_test.xml for protocol 1.0 WARNING: Unable to load XML validator libraries. XML validation will not be performed Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 109, in setup (name = 'pymavlink', File "/opt/homebrew/lib/python3.9/site-packages/setuptools/init.py", line 87, in setup return distutils.core.setup(**attrs) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup return run_commands(dist) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands dist.run_commands() File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands self.run_command(cmd) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/opt/homebrew/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 299, in run self.run_command('build') File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 136, in run self.run_command(cmd_name) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 103, in run generate_content() File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 64, in generate_content if not mavgen.mavgen_python_dialect(dialect, mavparse.PROTOCOL_1_0): File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavgen.py", line 247, in mavgen_python_dialect if not mavgen(opts, [xml]): File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavgen.py", line 142, in mavgen xml.append(mavparse.MAVXML(fname, opts.wire_protocol)) File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavparse.py", line 420, in init m.crc_extra = message_checksum(m) File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavparse.py", line 447, in message_checksum crc.accumulate_str(msg.name + ' ') File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavcrc.py", line 34, in accumulate_str bytes.fromstring(buf) AttributeError: 'array.array' object has no attribute 'fromstring' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pymavlink Running setup.py clean for pymavlink Failed to build pymavlink Installing collected packages: pymavlink DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Running setup.py install for pymavlink ... error error: subprocess-exited-with-error

Γ— Running setup.py install for pymavlink did not run successfully. β”‚ exit code: 1 ╰─> [58 lines of output] running install /opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py Using message definitions from /private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/message_definitions Building /private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/message_definitions/v1.0/python_array_test.xml for protocol 1.0 WARNING: Unable to load XML validator libraries. XML validation will not be performed Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 109, in setup (name = 'pymavlink', File "/opt/homebrew/lib/python3.9/site-packages/setuptools/init.py", line 87, in setup return distutils.core.setup(**attrs) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup return run_commands(dist) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands dist.run_commands() File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands self.run_command(cmd) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py", line 68, in run return orig.install.run(self) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/command/install.py", line 670, in run self.run_command('build') File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 136, in run self.run_command(cmd_name) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py", line 1229, in run_command super().run_command(command) File "/opt/homebrew/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command cmd_obj.run() File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 103, in run generate_content() File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/setup.py", line 64, in generate_content if not mavgen.mavgen_python_dialect(dialect, mavparse.PROTOCOL_1_0): File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavgen.py", line 247, in mavgen_python_dialect if not mavgen(opts, [xml]): File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavgen.py", line 142, in mavgen xml.append(mavparse.MAVXML(fname, opts.wire_protocol)) File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavparse.py", line 420, in init m.crc_extra = message_checksum(m) File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavparse.py", line 447, in message_checksum crc.accumulate_str(msg.name + ' ') File "/private/tmp/pip-install-qkyxr4il/pymavlink_7b139926334f4849b671942012c96389/generator/mavcrc.py", line 34, in accumulate_str bytes.fromstring(buf) AttributeError: 'array.array' object has no attribute 'fromstring' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

Γ— Encountered error while trying to install package. ╰─> pymavlink

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

Miles5177 commented 1 year ago

Have you been able to find a solution to this? thank you!

mujtabafromthedarkside commented 1 year ago

I am also getting the same as above legacy-install-failure as above with Python3. I am on Windows 10. The installation works fine for python2.

danammeansbear commented 1 year ago

i am having trouble on multiple systems. cant seem to figure out how to get it to work on ubuntu or my local windows machine which had it working a year ago but now its caput and im tooo scared to test it on my drone because i need to demo it for my senior project. Adam Dabdoub Software Developer c: 513.886.0301

On Tue, Apr 4, 2023 at 6:55β€―PM Mujtaba @.***> wrote:

I am also getting the same as above legacy-install-failure as above with Python3. I am on Windows 10. The installation works fine for python2.

β€” Reply to this email directly, view it on GitHub https://github.com/dronekit/dronekit-python/issues/1041#issuecomment-1496699633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJKTGIN2VUEMMXXCISAJGTW7SRHJANCNFSM4OQPXHGA . You are receiving this because you commented.Message ID: @.***>

SarinleFreeman commented 1 year ago

i am having trouble on multiple systems. cant seem to figure out how to get it to work on ubuntu or my local windows machine which had it working a year ago but now its caput and im tooo scared to test it on my drone because i need to demo it for my senior project. Adam Dabdoub Software Developer c: 513.886.0301 … On Tue, Apr 4, 2023 at 6:55β€―PM Mujtaba @.> wrote: I am also getting the same as above legacy-install-failure as above with Python3. I am on Windows 10. The installation works fine for python2. β€” Reply to this email directly, view it on GitHub <#1041 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJKTGIN2VUEMMXXCISAJGTW7SRHJANCNFSM4OQPXHGA . You are receiving this because you commented.Message ID: @.>

It works on Ubuntu for me, perhaps set up an associated Docker Image which uses Ubuntu and run your code on there?

Otherwise I can set up one and I'll link it in this chat.

danammeansbear commented 1 year ago

I think it would be nice to have an official docker image that we can use as a base so there less hiccups in getting into development because as it stands, the tutorial is out of date if legacy users are having issues just getting back into the code base. Adam Dabdoub Software Developer c: 513.886.0301

On Wed, Apr 5, 2023 at 8:48β€―AM Sarinle @.***> wrote:

i am having trouble on multiple systems. cant seem to figure out how to get it to work on ubuntu or my local windows machine which had it working a year ago but now its caput and im tooo scared to test it on my drone because i need to demo it for my senior project. Adam Dabdoub Software Developer c: 513.886.0301 … <#m4898225133774497299> On Tue, Apr 4, 2023 at 6:55β€―PM Mujtaba @.> wrote: I am also getting the same as above legacy-install-failure as above with Python3. I am on Windows 10. The installation works fine for python2. β€” Reply to this email directly, view it on GitHub <#1041 (comment) https://github.com/dronekit/dronekit-python/issues/1041#issuecomment-1496699633>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJKTGIN2VUEMMXXCISAJGTW7SRHJANCNFSM4OQPXHGA https://github.com/notifications/unsubscribe-auth/AHJKTGIN2VUEMMXXCISAJGTW7SRHJANCNFSM4OQPXHGA . You are receiving this because you commented.Message ID: @.>

It works on Ubuntu for me, perhaps set up an associated Docker Image which uses Ubuntu and run your code on there?

Otherwise I can set up one and I'll link it in this chat.

β€” Reply to this email directly, view it on GitHub https://github.com/dronekit/dronekit-python/issues/1041#issuecomment-1497431706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJKTGLOW3ZTUZHVMR4NE5TW7VS3JANCNFSM4OQPXHGA . You are receiving this because you commented.Message ID: @.***>

Atigit15 commented 1 year ago

The installation works fine for python2

Can you tell me how to install the desired version of pymavlink for python2, since pip is no longer supported for python2. Thank you !

wangcongai commented 6 months ago

After pymavlink version==2.4.8, the set_mode_apm function in pymavlik.mavutil.py changed, which cause failure on ardupilot MODE CHANGE. In order to use new version like pymavlink version==2.4.41, you just need to comment the code on "mav.command_long_send" and change it back to old "mav.set_mode_send". Reboot your IDE, Then the problem solved!

image
mujtabafromthedarkside commented 3 months ago

After pymavlink version==2.4.8, the set_mode_apm function in pymavlik.mavutil.py changed, which cause failure on ardupilot MODE CHANGE. In order to use new version like pymavlink version==2.4.41, you just need to comment the code on "mav.command_long_send" and change it back to old "mav.set_mode_send". Reboot your IDE, Then the problem solved! image

Yeah, that works. I guess, this is a good way to make it run on latest python versions that do not support pymavlink version 2.4.8

Previously, I used to use either python 3.6 or python 2.7 which were compatible with pymavlink==2.4.8