Skip to content

Conversation

@Lmh-java
Copy link
Contributor

@Lmh-java Lmh-java commented Sep 21, 2025

closes #3529

Description

This PR introduces native macOS ARM support for Thunderscope.

Currently, this PR is experimental and is just providing a minimal working demo on my macbook M1.

Out of scope for this PR:

  1. Cross-compilation and robot hardware interactions
  2. Support for Intel (x86) MacBooks

Testing Done

  • Run extensive tests on additional macOS ARM machines. My current laptop includes many pre-installed developer tools, so the setup script may need updates to ensure a clean installation experience.
  • Verify functionality on Ubuntu machines to confirm no regressions were introduced.

TODO List

For this PR:

  • Open issues for any newly identified TODO items
  • Fix the broken local_new_repositories and confirm compatibility with Ubuntu
  • Separate linux and macos requirements lock files, because evdev does not exist for macos.

Maybe for future PRs or possibly this PR:

  • If necessary, re-implement handheld controller widgets using a macOS-compatible library
  • Deduplicate TbotsProto.ObstacleList to prevent system network buffer overload (TrajectoryPlanner improvements #3104). This is impacting the stability of thunderscope on macOS. I am currently working on a sliding window cache that hopefully can mitigate this issue.

@Lmh-java Lmh-java force-pushed the lmh/macos-support-new branch 2 times, most recently from 3ca31a1 to c308ffb Compare October 18, 2025 18:51
@Lmh-java Lmh-java changed the title [DRAFT] Add macOS ARM support for Thunderscope Add macOS ARM support for Thunderscope Oct 18, 2025
Comment on lines 93 to 103
install_java_macos () {
java_home=""
java_download=https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz
curl -L $java_download -o /tmp/tbots_download_cache/jdk-21.tar.gz
mkdir /tmp/tbots_download_cache/jdk
tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /tmp/tbots_download_cache
sudo mv /tmp/tbots_download_cache/jdk-21*/Contents/Home /opt/tbotspython/bin/jdk
rm /tmp/tbots_download_cache/jdk-21.tar.gz
rm -rf /tmp/tbots_download_cache/jdk
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java Installed already from brew, I don't think we need this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a specific version of Java for autoref (Java 21)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you're using the autoref binary package, so you can probably ignore this

Copy link
Contributor

@itsarune itsarune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments

Comment on lines 93 to 103
install_java_macos () {
java_home=""
java_download=https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz
curl -L $java_download -o /tmp/tbots_download_cache/jdk-21.tar.gz
mkdir /tmp/tbots_download_cache/jdk
tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /tmp/tbots_download_cache
sudo mv /tmp/tbots_download_cache/jdk-21*/Contents/Home /opt/tbotspython/bin/jdk
rm /tmp/tbots_download_cache/jdk-21.tar.gz
rm -rf /tmp/tbots_download_cache/jdk
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you're using the autoref binary package, so you can probably ignore this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using uname -s for "Darwin" and merge into the non-mac version of these functions to reduce clutter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make sure you're using the same c++ compuler version as Ubuntu (to minimize the number of c++ compatibility changes that are needed)

requirement("evdev"),
],
] + select({
# TODO: remove this selection when we replace evdev to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag an issue with the TODO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was the first thing we have tried, but it breaks the dependency tree because other targets depending one this are all marked incompatible. I will do more test on this.

@Lmh-java Lmh-java force-pushed the lmh/macos-support-new branch from c308ffb to d6b303d Compare November 15, 2025 19:28

import evdev
from evdev import ecodes
# TODO: remove the try-catch when we rewrite this with macOS-compatible lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/.bazelrc Outdated
# Escalate Warnings to fail Compile for Thunderbots code
build --features=external_include_paths
build --per_file_copt=proto/.*,proto/message_translation/.*,proto/primitive/.*,software/.*,shared/.*,-external/.*@-Wall,-Wextra,-Wno-unused-parameter,-Wno-deprecated,-Werror,-Wno-deprecated-declarations
build:linux --features=external_include_paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally these flags would also work on macos

Copy link
Contributor Author

@Lmh-java Lmh-java Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, ideally it should also work on macos, but because the macos clang compiler is stricter than linux and reports millions of new errors (converted from warnings). :(

Copy link
Contributor

@itsarune itsarune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

@Andrewyx
Copy link
Contributor

Left some comments

I think we are getting close w/ getting this working, I put in a PR last week to hopefully reconcile some bazel hermiticity issues and we'll run a test this week to check if it actually works on anyone else's machines aside from minghao's.

qt@6
node@20
[email protected]
clang-format@20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note, we did switch to clang-format-14 in #3499 which affects the formatting

@nycrat
Copy link
Member

nycrat commented Dec 3, 2025

Just a note, I did get this working on my m1 macbook as well. I did however have to resolve some c++ compatibility issues, and also update the package required for bazel refresh_compile_commands to resolve a bug. I'm not sure if these issues were also present on your macbook?

We should definitely test some time with a clean install, and to test all scripts and commands that we want to support for mac to make sure they also work.

@Lmh-java Lmh-java marked this pull request as ready for review December 6, 2025 19:06
@Lmh-java Lmh-java requested a review from Andrewyx as a code owner December 6, 2025 19:06
@Lmh-java
Copy link
Contributor Author

Lmh-java commented Dec 6, 2025

@nycrat
Yes, we have seen this resolve some c++ compatibility issues on Annie's laptop as well, and I have the same fix.

Personally, I dont use the refresh_compile_commands. That's a great catch. I think it is less likely to affect ubuntu users by just updating the version. I will cherry-pick your commit onto this.

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.

Explore M1 series macOS native support

5 participants