Skip to content

refactor(api)!: Add board aliases and prefix IMU views#63

Merged
qzhhhi merged 2 commits into
mainfrom
dev/alias
Jul 4, 2026
Merged

refactor(api)!: Add board aliases and prefix IMU views#63
qzhhhi merged 2 commits into
mainfrom
dev/alias

Conversation

@qzhhhi

@qzhhhi qzhhhi commented Jul 4, 2026

Copy link
Copy Markdown
Member

Add Spec and View aliases to host board callback classes to shorten repeated descriptor and data view type names.

Use the shorter board callback aliases to rename IMU data view types with explicit IMU prefixes:

  • AccelerometerDataView -> ImuAccelerometerDataView
  • GyroscopeDataView -> ImuGyroscopeDataView
  • TemperatureDataView -> ImuTemperatureDataView

Update serializer, deserializer, host callbacks, and firmware callbacks to use the new IMU view names.

BREAKING CHANGE: Downstream code that references the old IMU data view names or overrides IMU callbacks must use the new Imu*DataView names.

本次变更重构了 board/协议相关的公开接口,主要包括:

  • 为 host 端 board 回调引入 SpecView 两个嵌套别名,减少重复书写 descriptor 和 data view 类型名。
  • 将 IMU 数据视图类型统一改名为更明确的前缀形式:
    • AccelerometerDataViewImuAccelerometerDataView
    • GyroscopeDataViewImuGyroscopeDataView
    • TemperatureDataViewImuTemperatureDataView
  • 同步更新了序列化、反序列化、host 回调以及 firmware 回调中所有相关方法签名与调用点,改为使用新的 IMU 视图类型。
  • host/src/protocol/handler.cppcore/src/protocol/* 中对应的 IMU 读写逻辑保持不变,仅类型名更新。

这是一个破坏性变更:下游代码若引用旧的 IMU data view 类型或覆盖相关回调,需要切换到新的 Imu*DataView 名称。

Add Spec and View aliases to host board callback classes to shorten repeated descriptor and data view type names.

Use the shorter board callback aliases to rename IMU data view types with explicit IMU prefixes:
- AccelerometerDataView -> ImuAccelerometerDataView
- GyroscopeDataView -> ImuGyroscopeDataView
- TemperatureDataView -> ImuTemperatureDataView

Update serializer, deserializer, host callbacks, and firmware callbacks to use the new IMU view names.

BREAKING CHANGE: Downstream code that references the old IMU data view names or overrides IMU callbacks must use the new Imu*DataView names.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@qzhhhi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d8dae7d8-c68f-4564-8809-68b9eba5c6fa

📥 Commits

Reviewing files that changed from the base of the PR and between cbfbc57 and e743397.

📒 Files selected for processing (3)
  • host/include/librmcs/board/c_board.hpp
  • host/include/librmcs/board/rmcs_board_lite.hpp
  • host/include/librmcs/board/rmcs_board_pro.hpp

Walkthrough

本次改动将 IMU 相关数据视图结构体(加速度计、陀螺仪、温度)重命名为带 Imu 前缀的类型,并在核心序列化/反序列化、固件与主机端各回调接口中同步更新参数类型;同时在主机端多个 Callback 类中新增 Spec/View 嵌套类型别名以统一封装描述符与数据视图类型。

Changes

IMU 数据视图重命名与 Callback 类型分组

Layer / File(s) Summary
核心数据视图与回调契约重命名
core/include/librmcs/data/datas.hpp
AccelerometerDataView/GyroscopeDataView/TemperatureDataView 重命名为 Imu*DataViewDataCallback 接口回调参数类型同步更新。
序列化/反序列化层类型同步
core/src/protocol/deserializer.hpp, core/src/protocol/deserializer.cpp, core/src/protocol/serializer.hpp
IMU 相关反序列化/序列化方法参数类型替换为新的 Imu*DataView,内部逻辑不变。
固件端 Vendor 回调类型更新
firmware/c_board/app/src/usb/vendor.hpp, firmware/rmcs_board/app/src/usb/vendor.hpp
Vendor 反序列化回调参数类型改为 Imu*DataView,占位实现保持不变。
主机端 Callback 新增 Spec/View 类型别名与签名更新
host/include/librmcs/board/c_board.hpp, host/include/librmcs/board/rmcs_board_lite.hpp, host/include/librmcs/board/rmcs_board_pro.hpp
三个 Callback 类新增 Spec/View 嵌套结构体,统一 CAN/UART/GPIO 描述符与数据视图,以及 IMU 数据视图别名,虚函数签名相应更新。
主机端 Handler 回调与打包类型同步
host/src/protocol/handler.cpp
Handler::Impl 反序列化回调与 PacketBuilder 写入方法参数类型改为 Imu*DataView,逻辑保持一致。

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • Alliance-Algorithm/librmcs#11: 引入了 core/include/librmcs/data/datas.hpp 中的 IMU 数据视图与 IDataCallback 声明,与本次重命名直接相关。
  • Alliance-Algorithm/librmcs#54: 同样修改了 IMU 数据视图/回调管线及温度回调处理路径,与本次改动存在重叠。

Poem

加速度计换新装,
Imu 前缀闪光芒,
陀螺温度齐上阵,
Spec View 分好类型,
兔子蹦跳码间跃 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次 API 重构:新增 board 别名并将 IMU 视图改为 Imu* 前缀。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/alias

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
host/include/librmcs/board/c_board.hpp (1)

46-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

gpio_analog_read_result_callback 补充 View::GpioAnalog 别名,并统一 IMU 别名的命名空间限定风格。

View 结构体已经为 Can/Uart/GpioDigital 建立别名,但 gpio_analog_read_result_callback 的数据视图形参仍直接写 librmcs::data::GpioAnalogDataView,与本次重构“用 Spec/View 别名收敛重复类型名”的目标不一致。另外,三个 IMU 别名使用了完整限定 librmcs::data::Imu*DataView,而其余别名使用短限定 data::*DataView,风格不统一。

♻️ 建议的重构
         struct View {
             using Can = data::CanDataView;
             using Uart = data::UartDataView;
             using GpioDigital = data::GpioDigitalDataView;
-            using ImuAccelerometer = librmcs::data::ImuAccelerometerDataView;
-            using ImuGyroscope = librmcs::data::ImuGyroscopeDataView;
-            using ImuTemperature = librmcs::data::ImuTemperatureDataView;
+            using GpioAnalog = data::GpioAnalogDataView;
+            using ImuAccelerometer = data::ImuAccelerometerDataView;
+            using ImuGyroscope = data::ImuGyroscopeDataView;
+            using ImuTemperature = data::ImuTemperatureDataView;
         };
...
         virtual void gpio_analog_read_result_callback(
-            const Spec::Gpio& gpio, const librmcs::data::GpioAnalogDataView& data) {
+            const Spec::Gpio& gpio, const View::GpioAnalog& data) {
             (void)gpio;
             (void)data;
         }

Also applies to: 70-74

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@host/include/librmcs/board/c_board.hpp` around lines 46 - 53, Summary: add
the missing View alias for GpioAnalog and make the IMU alias naming consistent.
Update the board::View struct in c_board.hpp to include a GpioAnalog alias
alongside Can/Uart/GpioDigital, then adjust gpio_analog_read_result_callback to
use that View alias instead of the fully qualified
librmcs::data::GpioAnalogDataView. While touching View, normalize the IMU
aliases so they follow the same data::*DataView style as the other entries,
using the existing View symbols to keep the API consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@host/include/librmcs/board/c_board.hpp`:
- Around line 46-53: Summary: add the missing View alias for GpioAnalog and make
the IMU alias naming consistent. Update the board::View struct in c_board.hpp to
include a GpioAnalog alias alongside Can/Uart/GpioDigital, then adjust
gpio_analog_read_result_callback to use that View alias instead of the fully
qualified librmcs::data::GpioAnalogDataView. While touching View, normalize the
IMU aliases so they follow the same data::*DataView style as the other entries,
using the existing View symbols to keep the API consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f01012a-6f60-41ba-bb17-f3040f196d80

📥 Commits

Reviewing files that changed from the base of the PR and between b629e69 and cbfbc57.

📒 Files selected for processing (10)
  • core/include/librmcs/data/datas.hpp
  • core/src/protocol/deserializer.cpp
  • core/src/protocol/deserializer.hpp
  • core/src/protocol/serializer.hpp
  • firmware/c_board/app/src/usb/vendor.hpp
  • firmware/rmcs_board/app/src/usb/vendor.hpp
  • host/include/librmcs/board/c_board.hpp
  • host/include/librmcs/board/rmcs_board_lite.hpp
  • host/include/librmcs/board/rmcs_board_pro.hpp
  • host/src/protocol/handler.cpp

@qzhhhi qzhhhi merged commit ce221e5 into main Jul 4, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in RMCS Slave SDK Jul 4, 2026
@qzhhhi qzhhhi deleted the dev/alias branch July 4, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant