Github Codespaces (Programming in your browser for FRC) 2023 Update

I made a post a few weeks ago pre-kick off on how to use codespaces for WPILib, the marketplace plugin hasn’t been updated since last year (because we are not supposed to be using it). So here is a new devcontainer.json which allows you to use 2023.2.1 wpilib on codespaces. Remember this goes into .devcontainer/devcontainer.json.

{
  "image": "mcr.microsoft.com/devcontainers/universal:2",
  "postCreateCommand": "cd /opt && wget 'https://github.com/wpilibsuite/vscode-wpilib/releases/download/v2023.2.1/vscode-wpilib-2023.2.1.vsix'",
  "features": {
  },
  "customizations": {
    "vscode": {
      "extensions": ["/opt/vscode-wpilib-2023.2.1.vsix","vscjava.vscode-java-pack","vscjava.vscode-gradle"]
    }
  }
}

DELETE THE CODESPACE WHEN YOU ARE DONE WITH IT!

We have a functional example here on our Everybot repository.

To check and delete your codespaces you can go to github.com/codespaces

Hopefully this helps teams program anywhere!

6 Likes

I’m sure this is exactly what I was looking for!

When I opened a codespace of the Everybot repository you linked to, it works at starting up for a really long time (probably over an hour) but hasn’t yet finished, and does not give me syntax highlighting. Any idea what I might be doing wrong?

So far I’ve been doing this in Windows 10 and a private browsing window of FireFox.

1 Like

Weird, I had opened it on my computer when i made the post, WPILib installed in a few seconds and was able to compile.

Does this work with github.dev, or just Codespaces?

1 Like

I only tested codespaces

On a different computer (happens to have Windows 11) in a private window it looks like it finished in 3 min 40 sec but still virtually no syntax highlighting. Actually now I realize there is IntelliSense.

In a normal FireFox window it works much better.

With github.dev you’re not limited to 60 hr per month of free usage but it gives you a very limited set of functionality

  • A subset of syntax highlighting
  • Inability to build code or use a terminal
  • A subset of extensions

The difference is github.dev runs in the client side in the browser whereas codespaces also requires a virtual machine on the server side - so costs more money for GitHub/Microsoft to run.

Here’s a more complete comparison of github.dev and codespaces.

1 Like

I’m not sure what the advantages or disadvantages are to the alternative Java extensions so I just changed one line to the extensions that ship with WPILib by default (including the C++ extension).

{
  "image": "mcr.microsoft.com/devcontainers/universal:2",
  "postCreateCommand": "cd /opt && wget 'https://github.com/wpilibsuite/vscode-wpilib/releases/download/v2023.2.1/vscode-wpilib-2023.2.1.vsix'",
  "features": {
  },
  "customizations": {
    "vscode": {
      "extensions": ["/opt/vscode-wpilib-2023.2.1.vsix", "redhat.java", "vscjava.vscode-java-debug", "vscjava.vscode-java-dependency", "ms-vscode.cpptools"]
    }
  }
}
2 Likes

I noticed! I like the changes and put it in the repo.

Thank you! My team is now using this for machines where WPILib is not already installed. I have a couple of questions:

  • Does anyone know how to setup codespaces to be billed to the team while individuals operate with their own identities? The docs are a bit unclear to me.
  • What are the limitations of using codespaces for robot development?
1 Like

I believe these are the key limitations:

  • no simulation GUI (although it may be possible to get there with VNC?)
  • no ability to deploy to the robot
  • no ability to talk to coprocessors
  • no driver station
  • no other GUI tools (dashboards, etc) (but maybe with VNC?)

So you can clone your repo, edit, build, check in… but that’s it.

1 Like

Glad to hear it! Organizations have to enable codespaces. I avoid doing so because I am unsure of how many hours you get free as an organization, if any. Another thing to note is github doesn’t offer any free codespace hours for educational orgs or nonprofits currently.

Are unit testing and subsystem testing possible (or facilitated by wpilib) in this constrained system?

Setting up CI for Robot Code using GitHub Actions is documented for FRC and runs on a Linux system which is probably quite similar the the OS image selected in the example above. So I would think all that would work fine in codespaces. The tricky part is doing anything with a GUI outside of VS Code.

3 Likes

Any chance someone is giving this a shot for developing with C++? I’m attempting to get this working, because most of the students have Chromebooks. The team has been using C++ for a while and they’d like to keep it that way.

I attempted to use these directions with a fresh C++ FRC template, but I’m getting errors. In the extensions, I have what I believe I need for compiling C++, but still no luck.

Any help would be appreciated. Thanks!

Any specifics on the issues? It should be able to work just fine. If not I may need to add the libraries and cross compilers to the path variable. FYI My current install downloads the extension and unpacks it in /opt. The same concept can be used for the full wpilib tar.gz

I suspect that the problem is that the roborio cross compiler isn’t installed by the extension, and so needs to be installed.

2 Likes

Likewise, it’s not that hard to fix too. Just need to put them in /usr/local/bin and /usr/share/include and /usr/local/share/lib i think

You should be able to run ./gradlew installRoboRioToolchain to install a toolchain for GradleRIO to use

1 Like

The error says I need to run ./gradlew installRoboRioToolchain, but that doesn’t appear to fix the issue. You mentioned

put them in /usr/local/bin and /usr/share/include and /usr/local/share/lib

What should I put in there? I’m just getting started with this WPlib, and I haven’t tried to get it working on Linux yet. I’ll google a bit and try to get more info on that, while I tinker.

1 Like