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

Sync pressure sensor reading w move group #756

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f775c63
fix(z-motors): should disegange Z motors at boot when motor controlle…
ahiuchingau Mar 4, 2024
3b28e61
add PipetteMotorInterruptHandler
caila-marashaj Jan 24, 2024
0901aaf
AddSensorMoveRequest to be sent to the pipette task
ahiuchingau Jan 25, 2024
efad5ea
pass sensorqueue into pmih
caila-marashaj Jan 26, 2024
0815b37
send report message on start sensor move
caila-marashaj Jan 29, 2024
ed06eef
all hex files buiding
caila-marashaj Jan 29, 2024
920812d
format
caila-marashaj Jan 29, 2024
9901e6d
send sync output binding to pressure queue
caila-marashaj Jan 30, 2024
4f1fdb4
send sync and report actually lol
caila-marashaj Jan 30, 2024
edf55f1
send as uint8
caila-marashaj Jan 30, 2024
09259b6
this was working last week
ryanthecoder Feb 6, 2024
6962e29
this works i guess
ryanthecoder Feb 1, 2024
b905a7e
Tell sensor to stop reporting after successful probe but don't de-ass…
ryanthecoder Feb 1, 2024
6bb3596
static allocate a pressure buffer
ryanthecoder Feb 6, 2024
fb41a51
handle pressure buffer
caila-marashaj Feb 6, 2024
3c3b568
pass static array by pointer to sensor driver
ryanthecoder Feb 7, 2024
248032d
move reset buffer index
caila-marashaj Feb 7, 2024
7ceb69d
Jump the capture rate to max and add protection against memory overrruns
ryanthecoder Feb 7, 2024
0334eac
send error message when buffer runs out
caila-marashaj Feb 7, 2024
ac10b9e
get all of the firmwares to compile now
ryanthecoder Feb 7, 2024
6b6f6d9
tease out a little extra data about how much data the sensor collected
ryanthecoder Feb 8, 2024
0073d39
was sending the data too slow
ryanthecoder Feb 8, 2024
5f76e1f
format
ryanthecoder Mar 6, 2024
8bb65f8
add a compile option to gate the pressure-based move
ryanthecoder Mar 7, 2024
beb24d4
fix tests
ryanthecoder Mar 7, 2024
07a44ec
add github workflow that checks the pressure move compilation
ryanthecoder Mar 7, 2024
5f09c12
set a flag in the tertiary field if the pipette has the presssure sen…
ryanthecoder Mar 7, 2024
6bd9fc7
didn't do the workflow right
ryanthecoder Mar 7, 2024
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
116 changes: 116 additions & 0 deletions .github/workflows/cross-compile-special-sensors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: "cross-compile/format/lint all targets"
on:
push:
branches:
- "*"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

defaults:
run:
shell: bash
working-directory: ot3-firmware

jobs:
build-cross:
runs-on: "ubuntu-20.04"
timeout-minutes: 20
strategy:
matrix:
target: [
pipettes-single,
pipettes-multi,
pipettes-96,
]
fail-fast: false
name: Build ${{ matrix.target }}
steps:
- name: Checkout ot3-firmware repo
uses: actions/checkout@v4
with:
path: ot3-firmware

- name: Checkout github actions directory
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions
sparse-checkout-cone-mode: false
path: actions

- name: Setup main
uses: ./actions/.github/actions/main-setup
with:
cache-version: ${{ secrets.CACHE_VERSION }}

- name: Configure
run: cmake --preset=cross . -DUSE_PRESSURE_MOVE=true

- name: Build all STM32G4 applications
run: cmake --build --preset=${{ matrix.target }} --target ${{ matrix.target }}-images ${{ matrix.target }}-applications

format:
runs-on: "ubuntu-20.04"
timeout-minutes: 20
name: Formatting
steps:
- name: Checkout ot3-firmware repo
uses: actions/checkout@v4
with:
path: ot3-firmware

- name: Checkout github actions directory
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions
sparse-checkout-cone-mode: false
path: actions

- name: Setup main
uses: ./actions/.github/actions/main-setup
with:
cache-version: ${{ secrets.CACHE_VERSION }}

- name: Configure
run: cmake --preset=cross . -DUSE_PRESSURE_MOVE=true

- name: Format
run: cmake --build ./build-cross --target format-ci

lint:
runs-on: "ubuntu-20.04"
timeout-minutes: 20
name: ${{ matrix.target }} lint
strategy:
matrix:
target: [
pipettes,
]
steps:
- name: Checkout ot3-firmware repo
uses: actions/checkout@v4
with:
path: ot3-firmware

- name: Checkout github actions directory
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions
sparse-checkout-cone-mode: false
path: actions

- name: Setup main
uses: ./actions/.github/actions/main-setup
with:
cache-version: ${{ secrets.CACHE_VERSION }}

- name: Configure
run: cmake --preset=cross . -DUSE_PRESSURE_MOVE=true

- name: Format
run: cmake --build ./build-cross --target ${{ matrix.target }}-lint
6 changes: 6 additions & 0 deletions common/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ function(add_revision)
message(STATUS "add_revision has target ${_ar_TARGET} and revision ${_ar_REVISION}")
string(SUBSTRING ${_ar_REVISION} 0 1 PRIMARY_REVISION)
string(SUBSTRING ${_ar_REVISION} 1 1 SECONDARY_REVISION)
if (${USE_PRESSURE_MOVE})
set(TERTIARY_FLAG "0x01")
else()
set(TERTIARY_FLAG "0x00")
endif()


configure_file(${CMAKE_SOURCE_DIR}/common/core/revision.c.in ${CMAKE_CURRENT_BINARY_DIR}/${_ar_TARGET}_revision.c)

Expand Down
2 changes: 1 addition & 1 deletion common/core/revision.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static const struct revision _revision = {
.primary = '${PRIMARY_REVISION}',
.secondary = '${SECONDARY_REVISION}',
.tertiary = {0x00,0x00}
.tertiary = {0x00,${TERTIARY_FLAG}}
};

const struct revision* revision_get() {
Expand Down
2 changes: 1 addition & 1 deletion gripper/firmware/utility_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ inline static void ebrake_gpio_init(void) {
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(EBRAKE_PORT, &GPIO_InitStruct);

HAL_GPIO_WritePin(EBRAKE_PORT, EBRAKE_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(EBRAKE_PORT, EBRAKE_PIN, GPIO_PIN_RESET);
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions include/bootloader/core/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum {
can_messageid_execute_move_group_request = 0x18,
can_messageid_clear_all_move_groups_request = 0x19,
can_messageid_home_request = 0x20,
can_messageid_add_sensor_move_request = 0x23,
can_messageid_move_completed = 0x13,
can_messageid_motor_position_request = 0x12,
can_messageid_motor_position_response = 0x14,
Expand Down Expand Up @@ -112,6 +113,7 @@ typedef enum {
can_messageid_peripheral_status_request = 0x8c,
can_messageid_peripheral_status_response = 0x8d,
can_messageid_baseline_sensor_response = 0x8e,
can_messageid_send_accumulated_pressure_data = 0x8f,
can_messageid_set_hepa_fan_state_request = 0x90,
can_messageid_get_hepa_fan_state_request = 0x91,
can_messageid_get_hepa_fan_state_response = 0x92,
Expand Down
3 changes: 3 additions & 0 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum class MessageId {
execute_move_group_request = 0x18,
clear_all_move_groups_request = 0x19,
home_request = 0x20,
add_sensor_move_request = 0x23,
move_completed = 0x13,
motor_position_request = 0x12,
motor_position_response = 0x14,
Expand Down Expand Up @@ -114,6 +115,7 @@ enum class MessageId {
peripheral_status_request = 0x8c,
peripheral_status_response = 0x8d,
baseline_sensor_response = 0x8e,
send_accumulated_pressure_data = 0x8f,
set_hepa_fan_state_request = 0x90,
get_hepa_fan_state_request = 0x91,
get_hepa_fan_state_response = 0x92,
Expand Down Expand Up @@ -198,6 +200,7 @@ enum class SensorType {
enum class SensorId {
S0 = 0x0,
S1 = 0x1,
UNUSED = 0x2,
};

/** Links sensor threshold triggers to pins. */
Expand Down
9 changes: 9 additions & 0 deletions include/can/core/message_handlers/move_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ using namespace can::messages;
template <move_group_task::TaskClient Client>
class MoveGroupHandler {
public:
#ifdef USE_PRESSURE_MOVE
using MessageType =
std::variant<std::monostate, AddLinearMoveRequest,
ClearAllMoveGroupsRequest, ExecuteMoveGroupRequest,
GetMoveGroupRequest, HomeRequest, StopRequest,
AddSensorMoveRequest>;
#else
using MessageType =
std::variant<std::monostate, AddLinearMoveRequest,
ClearAllMoveGroupsRequest, ExecuteMoveGroupRequest,
GetMoveGroupRequest, HomeRequest, StopRequest>;
#endif

MoveGroupHandler(Client &task_client) : task_client{task_client} {}
MoveGroupHandler(const MoveGroupHandler &) = delete;
MoveGroupHandler(const MoveGroupHandler &&) = delete;
Expand Down
66 changes: 66 additions & 0 deletions include/can/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,27 @@ struct FirmwareUpdateStatusResponse
-> bool = default;
};

struct SendAccumulatedPressureDataRequest
: BaseMessage<MessageId::send_accumulated_pressure_data> {
uint32_t message_index = 0;
uint8_t sensor_id = 0;

template <bit_utils::ByteIterator Input, typename Limit>
static auto parse(Input body, Limit limit)
-> SendAccumulatedPressureDataRequest {
uint32_t msg_ind = 0;
uint8_t sensor_id = 0;

body = bit_utils::bytes_to_int(body, limit, msg_ind);
body = bit_utils::bytes_to_int(body, limit, sensor_id);
return SendAccumulatedPressureDataRequest{.message_index = msg_ind,
.sensor_id = sensor_id};
}

auto operator==(const SendAccumulatedPressureDataRequest& other) const
-> bool = default;
};

struct ReadFromSensorRequest : BaseMessage<MessageId::read_sensor_request> {
uint32_t message_index = 0;
uint8_t sensor = 0;
Expand Down Expand Up @@ -1672,6 +1693,51 @@ struct GetHepaUVStateResponse
-> bool = default;
};

// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct AddSensorMoveRequest : BaseMessage<MessageId::add_sensor_move_request> {
uint32_t message_index;
uint8_t group_id;
uint8_t seq_id;
stepper_timer_ticks duration;
um_per_tick_sq acceleration;
mm_per_tick velocity;
uint8_t request_stop_condition;
can::ids::SensorId sensor_id{};

template <bit_utils::ByteIterator Input, typename Limit>
static auto parse(Input body, Limit limit) -> AddSensorMoveRequest {
uint8_t group_id = 0;
uint8_t seq_id = 0;
stepper_timer_ticks duration = 0;
um_per_tick_sq acceleration = 0;
mm_per_tick velocity = 0;
uint8_t request_stop_condition = 0;
uint32_t msg_ind = 0;
uint8_t sensor_id = 0;

body = bit_utils::bytes_to_int(body, limit, msg_ind);
body = bit_utils::bytes_to_int(body, limit, group_id);
body = bit_utils::bytes_to_int(body, limit, seq_id);
body = bit_utils::bytes_to_int(body, limit, duration);
body = bit_utils::bytes_to_int(body, limit, acceleration);
body = bit_utils::bytes_to_int(body, limit, velocity);
body = bit_utils::bytes_to_int(body, limit, request_stop_condition);
body = bit_utils::bytes_to_int(body, limit, sensor_id);
return AddSensorMoveRequest{
.message_index = msg_ind,
.group_id = group_id,
.seq_id = seq_id,
.duration = duration,
.acceleration = acceleration,
.velocity = velocity,
.request_stop_condition = request_stop_condition,
.sensor_id = static_cast<can::ids::SensorId>(sensor_id),
};
}

auto operator==(const AddSensorMoveRequest& other) const -> bool = default;
};

/**
* A variant of all message types we might send..
*/
Expand Down
1 change: 1 addition & 0 deletions include/gripper/core/can_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ using GripperInfoDispatchTarget = can::dispatch::DispatchParseTarget<
using SensorDispatchTarget = can::dispatch::DispatchParseTarget<
sensors::handlers::SensorHandler<gripper_tasks::QueueClient>,
can::messages::TipStatusQueryRequest, can::messages::ReadFromSensorRequest,
can::messages::SendAccumulatedPressureDataRequest,
can::messages::WriteToSensorRequest, can::messages::BaselineSensorRequest,
can::messages::SetSensorThresholdRequest,
can::messages::BindSensorOutputRequest,
Expand Down
36 changes: 35 additions & 1 deletion include/motor-control/core/motor_messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,46 @@ struct Move { // NOLINT(cppcoreguidelines-pro-type-member-init)
}
};

struct SensorSyncMove { // NOLINT(cppcoreguidelines-pro-type-member-init)
uint32_t message_index;
stepper_timer_ticks duration; // in stepper timer ticks
steps_per_tick velocity;
steps_per_tick_sq acceleration;
uint8_t group_id;
uint8_t seq_id;
uint8_t stop_condition = static_cast<uint8_t>(MoveStopCondition::none);
int32_t start_encoder_position;
uint16_t usage_key;
can::ids::SensorId sensor_id;

auto build_ack(uint32_t position, int32_t pulses, uint8_t flags,
AckMessageId _id) -> Ack {
return Ack{
.message_index = message_index,
.group_id = group_id,
.seq_id = seq_id,
.current_position_steps = position,
.encoder_position = pulses,
.position_flags = flags,
.ack_id = _id,
.start_encoder_position = start_encoder_position,
.usage_key = usage_key,
};
}

[[nodiscard]] auto check_stop_condition(MoveStopCondition cond) const
-> bool {
return ((stop_condition & static_cast<uint8_t>(cond)) ==
static_cast<uint8_t>(cond));
}
};

struct GearMotorMove // NOLINT(cppcoreguidelines-pro-type-member-init)
: public Move {
uint32_t start_step_position;
can::ids::PipetteTipActionType action;
can::ids::GearMotorId gear_motor_id;

can::ids::SensorId sensor_id;
auto build_ack(uint32_t position, int32_t pulses, uint8_t flags,
AckMessageId _id) -> GearMotorAck {
return GearMotorAck{message_index, group_id,
Expand Down
Loading
Loading