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
11 changes: 6 additions & 5 deletions docs/useful-robot-commands.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Documentation/Testing (MD)

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [Robot Diagnostics](#robot-diagnostics)
- [For Just Diagnostics](#for-just-diagnostics)
- [For AI + Diagnostics](#for-ai--diagnostics)
- [Robot Auto Test](#robot-auto-test)
- [STSPIN Motor Controller Test](#stspin-motor-controller-test)
- [On Robot Commands](#on-robot-commands)
- [Systemd Services](#systemd-services)
- [Debugging Uart](#debugging-uart)
Expand Down Expand Up @@ -76,9 +76,10 @@ This will stop the current Systemd services, replace and restart them. Binaries
<b>This will trigger motor calibration meaning the wheels may spin. Please elevate the robot so the wheels are not touching the ground for proper calibration.</b>

```bash
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot -- --playbook deploy_robot_software.yml --hosts <robot_ip> --ssh_pass <robot_password>
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot --//software/embedded:motor_board=<motor_board> -- --playbook deploy_robot_software.yml --hosts <robot_ip> --ssh_pass <robot_password>
```

* <motor_board> is the type of motor driver board on the robot (either `STSPIN` or `TRINAMIC`)
* <robot_ip> is the IP address of the robot
* <robot_password> is the password of the `robot` user account

Expand Down Expand Up @@ -140,13 +141,13 @@ From Software/src

network_interface can be found with `ifconfig` commonly `wlp59s0` for wifi.

## Robot Auto Test
Runs the robot auto test fixture on a robot through Ansible, which tests the motor board and power board SPI and UART transfer respectively.
## STSPIN Motor Controller Test
Deploys the STSPIN Motor Controller Test binary onto a robot through Ansible.

From Software/src:

```bash
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot -- --playbook robot_auto_test_playbook.yml --hosts <robot_name> --ssh_pass <robot_password>
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot --//software/embedded:motor_board=STSPIN -- --playbook deploy_stspin_motor_controller_test.yml --hosts <robot_name> --ssh_pass <robot_password>
```

* replace the \<robot_ip\> with the actual ip address of the Raspberry Pi for the ssh connection.
Expand Down
7 changes: 7 additions & 0 deletions src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ http_archive(
url = "https://github.com/analogdevicesinc/TMC-API/archive/0cd695fab6d43ceb121af4b8608e5d92b14e1ce9.tar.gz",
)

http_archive(
Comment thread
GrayHoang marked this conversation as resolved.
name = "cppcrc",
build_file = "@//extlibs:cppcrc.BUILD",
strip_prefix = "cppcrc-6360eee1c8966d32b2552ce156b135ec6a3235f1",
url = "https://github.com/DarrenLevine/cppcrc/archive/6360eee1c8966d32b2552ce156b135ec6a3235f1.zip",
)

##############################################
# Register our Toolchains
##############################################
Expand Down
9 changes: 9 additions & 0 deletions src/extlibs/cppcrc.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Description:
Comment thread
GrayHoang marked this conversation as resolved.
# A very small, fast, header-only, C++ library for generating CRCs
# https://github.com/DarrenLevine/cppcrc/tree/main

cc_library(
name = "cppcrc",
hdrs = ["cppcrc.h"],
visibility = ["//visibility:public"],
)
31 changes: 24 additions & 7 deletions src/proto/robot_status_msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ enum ErrorCode

enum MotorFault
{
/*********** TMC Faults ************/
// Refer to Trinamic 6100 datasheet for precise definitions of motor faults.
// https://trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC6100_datasheet_Rev1.00.pdf
// (Section 5.1, p22-23)
Expand All @@ -99,6 +100,20 @@ enum MotorFault
PHASE_W_SHORT_COUNTER_DETECTED = 12;
PHASE_W_SHORT_TO_GND_DETECTED = 13;
PHASE_W_SHORT_TO_VS_DETECTED = 14;

/*********** STSPIN Faults ************/
Comment thread
GrayHoang marked this conversation as resolved.
NO_FAULT = 15;
DURATION = 16;
OVER_VOLT = 17;
UNDER_VOLT = 18;
OVER_TEMP = 19;
START_UP = 20;
SPEED_FDBK = 21;
OVER_CURR = 22;
SW_ERROR = 23;
SAMPLE_FAULT = 24;
OVERCURR_SW = 25;
DP_FAULT = 26;
Comment on lines +104 to +116
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kind of a hacky solution just appending these new fault types to our MotorFault enum. It would be better if we had separate enums for Trinamic vs. STSPIN faults

}

message DriveUnit
Expand All @@ -113,13 +128,15 @@ message DriveUnit
/* Data from all four drive units and the dribbler */
message MotorStatus
{
DriveUnit front_left = 1;
DriveUnit front_right = 2;
DriveUnit back_left = 3;
DriveUnit back_right = 4;
DribblerStatus dribbler = 5;
Vector local_velocity = 6;
AngularVelocity angular_velocity = 7;
DriveUnit front_left = 1;
DriveUnit front_right = 2;
DriveUnit back_left = 3;
DriveUnit back_right = 4;
DribblerStatus dribbler = 5;
Vector local_velocity = 6;
AngularVelocity angular_velocity = 7;
Vector target_local_velocity = 8;
AngularVelocity target_angular_velocity = 9;
Comment thread
GrayHoang marked this conversation as resolved.
}

/* Data about the network connection with the robots, including network-derived values */
Expand Down
2 changes: 1 addition & 1 deletion src/software/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const std::string ROBOT_KICK_EXP_COEFF_CONFIG_KEY = "kick_coeff";
const std::string ROBOT_CHIP_PULSE_WIDTH_CONFIG_KEY = "chip_pulse_width";

const std::string SSL_VISION_ADDRESS = "224.5.23.2";
static constexpr unsigned int SSL_VISION_PORT = 10020;
static constexpr unsigned int SSL_VISION_PORT = 10006;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the correct default SSL vision port

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

debugging


const std::string SSL_REFEREE_ADDRESS = "224.5.23.1";
static constexpr unsigned int SSL_REFEREE_PORT = 10003;
50 changes: 32 additions & 18 deletions src/software/embedded/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

package(default_visibility = ["//visibility:public"])
Comment thread
GrayHoang marked this conversation as resolved.

config_setting(
name = "build_trinamic",
flag_values = {
":motor_board": "TRINAMIC",
},
)

config_setting(
name = "build_stspin",
flag_values = {
":motor_board": "STSPIN",
},
)

string_flag(
name = "motor_board",
build_setting_default = "TRINAMIC",
values = [
"TRINAMIC",
"STSPIN",
],
)

cc_library(
name = "primitive_executor",
srcs = ["primitive_executor.cpp"],
Expand All @@ -19,6 +42,15 @@ cc_library(
],
)

cc_library(
name = "spi_utils",
srcs = ["spi_utils.cpp"],
hdrs = ["spi_utils.h"],
deps = [
"//software/logger",
],
)

cc_library(
name = "thunderloop",
srcs = ["thunderloop.cpp"],
Expand All @@ -37,24 +69,6 @@ cc_library(
],
)

cc_library(
name = "gpio",
srcs = [
"gpio_char_dev.cpp",
"gpio_sysfs.cpp",
],
hdrs = [
"gpio.h",
"gpio_char_dev.h",
"gpio_sysfs.h",
],
deps = [
"//software/logger",
"//software/logger:network_logger",
"//software/util/make_enum",
],
)

cc_binary(
name = "thunderloop_main",
srcs = ["thunderloop_main.cpp"],
Expand Down
2 changes: 1 addition & 1 deletion src/software/embedded/ansible/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ py_binary(
"//software/embedded:thunderloop_main",
"//software/embedded/linux_configs/pi:pi_files",
"//software/embedded/linux_configs/systemd:systemd_files",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

motor testing

"//software/embedded/motor_controller:stspin_motor_controller_test",
"//software/embedded/robot_diagnostics_cli:robot_diagnostics_cli_tar",
"//software/embedded/services:robot_auto_test",
"//software/power:powerloop_tar",
],
deps = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- name: Deploy stspin_motor_controller_test binary to robot
hosts: THUNDERBOTS_HOSTS

tasks:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Motor docs and testing

- name: Log Robot ID
ansible.builtin.debug:
msg: "[Robot ID = {{ inventory_hostname }}]"
tags: always

- name: Deploy stspin_motor_controller_test binary
block:
- name: Stop Services
become: true
become_method: ansible.builtin.sudo
ansible.builtin.systemd:
name: "thunderloop.service"
masked: false
daemon_reload: true
state: stopped
tags: always

- name: Delete stspin_motor_controller_test binary under ~/thunderbots_binaries
ansible.builtin.file:
state: absent
path: ~/thunderbots_binaries/stspin_motor_controller_test
become_method: ansible.builtin.sudo
become: true
register: result

- name: Log where Ansible is searching
ansible.builtin.debug:
msg: "{{ ansible_search_path }}"
tags: always

- name: Sync Binary
ansible.posix.synchronize:
src: ../../motor_controller/stspin_motor_controller_test
dest: ~/thunderbots_binaries/
recursive: true
copy_links: true
tags: always

This file was deleted.

7 changes: 0 additions & 7 deletions src/software/embedded/constants/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "constants",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

robot constants

hdrs = [
"constants.h",
],
)

py_library(
name = "py_constants",
srcs = [":py_constants.py"],
Expand Down
11 changes: 0 additions & 11 deletions src/software/embedded/constants/constants.h

This file was deleted.

18 changes: 18 additions & 0 deletions src/software/embedded/gpio/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "gpio",
Comment thread
GrayHoang marked this conversation as resolved.
srcs = [
"gpio.cpp",
"gpio_char_dev.cpp",
],
hdrs = [
"gpio.h",
"gpio_char_dev.h",
],
deps = [
"//software/logger",
"//software/logger:network_logger",
"//software/util/make_enum",
],
)
21 changes: 21 additions & 0 deletions src/software/embedded/gpio/gpio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "software/embedded/gpio/gpio.h"

#include <chrono>
Comment thread
GrayHoang marked this conversation as resolved.
#include <thread>

bool Gpio::pollValue(GpioState state, std::chrono::milliseconds timeout_ms)
{
const auto start_time = std::chrono::system_clock::now();
while (getValue() != state)
{
std::this_thread::sleep_for(std::chrono::microseconds(100));

const auto current_time = std::chrono::system_clock::now();
const auto elapsed_time = current_time - start_time;
if (elapsed_time > timeout_ms)
{
return false;
}
}
return true;
}
Comment thread
GrayHoang marked this conversation as resolved.
Loading
Loading