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

refactor(sensors): remove USE_SENSOR_FIRMWARE compile target #790

Merged
merged 9 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
44 changes: 0 additions & 44 deletions .github/workflows/build_sensor_fw.yaml

This file was deleted.

118 changes: 0 additions & 118 deletions .github/workflows/cross-compile-special-sensors.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@
"binaryDir": "${sourceDir}/build-cross",
"inherits": "cross-no-directory-reqs"
},
{
"name": "cross-sensor-buffer",
"displayName": "STM32 G4 OT-3 cross-compilation with sensor data buffers",
"description": "Build application firmware for OT-3 systems that use STM32, for flashing onto boards",
"installDir": "${sourceDir}/dist-sensor",
"binaryDir": "${sourceDir}/build-cross-sensor",
"cacheVariables": {
"USE_SENSOR_MOVE": true
},
"inherits": "cross"
},
{
"name": "host",
"displayName": "STM32 OT-3 host compilation for tests",
Expand Down Expand Up @@ -99,17 +88,6 @@
"firmware-images"
]
},
{
"name": "firmware-g4-sensors",
"displayName": "All G4 Firmwares With Sensor Data Buffers",
"description": "Environment to build all g4 firmware - see firmware-l5",
"configurePreset": "cross-sensor-buffer",
"jobs": 4,
"targets": [
"firmware-applications",
"firmware-images"
]
},
{
"name": "pipettes",
"displayName": "pipettes binaries",
Expand Down
4 changes: 0 additions & 4 deletions common/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ 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_SENSOR_MOVE})
set(TERTIARY_FLAG "'1'")
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: 0 additions & 2 deletions gripper/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
function(target_gripper_core TARGET)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC USE_SENSOR_MOVE)
endif()
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500)
target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true)
target_sources(${TARGET} PUBLIC
Expand Down
7 changes: 7 additions & 0 deletions gripper/simulator/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ static auto motor_interface =
/**
* The pending move queue
*/

#ifdef USE_SENSOR_MOVE
static freertos_message_queue::FreeRTOSMessageQueue<
motor_messages::SensorSyncMove>
motor_queue("Motor Queue");
#else
static freertos_message_queue::FreeRTOSMessageQueue<motor_messages::Move>
motor_queue("Motor Queue");
#endif

static freertos_message_queue::FreeRTOSMessageQueue<
can::messages::UpdateMotorPositionEstimationRequest>
Expand Down
2 changes: 1 addition & 1 deletion include/common/core/sensor_buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#ifndef SENSOR_BUFF_SIZE
#define SENSOR_BUFF_SIZE 1
constexpr size_t SENSOR_BUFF_SIZE = 1;
#endif
constexpr size_t SENSOR_BUFFER_SIZE = SENSOR_BUFF_SIZE;
34 changes: 27 additions & 7 deletions include/pipettes/simulator/interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
namespace interfaces {

template <typename Client>
using MotorInterruptHandlerType = motor_handler::MotorInterruptHandler<
freertos_message_queue::FreeRTOSMessageQueue, Client, motor_messages::Move,
sim_motor_hardware_iface::SimMotorHardwareIface>;
using MotorInterruptHandlerType =
#ifdef USE_SENSOR_MOVE
motor_handler::MotorInterruptHandler<
freertos_message_queue::FreeRTOSMessageQueue, Client,
motor_messages::SensorSyncMove,
sim_motor_hardware_iface::SimMotorHardwareIface>;
#else
motor_handler::MotorInterruptHandler<
freertos_message_queue::FreeRTOSMessageQueue, Client,
motor_messages::Move, sim_motor_hardware_iface::SimMotorHardwareIface>;
#endif

template <typename Client>
using GearMotorInterruptHandlerType = motor_handler::MotorInterruptHandler<
Expand Down Expand Up @@ -73,18 +81,30 @@ auto get_interrupt(sim_motor_hardware_iface::SimMotorHardwareIface& hw,
auto get_interrupt_driver(
sim_motor_hardware_iface::SimMotorHardwareIface& hw,
LowThroughputInterruptQueues& queues,
MotorInterruptHandlerType<linear_motor_tasks::QueueClient>& handler)
-> motor_interrupt_driver::MotorInterruptDriver<
MotorInterruptHandlerType<linear_motor_tasks::QueueClient>& handler) ->
#ifdef USE_SENSOR_MOVE
motor_interrupt_driver::MotorInterruptDriver<
linear_motor_tasks::QueueClient, motor_messages::SensorSyncMove,
sim_motor_hardware_iface::SimMotorHardwareIface>;
#else
motor_interrupt_driver::MotorInterruptDriver<
linear_motor_tasks::QueueClient, motor_messages::Move,
sim_motor_hardware_iface::SimMotorHardwareIface>;
#endif

auto get_interrupt_driver(
sim_motor_hardware_iface::SimMotorHardwareIface& hw,
HighThroughputInterruptQueues& queues,
MotorInterruptHandlerType<linear_motor_tasks::QueueClient>& handler)
-> motor_interrupt_driver::MotorInterruptDriver<
MotorInterruptHandlerType<linear_motor_tasks::QueueClient>& handler) ->
#ifdef USE_SENSOR_MOVE
motor_interrupt_driver::MotorInterruptDriver<
linear_motor_tasks::QueueClient, motor_messages::SensorSyncMove,
sim_motor_hardware_iface::SimMotorHardwareIface>;
#else
motor_interrupt_driver::MotorInterruptDriver<
linear_motor_tasks::QueueClient, motor_messages::Move,
sim_motor_hardware_iface::SimMotorHardwareIface>;
#endif

auto get_motor_hardware() -> sim_motor_hardware_iface::SimMotorHardwareIface;

Expand Down
26 changes: 12 additions & 14 deletions include/sensors/core/tasks/capacitive_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ class FDC1004 {
}

void send_accumulated_sensor_data(uint32_t message_index) {
#ifdef USE_SENSOR_MOVE
for (int i = 0; i < sensor_buffer_index; i++) {
// send over buffer adn then clear buffer values
can_client.send_can_message(
Expand All @@ -217,16 +216,22 @@ class FDC1004 {
(*sensor_buffer).at(i), S15Q16_RADIX)});
if (i % 10 == 0) {
// slow it down so the can buffer doesn't choke
vTaskDelay(50);
vtask_hardware_delay(50);
}
(*sensor_buffer).at(i) = 0;
}
can_client.send_can_message(
can::ids::NodeId::host,
can::messages::Acknowledgment{.message_index = message_index});
#else
std::ignore = message_index;
#endif
}

auto sensor_buffer_log(float data) -> void {
sensor_buffer->at(sensor_buffer_index) = data;
sensor_buffer_index++;
if (sensor_buffer_index == SENSOR_BUFFER_SIZE) {
sensor_buffer_index = 0;
crossed_buffer_index = true;
}
}

void handle_fdc_response(i2c::messages::TransactionResponse &m) {
Expand Down Expand Up @@ -296,14 +301,7 @@ class FDC1004 {
}

if (echoing) {
#ifdef USE_SENSOR_MOVE
// send a response with 9999 to make an overload of the buffer
// visible
if (sensor_buffer_index < SENSOR_BUFFER_SIZE) {
(*sensor_buffer).at(sensor_buffer_index) = capacitance;
sensor_buffer_index++;
}
#else
sensor_buffer_log(capacitance);
can_client.send_can_message(
can::ids::NodeId::host,
can::messages::ReadFromSensorResponse{
Expand All @@ -312,7 +310,6 @@ class FDC1004 {
.sensor_id = sensor_id,
.sensor_data =
convert_to_fixed_point(capacitance, S15Q16_RADIX)});
#endif
}
}

Expand Down Expand Up @@ -533,6 +530,7 @@ class FDC1004 {
}
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer;
uint16_t sensor_buffer_index = 0;
bool crossed_buffer_index = false;

}; // end of FDC1004 class

Expand Down
Loading
Loading