Skip to content
Closed
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
13 changes: 6 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tbots CI

on:
push:
branches: [ master ]
branches: [ master, robocup_* ]
pull_request:
branches: [ master ]
branches: [ master, robocup_* ]
schedule:
- cron: '0 8 * * *' # 12 AM PST / 8 AM UTC
workflow_dispatch:
Expand Down Expand Up @@ -151,16 +151,15 @@ jobs:
- uses: ./.github/actions/environment-setup

- name: Simulated Test Run
# TODO (#2908): reenable once field tests can be ran as simulated
# //software/gameplay_tests/... \
run: |
cd src
bazel test //software/gameplay_tests:requirements_test
bazel test --copt=-O3 --flaky_test_attempts=3 --show_timestamps \
--test_arg="--ci_mode" \
-- //software:unix_full_system \
--test_arg="--ci_mode" \
-- //software:unix_full_system \
-//software/gameplay_tests:requirements_test \
//software/ai/hl/... \
//software/simulation/... \
//software/ai/hl/... \
//software/ai/navigator/...

- name: Upload simulated test proto logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: auto-fixes with pre-commit

on:
push:
branches: [ master ]
branches: [ master, robocup_* ]
pull_request:
branches: [ master ]
branches: [ master, robocup_* ]
types: [ opened, reopened, synchronize, ready_for_review ]

concurrency:
Expand Down
22 changes: 0 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,6 @@ src/external/external
*.log
*.csv

### Node ###

# Dependencies
*node_modules

# Testing
*coverage
*.lcov

# Production
*build
*dist

# Node error log
*npm-debug.log*
*yarn-debug.log*
*yarn-error.log*

# Checksum
*.checksum


### Default C++ gitignore ###

# Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion environment_setup/setup_software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ host_software_packages=(
libffi-dev # needed to use _ctypes in Python3
libssl-dev # needed to build Python 3 with ssl support
openssl # possibly also necessary for ssl in Python 3
sshpass #used to remotely ssh into robots via Ansible
sshpass # used to remotely ssh into robots via Ansible
unzip # installing tigers autoref
xvfb # used for CI to run GUI applications
)
Expand Down
12 changes: 9 additions & 3 deletions environment_setup/setup_software_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ host_software_packages=(
node@20
go@1.24
clang-format@20
sshpass # used to remotely ssh into robots via Ansible
messense/macos-cross-toolchains/aarch64-unknown-linux-gnu # raspberry pi cross compiler
)

for pkg in "${host_software_packages[@]}"; do
Expand Down Expand Up @@ -72,9 +74,13 @@ print_status_msg "Install clang-format"
install_clang_format $sys
print_status_msg "Done installing clang-format"

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 PlatformIO"
sudo ln -s /opt/tbotspython/bin/platformio /usr/local/bin/platformio
print_status_msg "Done PlatformIO Setup"

print_status_msg "Setting up STM32 cross-compiler for motor board firmware"
install_stm32_cross_compiler $sys
print_status_msg "Done setting up STM32 cross-compiler"

print_status_msg "Setting Up Python Development Headers"
install_python_toolchain_headers
Expand Down
32 changes: 13 additions & 19 deletions environment_setup/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,14 @@ install_clang_format() {

install_cross_compiler() {
file_name=aarch64-tbots-linux-gnu-for-aarch64
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
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
}

install_gamecontroller () {
Expand Down Expand Up @@ -127,14 +118,17 @@ install_python_dev_cross_compile_headers() {

install_stm32_cross_compiler() {
arch="aarch64"
if is_x86 $1; then
if is_darwin $1; then
arch="darwin-arm64"
elif is_x86 $1; then
arch="x86_64"
fi
download_link=https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi.tar.xz
toolchain_name=arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi
download_link=https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/${toolchain_name}.tar.xz

wget -N $download_link -O /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
tar -xf /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi /opt/tbotspython/arm-none-eabi-gcc
sudo mv /tmp/tbots_download_cache/${toolchain_name} /opt/tbotspython/arm-none-eabi-gcc
rm /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
}

Expand Down
11 changes: 9 additions & 2 deletions src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module(
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "rules_pkg", version = "1.1.0")
bazel_dep(name = "rules_foreign_cc", version = "0.14.0")
bazel_dep(name = "rules_python", version = "1.4.1")
Expand Down Expand Up @@ -219,7 +219,7 @@ git_repository(
name = "mdv6_firmware",
build_file = "@//extlibs:mdv6_firmware.bzl",
# Pinning to the exact commit guarantees Bazel will rebuild when this commit SHA is updated
commit = "7657fb1c63bccd506196c42ff1720928314977c7", # latest commit on master branch
commit = "4341d96e9be1cb01f10d52f7e80326b84dbfb4ea", # latest commit on master branch
remote = "https://github.com/UBC-Thunderbots/MDv6_Firmware.git",
)

Expand Down Expand Up @@ -250,6 +250,7 @@ register_toolchains(
)

register_toolchains(
"//toolchains/cc:cc_toolchain_for_macos_robot",
"//toolchains/cc:cc_toolchain_for_k8_aarch64_linux",
"//toolchains/cc:cc_toolchain_for_k8",
"//toolchains/cc:cc_toolchain_for_aarch64",
Expand Down Expand Up @@ -286,6 +287,12 @@ new_local_repository(
path = "/opt/tbotspython/aarch64-tbots-linux-gnu/",
)

new_local_repository(
name = "macos_robot_gcc",
build_file = "@//extlibs:macos_robot_gcc.BUILD",
path = "/opt/homebrew/opt/aarch64-unknown-linux-gnu/toolchain/",
)

new_local_repository(
name = "motor_board_gcc",
build_file = "@//extlibs:motor_board_gcc.BUILD",
Expand Down
60 changes: 60 additions & 0 deletions src/cli/cli_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ class DebugBinary(str, Enum):
EnableThunderscopeOption = Annotated[bool, Option("-t", "--enable_thunderscope")]
StopAIOnStartOption = Annotated[bool, Option("-s", "--stop_ai_on_start")]

TestModeOption = Annotated[
bool,
Option(
"--test_mode",
help="Launch Thunderscope with a widget to select and run gameplay tests",
),
]
RunFieldTestOption = Annotated[
bool,
Option(
"--run_field_test",
help="In test mode, run field tests instead of simulated tests",
),
]

JobsOption = Annotated[str, Option("-j", "--jobs")]
RunsOption = Annotated[
int,
Expand Down Expand Up @@ -166,6 +181,30 @@ class DebugBinary(str, Enum):
title="Diagnostics",
description="Run Thunderscope in diagnostics mode against real robots",
),
questionary.Choice(
title="Run blue",
description="run_blue",
),
questionary.Choice(
title="Run yellow",
description="run_yellow",
),
questionary.Choice(
title="Tests",
description="Launch with a widget to select and run gameplay tests",
),
]

# Thunderscope test mode "Test type?" menu.
TEST_TYPE_CHOICES = [
questionary.Choice(
title="Simulated tests",
description="Run gameplay tests against the simulator",
),
questionary.Choice(
title="Field tests",
description="Run gameplay tests against real robots (requires an interface)",
),
]

# Thunderscope simulator "Options:" checkbox.
Expand All @@ -192,6 +231,20 @@ class DebugBinary(str, Enum):
),
]

# Deploy robot software "Options:" checkbox. Each option compiles Thunderloop
# with a preprocessor flag that disables the corresponding service, letting
# Thunderloop run on a robot whose powerboard or motorboard is unavailable.
DEPLOY_ROBOT_SOFTWARE_OPTION_CHOICES = [
questionary.Choice(
title="DISABLE_POWER_SERVICE",
description="Compile Thunderloop without the Power Service (no powerboard)",
),
questionary.Choice(
title="DISABLE_MOTOR_SERVICE",
description="Compile Thunderloop without the Motor Service (no motorboard)",
),
]

# Marker value returned by the DEBUG_POWERLOOP playbook choice. It maps to the
# deploy_powerboard.yml playbook but additionally compiles powerloop_main with
# the DEBUG_POWERLOOP flag, swapping in bare setup()/loop() stubs so arbitrary
Expand Down Expand Up @@ -222,3 +275,10 @@ class DebugBinary(str, Enum):
description="Flash the motor controller firmware",
),
]


THUNDERSCOPE_OPTIONS_MAP = {
"Diagnostics": "run_diagnostics",
"Run blue": "run_blue",
"Run yellow": "run_yellow",
}
6 changes: 6 additions & 0 deletions src/extlibs/macos_robot_gcc.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])

filegroup(
name = "everything",
srcs = glob(["**"]),
)
6 changes: 3 additions & 3 deletions src/proto/message_translation/tbots_protobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ std::optional<TrajectoryPath> createTrajectoryPathFromParams(
return std::nullopt;
}

KinematicConstraints constraints(max_speed,
robot_constants.robot_max_acceleration_m_per_s_2,
robot_constants.robot_max_deceleration_m_per_s_2);
KinematicConstraints constraints(
max_speed, robot_constants.robot_trajectory_max_acceleration_m_per_s_2,
robot_constants.robot_trajectory_max_deceleration_m_per_s_2);

Point initial_destination = createPoint(params.destination());
if (!params.sub_destinations().empty())
Expand Down
6 changes: 3 additions & 3 deletions src/proto/message_translation/tbots_protobuf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ TEST_P(TrajectoryParamConversionTest, trajectory_params_msg_test)
TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT;
double max_speed = convertMaxAllowedSpeedModeToMaxAllowedSpeed(max_allowed_speed_mode,
robot_constants);
KinematicConstraints constraints(max_speed,
robot_constants.robot_max_acceleration_m_per_s_2,
robot_constants.robot_max_deceleration_m_per_s_2);
KinematicConstraints constraints(
max_speed, robot_constants.robot_trajectory_max_acceleration_m_per_s_2,
robot_constants.robot_trajectory_max_deceleration_m_per_s_2);

Point initial_destination = destination;
if (!sub_destinations.empty())
Expand Down
4 changes: 2 additions & 2 deletions src/shared/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cc_library(

cc_library(
name = "robot_constants",
srcs = [],
hdrs = [":robot_constants.h"],
srcs = ["robot_constants.cpp"],
hdrs = ["robot_constants.h"],
deps = [":constants"],
)
31 changes: 26 additions & 5 deletions src/shared/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ static const std::unordered_map<int, std::string> ROBOT_MULTICAST_CHANNELS = {
{12, "ff02::c3d0:42d2:bb12"}, {13, "ff02::c3d0:42d2:bb13"},
{14, "ff02::c3d0:42d2:bb14"}, {15, "ff02::c3d0:42d2:bb15"}};

// the name of the loopback network interface, which differs across platforms
#ifdef __APPLE__
static const std::string LOOPBACK_INTERFACE = "lo0";
#else
static const std::string LOOPBACK_INTERFACE = "lo";
#endif

// PlotJuggler's default host and port
static const std::string PLOTJUGGLER_GUI_DEFAULT_HOST = "ff02::c3d0:42d2:aaaa";
static const short unsigned int PLOTJUGGLER_GUI_DEFAULT_PORT = 9870;
Expand Down Expand Up @@ -213,17 +220,31 @@ static const unsigned int NUM_TIMES_SEND_STOP = 10;
// disconnected
static const double DISCONNECT_DURATION_MS = 1 * MILLISECONDS_PER_SECOND;

// product and vendor id for Arduino Uno Rev3 (retrieved from
// http://www.linux-usb.org/usb.ids )
#define ARDUINO_ID_LENGTH 5
static const char ARDUINO_VENDOR_ID[ARDUINO_ID_LENGTH] = "2341";
static const char ARDUINO_PRODUCT_ID[ARDUINO_ID_LENGTH] = "0043";
// Vendor and product id pairs for the USB-to-serial adapters used by the
// physical estop. Multiple pairs are supported since estop units may use
// different adapters. IDs retrieved from http://www.linux-usb.org/usb.ids
struct EstopUsbId
{
const char* vendor_id;
const char* product_id;
};

constexpr EstopUsbId ESTOP_USB_DEVICE_IDS[] = {
{"2341", "0043"}, // Arduino Uno Rev3
{"1a86", "7523"}, // CH340-based Arduino clones
};

constexpr int NUM_ESTOP_USB_DEVICE_IDS =
sizeof(ESTOP_USB_DEVICE_IDS) / sizeof(ESTOP_USB_DEVICE_IDS[0]);

// Number of times thunderloop should tick per second
static const unsigned THUNDERLOOP_HZ = 300u;

static const unsigned NUM_GENEVA_ANGLES = 5;


static constexpr double RTT_S = 0.03;

// Robot diagnostics constants
constexpr double AUTO_CHIP_DISTANCE_DEFAULT_M = 1.5;
constexpr double AUTO_KICK_SPEED_DEFAULT_M_PER_S = 1.5;
Expand Down
Loading