Skip to content
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

Robot Stack Release 8.2.0 #812

Open
wants to merge 15 commits into
base: release
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
build-and-test:
name: Run all tests
runs-on: "ubuntu-20.04"
timeout-minutes: 10
timeout-minutes: 20
steps:
- name: Checkout ot3-firmware repo
uses: actions/checkout@v4
Expand Down
28 changes: 20 additions & 8 deletions gantry/firmware/interfaces_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ struct motion_controller::HardwareConfig motor_pins_x {
.port = GPIOB,
.pin = GPIO_PIN_7,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.port = GPIOC,
.pin = GPIO_PIN_5,
.active_setting = GPIO_PIN_RESET}
};

Expand Down Expand Up @@ -125,15 +131,21 @@ struct motion_controller::HardwareConfig motor_pins_y {
.port = GPIOB,
.pin = GPIO_PIN_5,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.port = GPIOC,
.pin = GPIO_PIN_5,
.active_setting = GPIO_PIN_RESET}
};

static tmc2130::configs::TMC2130DriverConfig gantry_x_driver_configs{
.registers = {.gconfig = {.en_pwm_mode = 1},
.registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1},
.ihold_irun = {.hold_current = 0x2,
.run_current = 0x18,
.hold_current_delay = 0x7},
Expand All @@ -156,7 +168,7 @@ static tmc2130::configs::TMC2130DriverConfig gantry_x_driver_configs{
}};

static tmc2130::configs::TMC2130DriverConfig gantry_y_driver_configs{
.registers = {.gconfig = {.en_pwm_mode = 1},
.registers = {.gconfig = {.en_pwm_mode = 1, .diag0_error = 1},
.ihold_irun = {.hold_current = 0x2,
.run_current = 0x18,
.hold_current_delay = 0x7},
Expand Down
30 changes: 22 additions & 8 deletions gantry/firmware/interfaces_rev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ struct motion_controller::HardwareConfig motor_pins_x {
.port = GPIOB,
.pin = GPIO_PIN_7,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.port = GPIOC,
.pin = GPIO_PIN_5,
.active_setting = GPIO_PIN_RESET}
};

Expand Down Expand Up @@ -125,15 +131,21 @@ struct motion_controller::HardwareConfig motor_pins_y {
.port = GPIOB,
.pin = GPIO_PIN_7,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOA,
.pin = GPIO_PIN_10,
.port = GPIOC,
.pin = GPIO_PIN_5,
.active_setting = GPIO_PIN_RESET}
};

static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{
.registers = {.gconfig = {.en_pwm_mode = 0},
.registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1},
.ihold_irun = {.hold_current = 16,
.run_current = 31,
.hold_current_delay = 0x7},
Expand All @@ -159,6 +171,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{
.freewheel = 0,
.pwm_reg = 0x7,
.pwm_lim = 0xC},
.drvconf = {.ot_select = 0},
.glob_scale = {.global_scaler = 0xA7}},
.current_config =
{
Expand All @@ -172,7 +185,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_x{
}};

static tmc2160::configs::TMC2160DriverConfig motor_driver_config_y{
.registers = {.gconfig = {.en_pwm_mode = 0},
.registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1},
.ihold_irun = {.hold_current = 16,
.run_current = 31,
.hold_current_delay = 0x7},
Expand All @@ -198,6 +211,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_config_y{
.freewheel = 0,
.pwm_reg = 0x7,
.pwm_lim = 0xC},
.drvconf = {.ot_select = 0},
.glob_scale = {.global_scaler = 0xA7}},
.current_config =
{
Expand Down
10 changes: 9 additions & 1 deletion gantry/firmware/motor_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) {
PC8 ------> Motor Step Pin
Enable
PA9 ------> Motor Enable Pin
DIAG0
PC5 ------> Motor Diag0 Pin
*/
GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
Expand Down Expand Up @@ -54,6 +56,12 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) {
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOA, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);

// Diag0
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}
}
SPI_HandleTypeDef hspi2 = {
Expand Down Expand Up @@ -87,7 +95,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) {
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |
GPIO_PIN_15 | GPIO_PIN_1);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8);
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8 | GPIO_PIN_5);
}
}

Expand Down
9 changes: 8 additions & 1 deletion gripper/firmware/interfaces_z_motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ struct motion_controller::HardwareConfig motor_pins {
.port = ESTOP_IN_PORT,
.pin = ESTOP_IN_PIN,
.active_setting = GPIO_PIN_RESET},
.ebrake = ebrake,
.diag0 =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB,
.pin = GPIO_PIN_2,
.active_setting = GPIO_PIN_RESET},
.ebrake = ebrake
};

/**
Expand All @@ -119,6 +125,7 @@ static motor_hardware::MotorHardware motor_hardware_iface(motor_pins, &htim7,
*/
static tmc2130::configs::TMC2130DriverConfig MotorDriverConfigurations{
.registers = {.gconfig = {.en_pwm_mode = 0x0,
.diag0_error = 1,
.stop_enable = use_stop_enable},
.ihold_irun = {.hold_current = 0x2, // 0.177A
.run_current = 0xA, // 0.648A
Expand Down
7 changes: 7 additions & 0 deletions gripper/firmware/utility_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ static void z_motor_gpio_init(void) {
PB1 ------> Motor Step Pin
Enable
PA9 ------> Motor Enable Pin
Diag0
PB2 ------> Motor Diag0 Pin
*/
GPIO_InitStruct.Pin = Z_MOT_DIR_PIN | Z_MOT_STEP_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
Expand All @@ -119,6 +121,11 @@ static void z_motor_gpio_init(void) {
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(Z_MOT_ENABLE_PORT, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);

GPIO_InitStruct.Pin = Z_MOT_DIAG0_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(Z_MOT_STEPDIR_PORT, &GPIO_InitStruct);
}

#if PCBA_PRIMARY_REVISION != 'b' && PCBA_PRIMARY_REVISION != 'a'
Expand Down
3 changes: 2 additions & 1 deletion head/core/can_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::motor::MotorHandler<head_tasks::MotorQueueClient>,
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest>;
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatusRequest>;
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<
head_tasks::MotorQueueClient>,
Expand Down
28 changes: 20 additions & 8 deletions head/firmware/main_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ struct motor_hardware::HardwareConfig pin_configurations_left {
.port = GPIOA,
.pin = GPIO_PIN_8,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB,
.pin = GPIO_PIN_4,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB,
.pin = GPIO_PIN_4,
.port = GPIOC,
.pin = GPIO_PIN_13,
.active_setting = GPIO_PIN_RESET}
};

Expand Down Expand Up @@ -186,18 +192,24 @@ struct motor_hardware::HardwareConfig pin_configurations_right {
.port = GPIOA,
.pin = GPIO_PIN_8,
.active_setting = GPIO_PIN_RESET},
.estop_in = {
.estop_in =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB,
.pin = GPIO_PIN_4,
.active_setting = GPIO_PIN_RESET},
.diag0 = {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB,
.pin = GPIO_PIN_4,
.port = GPIOC,
.pin = GPIO_PIN_15,
.active_setting = GPIO_PIN_RESET}
};

// TODO clean up the head main file by using interfaces.
static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_right{
.registers =
{
.gconfig = {.en_pwm_mode = 1},
.gconfig = {.en_pwm_mode = 1, .diag0_error = 1},
.ihold_irun = {.hold_current = 0xB,
.run_current = 0x19,
.hold_current_delay = 0x7},
Expand All @@ -224,7 +236,7 @@ static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_right{
static tmc2130::configs::TMC2130DriverConfig motor_driver_configs_left{
.registers =
{
.gconfig = {.en_pwm_mode = 1},
.gconfig = {.en_pwm_mode = 1, .diag0_error = 1},
.ihold_irun = {.hold_current = 0xB,
.run_current = 0x19,
.hold_current_delay = 0x7},
Expand Down
16 changes: 14 additions & 2 deletions head/firmware/main_rev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ struct motor_hardware::HardwareConfig pin_configurations_left {
.port = GPIOB,
.pin = GPIO_PIN_4,
.active_setting = GPIO_PIN_RESET},
.diag0 =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOC,
.pin = GPIO_PIN_13,
.active_setting = GPIO_PIN_RESET},
.ebrake = gpio::PinConfig {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB, .pin = GPIO_PIN_5, .active_setting = GPIO_PIN_RESET
Expand Down Expand Up @@ -198,6 +204,12 @@ struct motor_hardware::HardwareConfig pin_configurations_right {
.port = GPIOB,
.pin = GPIO_PIN_4,
.active_setting = GPIO_PIN_RESET},
.diag0 =
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOC,
.pin = GPIO_PIN_15,
.active_setting = GPIO_PIN_RESET},
.ebrake = gpio::PinConfig {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
.port = GPIOB, .pin = GPIO_PIN_0, .active_setting = GPIO_PIN_RESET
Expand All @@ -206,7 +218,7 @@ struct motor_hardware::HardwareConfig pin_configurations_right {

// TODO clean up the head main file by using interfaces.
static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_right{
.registers = {.gconfig = {.en_pwm_mode = 0},
.registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1},
.ihold_irun = {.hold_current = 16,
.run_current = 31,
.hold_current_delay = 0x7},
Expand All @@ -232,7 +244,7 @@ static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_right{
}};

static tmc2160::configs::TMC2160DriverConfig motor_driver_configs_left{
.registers = {.gconfig = {.en_pwm_mode = 0},
.registers = {.gconfig = {.en_pwm_mode = 0, .diag0_error = 1},
.ihold_irun = {.hold_current = 16,
.run_current = 31,
.hold_current_delay = 0x7},
Expand Down
14 changes: 14 additions & 0 deletions head/firmware/motor_hardware_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) {
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);

// A motor diag0
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);
}

else if (hspi->Instance == SPI3) {
Expand Down Expand Up @@ -91,6 +98,13 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) {
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);

// Z motor diag0
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
&GPIO_InitStruct);
}
}

Expand Down
5 changes: 5 additions & 0 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ enum class MessageId {
write_motor_current_request = 0x33,
read_motor_current_request = 0x34,
read_motor_current_response = 0x35,
read_motor_driver_error_status_request = 0x36,
read_motor_driver_error_status_response = 0x37,
set_brushed_motor_vref_request = 0x40,
set_brushed_motor_pwm_request = 0x41,
gripper_grip_request = 0x42,
Expand Down Expand Up @@ -105,6 +107,7 @@ enum class MessageId {
gear_read_motor_driver_request = 0x507,
max_sensor_value_request = 0x70,
max_sensor_value_response = 0x71,
batch_read_sensor_response = 0x81,
read_sensor_request = 0x82,
write_sensor_request = 0x83,
baseline_sensor_request = 0x84,
Expand Down Expand Up @@ -169,11 +172,13 @@ enum class ErrorCode {
over_pressure = 0xd,
door_open = 0xe,
reed_open = 0xf,
motor_driver_error_detected = 0x10,
safety_relay_inactive = 0x11,
};

/** Error Severity levels. */
enum class ErrorSeverity {
none = 0x0,
warning = 0x1,
recoverable = 0x2,
unrecoverable = 0x3,
Expand Down
5 changes: 3 additions & 2 deletions include/can/core/message_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class MessageWriter {
* @param message The message to send
*/
template <message_core::CanResponseMessage ResponseMessage>
void send_can_message(can::ids::NodeId node, ResponseMessage&& message) {
auto send_can_message(can::ids::NodeId node, ResponseMessage&& message)
-> bool {
auto arbitration_id = can::arbitration_id::ArbitrationId{};
auto task_message = can::message_writer_task::TaskMessage{};

Expand All @@ -41,7 +42,7 @@ class MessageWriter {
arbitration_id.originating_node_id(node_id);
task_message.arbitration_id = arbitration_id;
task_message.message = message;
queue->try_write(task_message);
return queue->try_write(task_message);
}

void set_queue(QueueType* q) { queue = q; }
Expand Down
Loading
Loading