Skip to content

Feat hardware component test#18

Merged
NestorDP merged 20 commits intomainfrom
feat-hardware-component-test
Jan 28, 2026
Merged

Feat hardware component test#18
NestorDP merged 20 commits intomainfrom
feat-hardware-component-test

Conversation

@NestorDP
Copy link
Copy Markdown
Owner

Pull Request

Description

Add unit test infrastructure for hadware component

Related Issue(s)

  • NA

Checklist

  • I have tested this code thoroughly.
  • My code follows the project's coding standards.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a unit-testable hardware/driver stack by refactoring the serial/codec payloads to use byte buffers, introducing driver interfaces/factories, and expanding the test suite.

Changes:

  • Switch serial port, driver, and codec payloads from std::string to std::vector<uint8_t>.
  • Introduce ILittlebotDriver + createLittlebotDriver() and update LittlebotHardwareComponent to use the factory.
  • Update/add unit tests and mocks to cover the refactored interfaces.

Reviewed changes

Copilot reviewed 20 out of 23 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
littlebot_base/test/test_serial_port.cpp Updates serial framing tests for byte payloads.
littlebot_base/test/test_littlebot_hardware_component.cpp Adds a minimal on_init success test using constructed HardwareInfo.
littlebot_base/test/test_littlebot_driver.cpp Updates driver tests to use byte payloads and protobuf encode/decode flow.
littlebot_base/test/mock_serial_port.hpp Updates mock to match new ISerialPort byte-based API.
littlebot_base/test/mock_littlebot_driver.hpp Adds a driver mock interface for future hardware-component tests.
littlebot_base/src/serial_port.cpp Refactors serial buffering/framing to bytes and changes open/framing behavior.
littlebot_base/include/littlebot_base/serial_port.hpp Updates SerialPort public API to bytes and adjusts test injection.
littlebot_base/include/littlebot_base/i_serial_port.hpp Updates interface to bytes, adds isOpen(), switches RX buffer storage type.
littlebot_base/src/codec.cpp Moves protobuf encode/decode to std::vector<uint8_t> based IO.
littlebot_base/include/littlebot_base/codec.hpp Updates codec API signatures to bytes.
littlebot_base/include/littlebot_base/i_littlebot_driver.hpp Adds driver interface used for injection and factory return types.
littlebot_base/src/littlebot_driver.cpp Implements ILittlebotDriver, updates request/send flows to byte payloads.
littlebot_base/include/littlebot_base/littlebot_driver.hpp Makes driver implement ILittlebotDriver and updates method signatures.
littlebot_base/src/littlebot_driver_factory.cpp Adds factory that creates/opens SerialPort + RT buffers + driver.
littlebot_base/include/littlebot_base/littlebot_driver_factory.hpp Declares driver factory API.
littlebot_base/src/littlebot_hardware_component.cpp Uses driver factory during configure and stores driver as interface type.
littlebot_base/include/littlebot_base/littlebot_hardware_component.hpp Adds test-focused injection constructor; switches stored driver to interface type.
littlebot_base/include/littlebot_base/types.hpp Clarifies enum comment numbering for error codes.
littlebot_base/scripts/run_tests.sh Forces Debug build type when running tests.
littlebot_base/CMakeLists.txt Adds new factory source to the driver library build.
docs/figures/littlebot_driver_sequence_request.png Adds sequence diagram figure asset.
Comments suppressed due to low confidence (1)

littlebot_base/src/codec.cpp:67

  • decode() resizes wheels, which default-constructs new Wheel objects and overwrites existing joint names/metadata (contradicting the header comment about preserving metadata). This also mutates LittlebotDriver::wheels_ size during status reads. Instead, validate the received size matches the existing vector (or update only up to min(size, wheels.size()) and report SizeMismatch).
  const int num_of_side_wheels = received_wheels_data.side_size();
  wheels.resize(num_of_side_wheels);

  for (int i = 0; i < num_of_side_wheels; ++i) {
    const auto & wheel_data = received_wheels_data.side(i);
    wheels[i].setCommandVelocity(wheel_data.command_velocity());
    wheels[i].setStatusVelocity(wheel_data.status_velocity());
    wheels[i].setStatusPosition(wheel_data.status_position());
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NestorDP NestorDP merged commit 9d94f61 into main Jan 28, 2026
0 of 2 checks passed
@NestorDP NestorDP deleted the feat-hardware-component-test branch January 28, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants