-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
WSL2 instructions to build, flash and simulate on Windows #1747
Conversation
Co-authored-by: Daniel Agar <daniel@agar.ca>
I will try this out tomorrow. Thanks! There should be only one recommended main approach for each platform - what would it take for WSL2 to become that option? |
For my workflow it is already the main option. The caveats are:
This might as well be a complete deal-breaker for some but on the other side the size problems preventing to generate a new Cygwin toolchain with the existing script makes the current version more and more outdated. |
Thanks @MaEtUgR! Are any of the issues you listed - direct serial flashing, auto connection of native QGC, graphics support amenable to fixing via configuration in some way or are they likely "forever" problems? My take on this is that we can live with "No direct serial flashing with the upload script", and "No automatic connection of native QGC to the sim running in WSL." (if we have to - undesirable) but it is much too early to insist on Win 11. You state in "Requirements for graphics support" that this is in Windows insider preview builds, so assuming it will go into Windows 10 soon, that might reasonably be the trigger for making this the main approach (if my assumption it will go into Windows 10 is correct). That said, if we can somehow route the the comms to localhost on the host, that would be even better. |
I got the error
Gazebo seems to work. Still playing. |
en/dev_setup/dev_env_windows_wsl.md
Outdated
3. Install the extension called [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) (marketplace) | ||
4. [Open a WSL shell](dev_env_windows_wsl.md#opening-a-wsl-shell) | ||
5. Switch to the PX4 folder: `cd ~/PX4-Autopilot` | ||
6. Open this folder with WSL integration in Visual Studio Code `code .` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? I presume you mean find the folder in the windows C drive? Note that the Linux penguin doesn't show up in VS Code so you can't select the WSL version in the same way as you would in Explorer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You install the extension in the VS code gui, then open a WSL shell, navigate to the folder with the command cd ~/PX4-Autopilot
and in this folder execute the command code .
as if you would be on Linux and the repository opens in VS code but natively. They do some trickery WSL magic to make that happen.
@hamishwillee Theoretically there can be workarounds. E.g. serial flashing could maybe call a pyton script outside of WSL and for the automatic connection to native QGC we could in theory run MAVLink router in WSL to forward the conntection to Windows. So easy to fix no, possibly yes with some cumbersome workarounds.
I thought so too. It's only for graphics support that the Windows version has to be so recent.
I expected the same since I had it running on the Windows 10 insider build before I switched to Windows 11 stable. But when I checked https://github.com/microsoft/wslg#pre-requisites again it switched from Windows 10 insider build to Windows 11 insider build 🤔 Maybe it's just to tease or not up to date. In any case Windows 11 stable works for sure. Windows 10 I'd need to test again.
Do you mean such that e.g. jMAVsim could run natively? That's also theoretically possible but with multiple workarounds to start and connect it all.
I got that as well. Was assuming it's the same for Ubuntu since it's basically running on Ubuntu. I remember jMAVsim worked with this setup earlier on. So I was assuming it's a general issue. |
@MaEtUgR No, I mean setting things up such that you can automatically connect to simulator from QGC on Windows (without having to work out the IP address of your virtual machine). You answered here #1747 (comment) as "maybe, but I'm not sure how".
You would be right/it is: http://docs.px4.io/master/en/simulation/jmavsim.html#an-illegal-reflective-access-operation-has-occured |
Awesome. Nearly there. Would be good if you could sanity check my changes. |
@MaEtUgR One more idea for "static IP address" workaround. Not sure it is "scalable" or something we can support, but perhaps something we could mention. A similar problem comes up with websites hosted as a process in a virtual machine - every time they boot they get a new IP. The solution as I understand it is Dynamic DNS. Yes your IP address changes, but on boot you find the address and send it to the DNS system which then updates. So you end up doing your addressing via DNS. https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client-on-ubuntu/ Something to think about. |
``` | ||
This will open the IDE fully integrated with the WSL shell. | ||
|
||
Make sure you always open the PX4 repository in the Remote WSL mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, @MaEtUgR Thanks for your explanation of the WSL integration.
To make this clear to others, I have added this line here - so that make it very clear that "this" is what it mean to open the PX4 repository in the Remote WSL mode.
Then in step 7 I add your image of how you "Open Recent" and not that it is also " opening in Remote WSL mode "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks a lot. I just didn't see how to tell that in a clear way 😇
@MaEtUgR Thanks for your patience. I've integrated your comments. Also done a cross link from Cygwin recommending this if you're building against master. There is a suggestion here #1747 (comment) but should not block merging. Upshot, merging now as "useful starting point". We can iterate. If you find out that this runs on windows 10 with the GUI, let me know. That would trigger it replacing Cygwin IMO. |
I added instructions on how to employ WSL2 to do PX4 development on Windows. I'm successfully using this environment for several months now. It works seamlessly, fast and allows for efficient work. The biggest improvement that brought me to switch to this environment is the native graphics support with 3D acceleration through the built-in WSLg. I suggest we add these instructions as even a preferred option to the Cygwin toolchain and keep both options for now. I would honestly also surface the VMWare instructions as a valid option because for certain developers it might be the prefered way.
I replaced the BashOnWindows instructions because those are deprecated.