Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use ArduPilot firmware manifest to download SITL binaries #145

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

peterbarker
Copy link
Contributor

With a little bit of work this will also allow dronekit-sitl to work on ARM.

I don't have a great solution for parameters yet.

@kyrlon
Copy link

kyrlon commented Feb 23, 2023

$ dronekit-sitl copter
Traceback (most recent call last):
  File "C:\Users\kyrlon\Documents\Repositories\py_venv\Scripts\dronekit-sitl-script.py", line 33, in <module>
    sys.exit(load_entry_point('dronekit-sitl==3.3.0', 'console_scripts', 'dronekit-sitl')())
  File "C:\Users\kyrlon\Documents\Repositories\py_venv\Scripts\dronekit-sitl-script.py", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "C:\Users\kyrlon\AppData\Local\Programs\Python\Python39\lib\importlib\metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "C:\Users\kyrlon\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 983, in get_code
  File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\kyrlon\Documents\Repositories\py_venv\lib\site-packages\dronekit_sitl\__init__.py", line 240
    os.chmod(target_filepath, 0755)
                                 ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
(py_venv) 

@nonmeaning
Copy link

i try the new version of "init.py" to run dronekit-sitl, but it still doesn't work. I run it on the nvidia jetson Orin NX. Here are the Tracbacks:
File "/home/heu/miniconda3/envs/UAV-track/bin/dronekit-sitl", line 33, in
sys.exit(load_entry_point('dronekit-sitl==3.3.0', 'console_scripts', 'dronekit-sitl')())
File "/home/heu/miniconda3/envs/UAV-track/lib/python3.8/site-packages/dronekit_sitl-3.3.0-py3.8.egg/dronekit_sitl/init.py", line 847, in main
sitl.launch(args, verbose=True)
File "/home/heu/miniconda3/envs/UAV-track/lib/python3.8/site-packages/dronekit_sitl-3.3.0-py3.8.egg/dronekit_sitl/init.py", line 493, in launch
caps = ArdupilotCapabilities(self.path)
File "/home/heu/miniconda3/envs/UAV-track/lib/python3.8/site-packages/dronekit_sitl-3.3.0-py3.8.egg/dronekit_sitl/init.py", line 402, in init
process = subprocess.Popen([path, '--help'], stdout=subprocess.PIPE)
File "/home/heu/miniconda3/envs/UAV-track/lib/python3.8/subprocess.py", line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/heu/miniconda3/envs/UAV-track/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/heu/.dronekit/sitl/copter-3.3/apm'
Any help to resolve this queson? Many thanks!

@i-vis
Copy link

i-vis commented Aug 9, 2024

Hi! As @kyrlon mentioned, 0o755 instead of 0755 fixes the code. Also I think there should be a check for sitl_target directory, whether it exists or not before os.makedirs(sitl_target) ( in def version_list_new_manifest() ), as I had problem with that because that path exists already. After doing these 2 small changes to code in this PR, my dronekit-sitl, MAVproxy, dronekit setup for testing finally works correctly and problems like #153 are gone. Thank you very much, I hope your PR will get updated and merged.

@peterbarker peterbarker marked this pull request as ready for review August 9, 2024 11:30
@peterbarker
Copy link
Contributor Author

Hi! As @kyrlon mentioned, 0o755 instead of 0755 fixes the code. Also I think there should be a check for sitl_target directory, whether it exists or not before os.makedirs(sitl_target) ( in def version_list_new_manifest() ), as I had problem with that because that path exists already. After doing these 2 small changes to code in this PR, my dronekit-sitl, MAVproxy, dronekit setup for testing finally works correctly and problems like #153 are gone. Thank you very much, I hope your PR will get updated and merged.

Wow. Some love for a 5-year old PR!

I've made the changes suggested here. Could people test them, please? :-)

@kyrlon
Copy link

kyrlon commented Aug 10, 2024

Hi! As @kyrlon mentioned, 0o755 instead of 0755 fixes the code. Also I think there should be a check for sitl_target directory, whether it exists or not before os.makedirs(sitl_target) ( in def version_list_new_manifest() ), as I had problem with that because that path exists already. After doing these 2 small changes to code in this PR, my dronekit-sitl, MAVproxy, dronekit setup for testing finally works correctly and problems like #153 are gone. Thank you very much, I hope your PR will get updated and merged.

Wow. Some love for a 5-year old PR!

I've made the changes suggested here. Could people test them, please? :-)

AND HE'S BACK!! :)

Was able to run with no problems with the recent changes on Win10, python3.10 with a venv.

Here are the commands ran to attempt this:

PS C:\Users\kyrlon\Desktop> py -m venv dronekit-sitl
PS C:\Users\kyrlon\Desktop> .\dronekit-sitl\Scripts\activate
(dronekit-sitl) PS C:\Users\kyrlon\Desktop>
(dronekit-sitl) PS C:\Users\kyrlon\Desktop> py -m pip install git+https://github.com/dronekit/dronekit-sitl@refs/pull/145
.
.
(install process of dependencies)
.
.
(dronekit-sitl) PS C:\Users\kyrlon\Desktop> dronekit-sitl copter
os: win, apm: copter, release: stable
Downloading SITL from http://dronekit-assets.s3.amazonaws.com/sitl/copter/sitl-win-copter-3.3.tar.gz
Download Complete.
Payload Extracted.
Ready to boot.
Execute: C:\Users\kyrlon\.dronekit\sitl\copter-3.3\apm.exe --home=-35.363261,149.165230,584,353 --model=quad -I 0
SITL-0> Started model quad at -35.363261,149.165230,584,353 at speed 1.0
SITL-0.stderr> bind port 5760 for 0
Starting sketch 'ArduCopter'
Serial port 0 on TCP port 5760
Starting SITL input
Waiting for connection ....

@peterbarker peterbarker merged commit 4bcaf94 into dronekit:master Aug 13, 2024
@peterbarker
Copy link
Contributor Author

@kyrlon many thanks for the testing - I've merged this one now.

I'm going to try to set up an easy release process for this next...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants