Skip to content

Commit 7bb3ccc

Browse files
committed
merged
2 parents 448a17d + 5652e04 commit 7bb3ccc

34 files changed

Lines changed: 427 additions & 198 deletions

.gitignore

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,6 @@ src/external/external
6060
*.log
6161
*.csv
6262

63-
### Node ###
64-
65-
# Dependencies
66-
*node_modules
67-
68-
# Testing
69-
*coverage
70-
*.lcov
71-
72-
# Production
73-
*build
74-
*dist
75-
76-
# Node error log
77-
*npm-debug.log*
78-
*yarn-debug.log*
79-
*yarn-error.log*
80-
81-
# Checksum
82-
*.checksum
83-
84-
8563
### Default C++ gitignore ###
8664

8765
# Prerequisites

environment_setup/setup_software.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ host_software_packages=(
7575
libffi-dev # needed to use _ctypes in Python3
7676
libssl-dev # needed to build Python 3 with ssl support
7777
openssl # possibly also necessary for ssl in Python 3
78-
sshpass #used to remotely ssh into robots via Ansible
78+
sshpass # used to remotely ssh into robots via Ansible
7979
unzip # installing tigers autoref
8080
xvfb # used for CI to run GUI applications
8181
)

environment_setup/setup_software_mac.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ host_software_packages=(
3232
node@20
3333
go@1.24
3434
clang-format@20
35+
sshpass # used to remotely ssh into robots via Ansible
36+
messense/macos-cross-toolchains/aarch64-unknown-linux-gnu # raspberry pi cross compiler
3537
)
3638

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

75-
print_status_msg "Setting up cross compiler for robot software"
76-
install_cross_compiler $sys
77-
print_status_msg "Done setting up cross compiler for robot software"
77+
print_status_msg "Setting Up PlatformIO"
78+
sudo ln -s /opt/tbotspython/bin/platformio /usr/local/bin/platformio
79+
print_status_msg "Done PlatformIO Setup"
80+
81+
print_status_msg "Setting up STM32 cross-compiler for motor board firmware"
82+
install_stm32_cross_compiler $sys
83+
print_status_msg "Done setting up STM32 cross-compiler"
7884

7985
print_status_msg "Setting Up Python Development Headers"
8086
install_python_toolchain_headers

environment_setup/util.sh

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,14 @@ install_clang_format() {
3838

3939
install_cross_compiler() {
4040
file_name=aarch64-tbots-linux-gnu-for-aarch64
41-
if is_darwin $1; then
42-
full_file_name=$file_name.tar.xz
43-
curl -L "https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name" \
44-
-o /tmp/tbots_download_cache/$full_file_name
45-
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
46-
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
47-
rm /tmp/tbots_download_cache/$full_file_name
48-
else
49-
if is_x86 $1; then
50-
file_name=aarch64-tbots-linux-gnu-for-x86
51-
fi
52-
full_file_name=$file_name.tar.xz
53-
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
54-
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
55-
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
56-
rm /tmp/tbots_download_cache/$full_file_name
41+
if is_x86 $1; then
42+
file_name=aarch64-tbots-linux-gnu-for-x86
5743
fi
44+
full_file_name=$file_name.tar.xz
45+
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
46+
tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/
47+
sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython
48+
rm /tmp/tbots_download_cache/$full_file_name
5849
}
5950

6051
install_gamecontroller () {
@@ -127,14 +118,17 @@ install_python_dev_cross_compile_headers() {
127118

128119
install_stm32_cross_compiler() {
129120
arch="aarch64"
130-
if is_x86 $1; then
121+
if is_darwin $1; then
122+
arch="darwin-arm64"
123+
elif is_x86 $1; then
131124
arch="x86_64"
132125
fi
133-
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
126+
toolchain_name=arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi
127+
download_link=https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/${toolchain_name}.tar.xz
134128

135129
wget -N $download_link -O /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
136130
tar -xf /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz -C /tmp/tbots_download_cache/
137-
sudo mv /tmp/tbots_download_cache/arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi /opt/tbotspython/arm-none-eabi-gcc
131+
sudo mv /tmp/tbots_download_cache/${toolchain_name} /opt/tbotspython/arm-none-eabi-gcc
138132
rm /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
139133
}
140134

src/MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ register_toolchains(
250250
)
251251

252252
register_toolchains(
253+
"//toolchains/cc:cc_toolchain_for_macos_robot",
253254
"//toolchains/cc:cc_toolchain_for_k8_aarch64_linux",
254255
"//toolchains/cc:cc_toolchain_for_k8",
255256
"//toolchains/cc:cc_toolchain_for_aarch64",
@@ -286,6 +287,12 @@ new_local_repository(
286287
path = "/opt/tbotspython/aarch64-tbots-linux-gnu/",
287288
)
288289

290+
new_local_repository(
291+
name = "macos_robot_gcc",
292+
build_file = "@//extlibs:macos_robot_gcc.BUILD",
293+
path = "/opt/homebrew/opt/aarch64-unknown-linux-gnu/toolchain/",
294+
)
295+
289296
new_local_repository(
290297
name = "motor_board_gcc",
291298
build_file = "@//extlibs:motor_board_gcc.BUILD",

src/extlibs/macos_robot_gcc.BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
filegroup(
4+
name = "everything",
5+
srcs = glob(["**"]),
6+
)

src/shared/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cc_library(
2222

2323
cc_library(
2424
name = "robot_constants",
25-
srcs = [],
26-
hdrs = [":robot_constants.h"],
25+
srcs = ["robot_constants.cpp"],
26+
hdrs = ["robot_constants.h"],
2727
deps = [":constants"],
2828
)

src/shared/constants.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ static const std::unordered_map<int, std::string> ROBOT_MULTICAST_CHANNELS = {
2222
{12, "ff02::c3d0:42d2:bb12"}, {13, "ff02::c3d0:42d2:bb13"},
2323
{14, "ff02::c3d0:42d2:bb14"}, {15, "ff02::c3d0:42d2:bb15"}};
2424

25+
// the name of the loopback network interface, which differs across platforms
26+
#ifdef __APPLE__
27+
static const std::string LOOPBACK_INTERFACE = "lo0";
28+
#else
29+
static const std::string LOOPBACK_INTERFACE = "lo";
30+
#endif
31+
2532
// PlotJuggler's default host and port
2633
static const std::string PLOTJUGGLER_GUI_DEFAULT_HOST = "ff02::c3d0:42d2:aaaa";
2734
static const short unsigned int PLOTJUGGLER_GUI_DEFAULT_PORT = 9870;
@@ -213,11 +220,22 @@ static const unsigned int NUM_TIMES_SEND_STOP = 10;
213220
// disconnected
214221
static const double DISCONNECT_DURATION_MS = 1 * MILLISECONDS_PER_SECOND;
215222

216-
// product and vendor id for Arduino Uno Rev3 (retrieved from
217-
// http://www.linux-usb.org/usb.ids )
218-
#define ARDUINO_ID_LENGTH 5
219-
static const char ARDUINO_VENDOR_ID[ARDUINO_ID_LENGTH] = "2341";
220-
static const char ARDUINO_PRODUCT_ID[ARDUINO_ID_LENGTH] = "0043";
223+
// Vendor and product id pairs for the USB-to-serial adapters used by the
224+
// physical estop. Multiple pairs are supported since estop units may use
225+
// different adapters. IDs retrieved from http://www.linux-usb.org/usb.ids
226+
struct EstopUsbId
227+
{
228+
const char* vendor_id;
229+
const char* product_id;
230+
};
231+
232+
constexpr EstopUsbId ESTOP_USB_DEVICE_IDS[] = {
233+
{"2341", "0043"}, // Arduino Uno Rev3
234+
{"1a86", "7523"}, // CH340-based Arduino clones
235+
};
236+
237+
constexpr int NUM_ESTOP_USB_DEVICE_IDS =
238+
sizeof(ESTOP_USB_DEVICE_IDS) / sizeof(ESTOP_USB_DEVICE_IDS[0]);
221239

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

src/shared/robot_constants.cpp

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#include "shared/robot_constants.h"
2+
3+
#include "shared/constants.h"
4+
5+
namespace robot_constants
6+
{
7+
8+
#if CHECK_VERSION(2026)
9+
RobotConstants createRobotConstants()
10+
{
11+
return {
12+
.robot_radius_m = static_cast<float>(ROBOT_MAX_RADIUS_METERS),
13+
.front_wheel_angle_deg = 32.0f,
14+
.back_wheel_angle_deg = 44.0f,
15+
16+
.fr_x_pos_meters = 0.03485f,
17+
.fr_y_pos_meters = -0.06632f,
18+
.fl_x_pos_meters = 0.03485f,
19+
.fl_y_pos_meters = 0.06632f,
20+
.bl_x_pos_meters = -0.04985f,
21+
.bl_y_pos_meters = 0.05592f,
22+
.br_x_pos_meters = -0.04985f,
23+
.br_y_pos_meters = -0.05592f,
24+
25+
.front_of_robot_width_meters = 0.11f,
26+
.dribbler_width_meters = 0.07825f,
27+
28+
// Dribbler speeds are negative as that is the direction that sucks the ball in
29+
.indefinite_dribbler_speed_rpm = -10000,
30+
.max_force_dribbler_speed_rpm = -12000,
31+
32+
// Motor constant
33+
.motor_max_acceleration_m_per_s_2 = 4.5f,
34+
35+
// Robot's linear movement constants
36+
.robot_max_speed_m_per_s = 3.0f,
37+
.robot_trajectory_max_speed_m_per_s = 2.5f,
38+
39+
.robot_max_acceleration_m_per_s_2 = 4.5f,
40+
.robot_max_deceleration_m_per_s_2 = 3.0f,
41+
42+
.robot_trajectory_max_acceleration_m_per_s_2 = 3.0f,
43+
.robot_trajectory_max_deceleration_m_per_s_2 = 2.0f,
44+
45+
// Robot's angular movement constants
46+
.robot_max_ang_speed_rad_per_s = 10.0f,
47+
.robot_trajectory_max_ang_speed_rad_per_s = 7.0f,
48+
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
49+
50+
.wheel_radius_meters = 0.03f,
51+
52+
.expected_lever_arm = 0.0749f,
53+
54+
// Kalman filter variances for robot localizer
55+
.kalman_process_noise_variance_rad_per_s_4 = 1.0f,
56+
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
57+
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5f};
58+
}
59+
#elif CHECK_VERSION(2021)
60+
constexpr RobotConstants createRobotConstants()
61+
{
62+
return {
63+
.robot_radius_m = static_cast<float>(ROBOT_MAX_RADIUS_METERS),
64+
.front_wheel_angle_deg = 32.06f,
65+
.back_wheel_angle_deg = 46.04f,
66+
67+
.front_of_robot_width_meters = 0.11f,
68+
.dribbler_width_meters = 0.07825f,
69+
70+
// Dribbler speeds are negative as that is the direction that sucks the ball in
71+
.indefinite_dribbler_speed_rpm = -10000,
72+
.max_force_dribbler_speed_rpm = -12000,
73+
74+
// Motor constant
75+
.motor_max_acceleration_m_per_s_2 = 4.5f,
76+
77+
// Robot's linear movement constants
78+
.robot_max_speed_m_per_s = 3.000f,
79+
.robot_trajectory_max_speed_m_per_s = 3.000f,
80+
.robot_max_acceleration_m_per_s_2 = 3.0f,
81+
.robot_max_deceleration_m_per_s_2 = 3.0f,
82+
.robot_trajectory_max_acceleration_m_per_s_2 = 3.0f,
83+
.robot_trajectory_max_deceleration_m_per_s_2 = 3.0f,
84+
85+
// Robot's angular movement constants
86+
.robot_max_ang_speed_rad_per_s = 10.0f,
87+
.robot_trajectory_max_ang_speed_rad_per_s = 7.0f,
88+
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
89+
90+
.wheel_radius_meters = 0.03f,
91+
92+
// Kalman filter variances for robot localizer
93+
.kalman_process_noise_variance_rad_per_s_4 = 0.5f,
94+
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
95+
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5f * 0.5f};
96+
}
97+
#endif
98+
99+
} // namespace robot_constants

0 commit comments

Comments
 (0)