Conversation
There was a problem hiding this comment.
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::stringtostd::vector<uint8_t>. - Introduce
ILittlebotDriver+createLittlebotDriver()and updateLittlebotHardwareComponentto 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()resizeswheels, which default-constructs newWheelobjects and overwrites existing joint names/metadata (contradicting the header comment about preserving metadata). This also mutatesLittlebotDriver::wheels_size during status reads. Instead, validate the received size matches the existing vector (or update only up tomin(size, wheels.size())and reportSizeMismatch).
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Add unit test infrastructure for hadware component
Related Issue(s)
Checklist