Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ src/.clangd

# external is a special directory for bazel so it should be ignored
src/external

# macOS folder info
.DS_Store

13 changes: 13 additions & 0 deletions environment_setup/macos_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ansible-lint==24.12.2
pyqtgraph==0.13.7
Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of these can be removed pending #3542 I think

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 will do a merge test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhh I think bazel has no problem with your PR, everything compiles. But PyQt6 conflicts still exist with the current commit 9fce33a1727218c76ee0e1b37ee26bbbd1d0a1e1. I would guess this issue is normal because you have not resolved this PyQt lib conflict in your branch yet?

Full Error message:

INFO: Running command line: bazel-bin/software/thunderscope/thunderscope_main
  ⚠ Conflicting symlinks found when attempting to create venv. More than one package provides the file at these paths
   ╭─[1:208]
 1 │ /private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/PyQt6/__init__.py
   ·                                                                                                                                                                                                                ───────────────┬───────────────
   ·                                                                                                                                                                                                                               ╰── Existing file in virtual environment
 2 │ /private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/rules_python++pip+thunderscope_deps_312_pyqt6/site-packages/PyQt6/__init__.py
   ·                                                                                                                                                                                                                       ───────────────┬───────────────
   ·                                                                                                                                                                                                                                      ╰── Next file to link
   ╰────
  help: Set `package_collisions = "ignore"` on the binary or test rule to ignore this warning

Traceback (most recent call last):
  File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/_main/software/thunderscope/thunderscope_main.py", line 18, in <module>
    from software.thunderscope.thunderscope import Thunderscope
  File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/_main/software/thunderscope/thunderscope.py", line 7, in <module>
    import pyqtgraph
  File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/__init__.py", line 18, in <module>
    from .colors import palette
  File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/colors/palette.py", line 1, in <module>
    from ..Qt import QtGui
  File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/Qt/__init__.py", line 57, in <module>
    raise ImportError("PyQtGraph requires one of PyQt5, PyQt6, PySide2 or PySide6; none of these packages could be imported.")
ImportError: PyQtGraph requires one of PyQt5, PyQt6, PySide2 or PySide6; none of these packages could be imported.

thefuzz==0.19.0
iterfzf==0.5.0.20.0
python-Levenshtein==0.25.1
psutil==5.9.0
PyOpenGL==3.1.6
ruff==0.5.5
pyqt-toast-notification==1.3.2
grpcio-tools==1.71.0
platformio==6.1.18
pyqt6==6.9.1

1 change: 1 addition & 0 deletions environment_setup/setup_software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ print_status_msg "Done setting up cross compiler for robot software"

print_status_msg "Setting Up Python Development Headers"
install_python_dev_cross_compile_headers $g_arch
install_python_toolchain_headers
print_status_msg "Done Setting Up Python Development Headers"

print_status_msg "Setting Up PlatformIO"
Expand Down
90 changes: 90 additions & 0 deletions environment_setup/setup_software_mac.sh
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)

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# UBC Thunderbots macOS Software Setup
#
# This script will install all required libraries and dependencies to build
# and run the Thunderbots codebase on macOS, including the AI and unit tests.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

# Save the parent dir of this script
CURR_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "$CURR_DIR" || exit

source util.sh

# Since we only support MacOS Arm chips (M series), we can use "Darwin" as the identifier
# for mac setup procedures and ignore the architecture for now.
sys=$(uname -s)

print_status_msg "Installing Utilities and Dependencies"

# Update Homebrew
brew update

# Install required packages
host_software_packages=(
cmake@4
python@3.12
bazelisk
openjdk@21
pyqt@6
qt@6
node@20
go@1.24
clang-format@20
)

for pkg in "${host_software_packages[@]}"; do
if ! brew list "$pkg" &>/dev/null; then
print_status_msg "Installing $pkg..."
brew install "$pkg"
else
print_status_msg "$pkg already installed, skipping..."
fi
done

# Set up cache
mkdir /tmp/tbots_download_cache

# Set up Python
print_status_msg "Setting Up Python Environment"

# Create virtual environment
sudo python3.12 -m venv /opt/tbotspython
chmod
source /opt/tbotspython/bin/activate

# Install Python dependencies
sudo pip install --upgrade pip
sudo pip install -r macos_requirements.txt

print_status_msg "Done Setting Up Python Environment"

print_status_msg "Fetching game controller"
install_gamecontroller $sys

print_status_msg "Setting up TIGERS AutoRef"
install_autoref $sys
sudo chmod +x "$CURR_DIR/../src/software/autoref/run_autoref.sh"
sudo cp "$CURR_DIR/../src/software/autoref/DIV_B.txt" "/opt/tbotspython/autoReferee/config/geometry/DIV_B.txt"
print_status_msg "Finished setting up AutoRef"

print_status_msg "Setting up cross compiler for robot software"
install_cross_compiler $sys
print_status_msg "Done setting up cross compiler for robot software"

print_status_msg "Setting Up Python Development Headers"
install_python_toolchain_headers
print_status_msg "Done Setting Up Python Development Headers"

print_status_msg "Granting Permissions to /opt/tbotspython"
sudo chown -R $(id -u):$(id -g) /opt/tbotspython
print_status_msg "Done Granting Permissions to /opt/tbotspython"

print_status_msg "Set up ansible-lint"
/opt/tbotspython/bin/ansible-galaxy collection install ansible.posix
print_status_msg "Finished setting up ansible-lint"

print_status_msg "Software Setup Complete"
print_status_msg "Note: Some changes require a new terminal session to take effect"

84 changes: 64 additions & 20 deletions environment_setup/util.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
install_autoref() {
autoref_commit=b30660b78728c3ce159de8ae096181a1ec52e9ba
wget -N https://github.com/TIGERs-Mannheim/AutoReferee/archive/${autoref_commit}.zip -O /tmp/tbots_download_cache/autoReferee.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip
if is_darwin $1; then
autoref_version=1.5.5
curl -L https://github.com/TIGERs-Mannheim/AutoReferee/releases/download/${autoref_version}/autoReferee.zip -o /tmp/tbots_download_cache/autoReferee.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip

/tmp/tbots_download_cache/AutoReferee-${autoref_commit}/./gradlew installDist -p /tmp/tbots_download_cache/AutoReferee-${autoref_commit} -Dorg.gradle.java.home=/opt/tbotspython/bin/jdk
mv /tmp/tbots_download_cache/AutoReferee-${autoref_commit}/build/install/autoReferee /opt/tbotspython/
rm -rf /tmp/tbots_download_cache/autoReferee.zip /tmp/tbots_download_cache/AutoReferee-${autoref_commit}
sudo mv /tmp/tbots_download_cache/autoReferee /opt/tbotspython/
rm -rf /tmp/tbots_download_cache/autoReferee.zip
else
autoref_commit=b30660b78728c3ce159de8ae096181a1ec52e9ba
wget -N https://github.com/TIGERs-Mannheim/AutoReferee/archive/${autoref_commit}.zip -O /tmp/tbots_download_cache/autoReferee.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip

/tmp/tbots_download_cache/AutoReferee-${autoref_commit}/./gradlew installDist -p /tmp/tbots_download_cache/AutoReferee-${autoref_commit} -Dorg.gradle.java.home=/opt/tbotspython/bin/jdk
mv /tmp/tbots_download_cache/AutoReferee-${autoref_commit}/build/install/autoReferee /opt/tbotspython/
rm -rf /tmp/tbots_download_cache/autoReferee.zip /tmp/tbots_download_cache/AutoReferee-${autoref_commit}
fi
}

install_bazel() {
Expand All @@ -25,25 +34,47 @@ install_clang_format() {

install_cross_compiler() {
file_name=aarch64-tbots-linux-gnu-for-aarch64
if is_x86 $1; then
file_name=aarch64-tbots-linux-gnu-for-x86
if is_darwin $1; then
full_file_name=$file_name.tar.xz
curl -L "https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name" \
-o /tmp/tbots_download_cache/$full_file_name
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
rm /tmp/tbots_download_cache/$full_file_name
else
if is_x86 $1; then
file_name=aarch64-tbots-linux-gnu-for-x86
fi
full_file_name=$file_name.tar.xz
wget https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name -O /tmp/tbots_download_cache/$full_file_name
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
rm /tmp/tbots_download_cache/$full_file_name
fi
full_file_name=$file_name.tar.xz
wget https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name -O /tmp/tbots_download_cache/$full_file_name
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
rm /tmp/tbots_download_cache/$full_file_name
}

install_gamecontroller () {
arch=arm64
if is_x86 $1; then
arch=amd64
fi
if is_darwin $1; then
curl -L https://github.com/RoboCup-SSL/ssl-game-controller/archive/refs/tags/v3.17.0.zip -o /tmp/tbots_download_cache/ssl-game-controller.zip
unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/ssl-game-controller.zip
cd /tmp/tbots_download_cache/ssl-game-controller-3.17.0
make install
go build cmd/ssl-game-controller/main.go
sudo mv main /opt/tbotspython/gamecontroller
sudo chmod +x /opt/tbotspython/gamecontroller

cd -
sudo rm -rf /tmp/tbots_download_cache/ssl-game-controller-3.17.0 /tmp/tbots_download_cache/go /tmp/tbots_download_cache/go.tar.gz /tmp/tbots_download_cache/ssl-game-controller.zip
else
arch=arm64
if is_x86 $1; then
arch=amd64
fi

wget https://github.com/RoboCup-SSL/ssl-game-controller/releases/download/v3.16.1/ssl-game-controller_v3.16.1_linux_${arch} -O /tmp/tbots_download_cache/gamecontroller
sudo mv /tmp/tbots_download_cache/gamecontroller /opt/tbotspython/gamecontroller
sudo chmod +x /opt/tbotspython/gamecontroller
wget https://github.com/RoboCup-SSL/ssl-game-controller/releases/download/v3.16.1/ssl-game-controller_v3.16.1_linux_${arch} -O /tmp/tbots_download_cache/gamecontroller
sudo mv /tmp/tbots_download_cache/gamecontroller /opt/tbotspython/gamecontroller
sudo chmod +x /opt/tbotspython/gamecontroller
fi
}

install_java () {
Expand Down Expand Up @@ -90,6 +121,11 @@ install_python_dev_cross_compile_headers() {
rm -rf /tmp/tbots_download_cache/python-3.12.0.tar.xz
}

install_python_toolchain_headers() {
sudo mkdir -p /opt/tbotspython/py_headers/include/
sudo ln -sfn "$(python3.12-config --includes | awk '{for(i=1;i<=NF;++i) if ($i ~ /^-I/) print substr($i, 3)}' | head -n1)" /opt/tbotspython/py_headers/include/
}

is_x86() {
if [[ $1 == "x86_64" ]]; then
return 0
Expand All @@ -98,6 +134,14 @@ is_x86() {
fi
}

is_darwin() {
if [[ $1 == "Darwin" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

very minor nit: add a comment here similar to line 15 in environment_setup/setup_software_mac.sh to explain what Darwin is

return 0
else
return 1
fi
}

print_status_msg () {
echo "================================================================"
echo $1
Expand Down
2 changes: 1 addition & 1 deletion src/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ build --incompatible_remove_legacy_whole_archive=False

# 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 --per_file_copt=proto/.*,proto/message_translation/.*,proto/primitive/.*,software/.*,shared/.*,-external/.*@-Wall,-Wextra,-Wno-unused-parameter,-Wno-deprecated,-Werror,-Wno-deprecated-declarations
# TODO: #3492
# build --per_file_copt=software/.*,shared/.*,-external/.*@-Wconversion

Expand Down
2 changes: 1 addition & 1 deletion src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ new_local_repository(
new_local_repository(
name = "py_cc_toolchain_host",
build_file = "@//extlibs:py_cc_toolchain.BUILD",
path = "/usr/include/python3.12/",
path = "/opt/tbotspython/py_headers/include/python3.12/",
)

new_local_repository(
Expand Down
5 changes: 3 additions & 2 deletions src/extlibs/er_force_sim/src/amun/simulator/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,13 @@ void Simulator::handleSimulatorSetupCommand(const std::unique_ptr<amun::Command>

if (realism.has_vision_delay())
{
m_visionDelay = std::max(0l, realism.vision_delay());
m_visionDelay = std::max<int64_t>(0l, realism.vision_delay());
}

if (realism.has_vision_processing_time())
{
m_visionProcessingTime = std::max(0l, realism.vision_processing_time());
m_visionProcessingTime =
std::max<int64_t>(0l, realism.vision_processing_time());
}

if (realism.has_simulate_dribbling())
Expand Down
3 changes: 2 additions & 1 deletion src/software/ai/hl/stp/play/play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ std::unique_ptr<TbotsProto::PrimitiveSet> Play::get(
new_primitives_to_assign->robot_primitives())
{
primitives_to_run->mutable_robot_primitives()->insert(
google::protobuf::MapPair(robot_id, primitive));
google::protobuf::MapPair<uint32_t, TbotsProto::Primitive>(
robot_id, primitive));
}

robots = remaining_robots;
Expand Down
14 changes: 13 additions & 1 deletion src/software/logger/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cc_library(
"log_merger.h",
],
deps = [
":compat_flags",
"@g3log",
],
)
Expand All @@ -19,9 +20,13 @@ cc_library(
"custom_logging_levels.h",
"logger.h",
],
linkopts = ["-lstdc++fs"],
linkopts = select({
"@platforms//os:linux": ["-lstdc++fs"],
"//conditions:default": [],
}),
deps = [
":coloured_cout_sink",
":compat_flags",
":csv_sink",
":log_merger",
":plotjuggler_sink",
Expand Down Expand Up @@ -103,6 +108,7 @@ cc_library(
"custom_logging_levels.h",
],
deps = [
":compat_flags",
"@g3log",
],
)
Expand Down Expand Up @@ -182,10 +188,16 @@ cc_library(
"proto_logger.h",
],
deps = [
":compat_flags",
"//proto:tbots_cc_proto",
"//software/multithreading:thread_safe_buffer",
"@base64",
"@boost//:filesystem",
"@zlib",
],
)

cc_library(
name = "compat_flags",
srcs = ["compat_flags.h"],
)
17 changes: 17 additions & 0 deletions src/software/logger/compat_flags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <chrono>

#if defined(__APPLE__)
using Clock = std::chrono::system_clock;
#else
using Clock = std::chrono::_V2::system_clock;
#endif

#if __cplusplus > 201703L
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
6 changes: 1 addition & 5 deletions src/software/logger/csv_sink.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "software/logger/csv_sink.h"

#if __cplusplus > 201703L
#include <filesystem>
#else
#include <experimental/filesystem>
#endif
#include "compat_flags.h"

CSVSink::CSVSink(const std::string& log_directory) : log_directory(log_directory) {}

Expand Down
6 changes: 2 additions & 4 deletions src/software/logger/log_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ std::list<g3::LogMessage> LogMerger::log(g3::LogMessage &log)
{
std::string msg = log.message();

std::chrono::_V2::system_clock::time_point current_time =
std::chrono::system_clock::now();
Clock::time_point current_time = std::chrono::system_clock::now();
// add passed time from testing
current_time += passed_time;
std::list<g3::LogMessage> messages_to_log = _getOldMessages(current_time);
Expand All @@ -38,8 +37,7 @@ std::list<g3::LogMessage> LogMerger::log(g3::LogMessage &log)
}
}

std::list<g3::LogMessage> LogMerger::_getOldMessages(
std::chrono::_V2::system_clock::time_point current_time)
std::list<g3::LogMessage> LogMerger::_getOldMessages(Clock::time_point current_time)
{
std::list<g3::LogMessage> result;
while (message_list.size() > 0)
Expand Down
Loading