-
Notifications
You must be signed in to change notification settings - Fork 126
Implement STSPIN motor controller and refactor motor service #3715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ac62aaa
903ec93
520c4f4
89c7e0e
1a2f397
6938ccc
e7e6931
0c92ab0
d6a261c
882875c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Description: | ||
|
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"], | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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 ************/ | ||
|
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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| message DriveUnit | ||
|
|
@@ -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; | ||
|
GrayHoang marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /* Data about the network connection with the robots, including network-derived values */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the correct default SSL vision port
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,8 @@ py_binary( | |
| "//software/embedded:thunderloop_main", | ||
| "//software/embedded/linux_configs/pi:pi_files", | ||
| "//software/embedded/linux_configs/systemd:systemd_files", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = [ | ||
|
|
||
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,5 @@ | ||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| cc_library( | ||
| name = "constants", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"], | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| cc_library( | ||
| name = "gpio", | ||
|
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", | ||
| ], | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #include "software/embedded/gpio/gpio.h" | ||
|
|
||
| #include <chrono> | ||
|
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; | ||
| } | ||
|
GrayHoang marked this conversation as resolved.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation/Testing (MD)