Skip to content

Commit

Permalink
make p buff sensor buff, change size to 500
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jun 11, 2024
1 parent c94d9d2 commit 7e89b0f
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion gripper/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function(target_gripper_core TARGET)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC USE_SENSOR_MOVE)
target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1700)
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500)
target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true)
endif()
target_sources(${TARGET} PUBLIC
Expand Down
10 changes: 5 additions & 5 deletions gripper/core/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

static auto tasks = gripper_tasks::AllTask{};
static auto queues = gripper_tasks::QueueClient{can::ids::NodeId::gripper};
static std::array<float, SENSOR_BUFFER_SIZE> p_buff;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer;
#ifdef USE_TWO_BUFFERS
static std::array<float, SENSOR_BUFFER_SIZE> p_buff_front;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer_front;
#endif

static auto eeprom_task_builder =
Expand Down Expand Up @@ -101,14 +101,14 @@ void gripper_tasks::start_tasks(
5, "cap sensor S1", i2c2_task_client, i2c2_poll_client,
sensor_hardware, queues,
#ifdef USE_TWO_BUFFERS
p_buff_front);
sensor_buffer_front);
#else
p_buff);
sensor_buffer);
#endif
auto& capacitive_sensor_task_rear =
capacitive_sensor_task_builder_rear.start(
5, "cap sensor S0", i2c3_task_client, i2c3_poll_client,
sensor_hardware, queues, p_buff);
sensor_hardware, queues, sensor_buffer);

tasks.i2c2_task = &i2c2_task;
tasks.i2c3_task = &i2c3_task;
Expand Down
4 changes: 2 additions & 2 deletions include/common/core/sensor_buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#ifdef USE_SENSOR_MOVE
constexpr size_t SENSOR_BUFFER_SIZE = P_BUFF_SIZE;
constexpr size_t SENSOR_BUFFER_SIZE = SENSOR_BUFF_SIZE;
#else
constexpr size_t SENSOR_BUFFER_SIZE = 0;
#endif
#endif
12 changes: 6 additions & 6 deletions include/sensors/core/tasks/capacitive_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class FDC1004 {
FDC1004(I2CQueueWriter &writer, I2CQueuePoller &poller,
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware, bool shared_sensor,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff)
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer)
: writer(writer),
poller(poller),
can_client(can_client),
own_queue(own_queue),
hardware(hardware),
shared_sensor(shared_sensor),
p_buff(p_buff) {}
sensor_buffer(sensor_buffer) {}

[[nodiscard]] auto initialized() const -> bool { return _initialized; }

Expand Down Expand Up @@ -224,12 +224,12 @@ class FDC1004 {
.sensor = can::ids::SensorType::capacitive,
.sensor_id = sensor_id,
.sensor_data =
convert_to_fixed_point((*p_buff).at(i), S15Q16_RADIX)});
convert_to_fixed_point((*sensor_buffer).at(i), S15Q16_RADIX)});
if (i % 10 == 0) {
// slow it down so the can buffer doesn't choke
vTaskDelay(50);
}
(*p_buff).at(i) = 0;
(*sensor_buffer).at(i) = 0;
}
#else
std::ignore = message_index;
Expand Down Expand Up @@ -306,7 +306,7 @@ class FDC1004 {
// send a response with 9999 to make an overload of the buffer
// visible
if (sensor_buffer_index < SENSOR_BUFFER_SIZE) {
(*p_buff).at(sensor_buffer_index) = capacitance;
(*sensor_buffer).at(sensor_buffer_index) = capacitance;
sensor_buffer_index++;
}
#else
Expand Down Expand Up @@ -537,7 +537,7 @@ class FDC1004 {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
return RG(*reinterpret_cast<Reg *>(&ret.value()));
}
std::array<float, SENSOR_BUFFER_SIZE> *p_buff;
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer;
uint16_t sensor_buffer_index = 0;

}; // end of FDC1004 class
Expand Down
8 changes: 4 additions & 4 deletions include/sensors/core/tasks/capacitive_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CapacitiveMessageHandler {
I2CQueueWriter &i2c_writer, I2CQueuePoller &i2c_poller,
sensors::hardware::SensorHardwareBase &hardware, CanClient &can_client,
OwnQueue &own_queue, bool shared_task,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff)
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer)
: driver{i2c_writer, i2c_poller, can_client, own_queue,
hardware, shared_task, p_buff} {}
hardware, shared_task, sensor_buffer} {}
CapacitiveMessageHandler(const CapacitiveMessageHandler &) = delete;
CapacitiveMessageHandler(const CapacitiveMessageHandler &&) = delete;
auto operator=(const CapacitiveMessageHandler &)
Expand Down Expand Up @@ -213,14 +213,14 @@ class CapacitiveSensorTask {
i2c::writer::Writer<QueueImpl> *writer,
i2c::poller::Poller<QueueImpl> *poller,
sensors::hardware::SensorHardwareBase *hardware, CanClient *can_client,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff,
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer,
bool shared_task = false) {
// On the 8 channel, there is a singular cap sensor but we're using
// multiple channels. We will thus rely on the sensor id in this case
// to determine which CIN configuration the sensor should be in.
auto handler = CapacitiveMessageHandler{
*writer, *poller, *hardware, *can_client,
get_queue(), shared_task, p_buff};
get_queue(), shared_task, sensor_buffer};
handler.initialize();
utils::TaskMessage message{};
for (;;) {
Expand Down
12 changes: 6 additions & 6 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class MMR920 {
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id,
const sensors::mmr920::SensorVersion version,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff)
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer)
: writer(writer),
poller(poller),
can_client(can_client),
own_queue(own_queue),
hardware(hardware),
sensor_id(id),
sensor_version(version),
p_buff(p_buff) {}
sensor_buffer(sensor_buffer) {}

/**
* @brief Check if the MMR92 has been initialized.
Expand Down Expand Up @@ -290,12 +290,12 @@ class MMR920 {
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data =
mmr920::reading_to_fixed_point((*p_buff).at(i))});
mmr920::reading_to_fixed_point((*sensor_buffer).at(i))});
if (i % 10 == 0) {
// slow it down so the can buffer doesn't choke
vTaskDelay(50);
}
(*p_buff).at(i) = 0;
(*sensor_buffer).at(i) = 0;
}
#else
std::ignore = message_index;
Expand Down Expand Up @@ -362,7 +362,7 @@ class MMR920 {
auto response_pressure = pressure - current_pressure_baseline_pa;
#ifdef USE_SENSOR_MOVE
if (sensor_buffer_index < SENSOR_BUFFER_SIZE) {
(*p_buff).at(sensor_buffer_index) = response_pressure;
(*sensor_buffer).at(sensor_buffer_index) = response_pressure;
sensor_buffer_index++;
}
#else
Expand Down Expand Up @@ -558,7 +558,7 @@ class MMR920 {
value &= Reg::value_mask;
return write(Reg::address, value);
}
std::array<float, SENSOR_BUFFER_SIZE> *p_buff;
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer;
uint16_t sensor_buffer_index = 0;
};

Expand Down
8 changes: 4 additions & 4 deletions include/sensors/core/tasks/pressure_sensor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class PressureMessageHandler {
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id,
const sensors::mmr920::SensorVersion &version,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff)
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer)
: driver{i2c_writer, i2c_poller, can_client, own_queue,
hardware, id, version, p_buff} {}
hardware, id, version, sensor_buffer} {}
PressureMessageHandler(const PressureMessageHandler &) = delete;
PressureMessageHandler(const PressureMessageHandler &&) = delete;
auto operator=(const PressureMessageHandler &)
Expand Down Expand Up @@ -204,10 +204,10 @@ class PressureSensorTask {
i2c::poller::Poller<QueueImpl> *poller, CanClient *can_client,
sensors::hardware::SensorHardwareBase *hardware,
sensors::mmr920::SensorVersion *sensor_version,
std::array<float, SENSOR_BUFFER_SIZE> *p_buff) {
std::array<float, SENSOR_BUFFER_SIZE> *sensor_buffer) {
auto handler = PressureMessageHandler{
*writer, *poller, *can_client, get_queue(),
*hardware, sensor_id, *sensor_version, p_buff};
*hardware, sensor_id, *sensor_version, sensor_buffer};
handler.initialize();
utils::TaskMessage message{};
for (;;) {
Expand Down
8 changes: 4 additions & 4 deletions pipettes/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function(target_pipettes_core_single TARGET REVISION)
target_pipettes_core_common(${TARGET} ${REVISION})
target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=SINGLE_CHANNEL)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=2800)
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500)
endif()
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/can_task_low_throughput.cpp)
Expand All @@ -28,7 +28,7 @@ function(target_pipettes_core_multi TARGET REVISION)
target_pipettes_core_common(${TARGET} ${REVISION})
target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=EIGHT_CHANNEL)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1700)
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=500)
target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true)
endif()
target_sources(${TARGET} PUBLIC
Expand All @@ -39,7 +39,7 @@ function(target_pipettes_core_96 TARGET REVISION)
target_pipettes_core_common(${TARGET} ${REVISION})
target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=NINETY_SIX_CHANNEL)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=800)
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=800)
target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true)
endif()
target_sources(${TARGET} PUBLIC
Expand All @@ -50,7 +50,7 @@ function(target_pipettes_core_384 TARGET REVISION)
target_pipettes_core_common(${TARGET} ${REVISION})
target_compile_definitions(${TARGET} PUBLIC PIPETTE_TYPE_DEFINE=THREE_EIGHTY_FOUR_CHANNEL)
if(${USE_SENSOR_MOVE})
target_compile_definitions(${TARGET} PUBLIC P_BUFF_SIZE=1500)
target_compile_definitions(${TARGET} PUBLIC SENSOR_BUFF_SIZE=1500)
target_compile_definitions(${TARGET} PUBLIC USE_TWO_BUFFERS=true)
endif()
target_sources(${TARGET} PUBLIC
Expand Down
20 changes: 10 additions & 10 deletions pipettes/core/sensor_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

static auto tasks = sensor_tasks::Tasks{};
static auto queue_client = sensor_tasks::QueueClient{};
static std::array<float, SENSOR_BUFFER_SIZE> p_buff;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer;
#ifdef USE_TWO_BUFFERS
static std::array<float, SENSOR_BUFFER_SIZE> p_buff_front;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer_front;
#endif
static auto eeprom_task_builder =
freertos_task::TaskStarter<512, eeprom::task::EEPromTask>{};
Expand Down Expand Up @@ -73,11 +73,11 @@ void sensor_tasks::start_tasks(
5, "enviro sensor", i2c3_task_client, i2c3_poller_client, queues);
auto& pressure_sensor_task_rear = pressure_sensor_task_builder_rear.start(
5, "pressure sensor s0", pressure_i2c_client, pressure_i2c_poller,
queues, sensor_hardware_primary, sensor_version, p_buff);
queues, sensor_hardware_primary, sensor_version, sensor_buffer);
auto& capacitive_sensor_task_rear =
capacitive_sensor_task_builder_rear.start(
5, "capacitive sensor s0", i2c3_task_client, i2c3_poller_client,
sensor_hardware_primary, queues, p_buff);
sensor_hardware_primary, queues, sensor_buffer);
auto& tip_notification_task_rear = tip_notification_task_builder_rear.start(
5, "tip notification sensor s0", queues, sensor_hardware_primary);

Expand Down Expand Up @@ -139,23 +139,23 @@ void sensor_tasks::start_tasks(
auto& pressure_sensor_task_rear = pressure_sensor_task_builder_rear.start(
5, "pressure sensor s0", primary_pressure_i2c_client,
primary_pressure_i2c_poller, queues, sensor_hardware_primary,
sensor_version, p_buff);
sensor_version, sensor_buffer);
auto& pressure_sensor_task_front = pressure_sensor_task_builder_front.start(
5, "pressure sensor s1", secondary_pressure_i2c_client,
secondary_pressure_i2c_poller, queues, sensor_hardware_secondary,
sensor_version,
#ifdef USE_TWO_BUFFERS
p_buff_front);
sensor_buffer_front);
#else
// we don't want to build a second buffer for the single channel, but if
// we dont pass in the correct sized array here, compilation fails
// this doesn't matter though cause single channels will never call this
p_buff);
sensor_buffer);
#endif
auto& capacitive_sensor_task_rear =
capacitive_sensor_task_builder_rear.start(
5, "capacitive sensor s0", i2c3_task_client, i2c3_poller_client,
sensor_hardware_primary, queues, p_buff, shared_cap_task);
sensor_hardware_primary, queues, sensor_buffer, shared_cap_task);
auto& tip_notification_task_rear = tip_notification_task_builder_rear.start(
5, "tip notification sensor s0", queues, sensor_hardware_primary);

Expand Down Expand Up @@ -190,9 +190,9 @@ void sensor_tasks::start_tasks(
5, "capacitive sensor s1", i2c2_task_client, i2c2_poller_client,
sensor_hardware_secondary, queues,
#ifdef USE_TWO_BUFFERS
p_buff_front);
sensor_buffer_front);
#else
p_buff);
sensor_buffer);
#endif
tasks.capacitive_sensor_task_front = &capacitive_sensor_task_front;
queues.capacitive_sensor_queue_front =
Expand Down
10 changes: 5 additions & 5 deletions sensors/tests/test_capacitive_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ auto get_message_i2c(Queue& q) -> Message {
auto sensor_id = can::ids::SensorId::S0;
constexpr uint8_t sensor_id_int = 0x0;

static std::array<float, SENSOR_BUFFER_SIZE> p_buff;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer;

SCENARIO("read capacitance sensor values without shared CINs") {
test_mocks::MockSensorHardware mock_hw{};
Expand All @@ -55,7 +55,7 @@ SCENARIO("read capacitance sensor values without shared CINs") {
poller.set_queue(&poller_queue);

auto sensor_not_shared = sensors::tasks::CapacitiveMessageHandler{
writer, poller, mock_hw, queue_client, response_queue, false, &p_buff};
writer, poller, mock_hw, queue_client, response_queue, false, &sensor_buffer};
constexpr uint8_t capacitive_id = 0x1;

GIVEN("a initialize sensor request") {
Expand Down Expand Up @@ -383,7 +383,7 @@ SCENARIO("read capacitance sensor values supporting shared CINs") {
poller.set_queue(&poller_queue);

auto sensor_shared = sensors::tasks::CapacitiveMessageHandler{
writer, poller, mock_hw, queue_client, response_queue, true, &p_buff};
writer, poller, mock_hw, queue_client, response_queue, true, &sensor_buffer};
constexpr uint8_t capacitive_id = 0x1;

GIVEN("a initialize sensor request") {
Expand Down Expand Up @@ -581,7 +581,7 @@ SCENARIO("capacitance driver tests no shared CINs") {
queue_client.set_queue(&can_queue);
writer.set_queue(&i2c_queue);
sensors::tasks::FDC1004 callback_host(
writer, poller, queue_client, response_queue, mock_hw, false, &p_buff);
writer, poller, queue_client, response_queue, mock_hw, false, &sensor_buffer);

can::message_writer_task::TaskMessage empty_msg{};

Expand Down Expand Up @@ -771,7 +771,7 @@ SCENARIO("threshold configuration") {
poller.set_queue(&poller_queue);

auto sensor = sensors::tasks::CapacitiveMessageHandler{
writer, poller, mock_hw, queue_client, response_queue, false, &p_buff};
writer, poller, mock_hw, queue_client, response_queue, false, &sensor_buffer};

GIVEN("A request to set an autothreshold") {
int NUM_READS = 10;
Expand Down
4 changes: 2 additions & 2 deletions sensors/tests/test_pressure_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ auto get_message(Queue& q) -> Message {

constexpr auto sensor_id = can::ids::SensorId::S0;
constexpr uint8_t sensor_id_int = 0x0;
static std::array<float, SENSOR_BUFFER_SIZE> p_buff;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer;

SCENARIO("Testing the pressure sensor driver") {
test_mocks::MockMessageQueue<i2c::writer::TaskMessage> i2c_queue{};
Expand All @@ -61,7 +61,7 @@ SCENARIO("Testing the pressure sensor driver") {
poller.set_queue(&i2c_poll_queue);
sensors::tasks::MMR920 driver(
writer, poller, queue_client, pressure_queue, hardware, sensor_id,
sensors::mmr920::SensorVersion::mmr920c04, &p_buff);
sensors::mmr920::SensorVersion::mmr920c04, &sensor_buffer);

can::message_writer_task::TaskMessage empty_can_msg{};

Expand Down
4 changes: 2 additions & 2 deletions sensors/tests/test_pressure_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constexpr uint8_t pressure_temperature_id =
static_cast<uint8_t>(can::ids::SensorType::pressure_temperature);
constexpr uint8_t sensor_id_int = 0x0;

static std::array<float, SENSOR_BUFFER_SIZE> p_buff;
static std::array<float, SENSOR_BUFFER_SIZE> sensor_buffer;

SCENARIO("Receiving messages through the pressure sensor message handler") {
test_mocks::MockMessageQueue<i2c::writer::TaskMessage> i2c_queue{};
Expand Down Expand Up @@ -65,7 +65,7 @@ SCENARIO("Receiving messages through the pressure sensor message handler") {
mock_hw,
sensor_id,
sensors::mmr920::SensorVersion::mmr920c04,
&p_buff};
&sensor_buffer};

GIVEN("A TransactionResponse message") {
can_queue.reset();
Expand Down

0 comments on commit 7e89b0f

Please sign in to comment.