Merge downstream gimbal control for flight#48
Merge downstream gimbal control for flight#48Embers-of-the-Fire wants to merge 5 commits intoAlliance-Algorithm:flightfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
总体概览这个PR引入了Flight硬件组件、增强了脚本功能、更新了Docker配置和环境设置、删除了GitHub Actions工作流,并添加了新的RMCS飞行配置。跨越基础设施、脚本、容器配置和核心硬件控制等多个方面。 变更
序列图sequenceDiagram
participant CAN as CAN总线
participant Flight as Flight硬件组件
participant Motor as 电机驱动<br/>(云台/摩擦轮)
participant IMU as IMU传感器
participant TF as TF坐标框架
participant UART as UART通信<br/>(裁判系统)
Flight->>Motor: 初始化电机参数<br/>(yaw/pitch/摩擦轮)
Flight->>TF: 构建坐标树<br/>(基座/轮/云台)
Flight->>UART: 连接裁判系统<br/>(环形缓冲)
rect rgb(100, 200, 150, 0.5)
Note over Flight: 主循环update()
Flight->>Motor: 读取电机状态
Motor-->>Flight: 返回电机反馈
Flight->>IMU: 更新IMU数据
IMU-->>Flight: 返回加速度/角速度
Flight->>TF: 发布IMU坐标变换
end
rect rgb(150, 150, 200, 0.5)
Note over Flight: 命令更新command_update()
Flight->>CAN: 组装CAN消息<br/>(yaw/pitch/执行器)
CAN-->>Flight: 响应CAN传输
end
CAN-->>Flight: CAN回调<br/>(ID解析)
Flight->>Flight: 缓存电机状态
UART-->>Flight: UART回调<br/>(裁判数据)
Flight->>Flight: 更新裁判状态缓冲
审查工作量估计🎯 4 (复杂) | ⏱️ ~60 分钟 相关PR
建议审查者
诗歌
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
42c3f9a to
bb55566
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rmcs_ws/src/rmcs_executor/include/rmcs_executor/component.hpp (1)
138-149:⚠️ Potential issue | 🟠 Major添加显式
<concepts>包含以保证std::constructible_from的可用性。
代码在第 138-149 行使用了std::constructible_from的 requires 约束,但当前头文件未显式包含<concepts>头文件。虽然某些标准库实现可能通过间接包含提供此概念,但为保证代码在不同编译器和标准库实现下的可移植性和稳定性,应显式包含此头文件。建议修复
`#include` <map> `#include` <memory> `#include` <new> +#include <concepts> `#include` <stdexcept> `#include` <string> `#include` <type_traits>
🤖 Fix all issues with AI agents
In @.script/play-autoaim:
- Around line 63-68: The script uses set -e which causes the shell to exit
before the custom error message runs when scp fails; replace the separate scp
then "$?" check with a single conditional that captures scp's failure (for
example: if ! scp "${SDP_PATH}" "${MONITOR_USER}@${MONITOR_HOST}:${SDP_PATH}";
then echo " scp 拷贝失败"; exit 1; fi) or temporarily disable errexit around the
scp (set +e; scp ... || { echo "..."; exit 1; }; set -e). Update the block that
references SKIP_COPY and the scp command so the error message is printed
reliably on failure.
- Around line 48-60: The script sets set -e which causes the scp command to
abort the whole script before your manual error handling runs; modify the scp
invocation so its failure is caught instead of triggering errexit — for example
change the scp line to run in a conditional (if ! scp remote:${SDP_PATH}
${SDP_PATH}; then …) or temporarily disable errexit around scp (set +e before
scp and set -e after) and then keep the existing $? -ne 0 branch that prompts
the user; ensure you reference the USE_REMOTE check and the scp
remote:${SDP_PATH} ${SDP_PATH} invocation and preserve the subsequent
interactive prompt logic.
In `@Dockerfile`:
- Around line 96-108: Replace the third-party Tsinghua mirror URL used when
adding the LLVM apt source with the official apt.llvm.org URL: update the echo
that writes the sources list (the line creating
/etc/apt/sources.list.d/llvm.list) to use "http://apt.llvm.org/noble/"
(preserving the [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] token and the
"llvm-toolchain-noble-22 main" suite), keep the existing GPG key fetch (the wget
| gpg --dearmor step) and the subsequent apt-get
install/update-alternatives/cleanup commands unchanged so the rest of the RUN
block (installing clang-22, clangd-22, clang-format-22, lldb-22 and configuring
update-alternatives) continues to work as before.
In `@rmcs_ws/src/rmcs_core/src/controller/gimbal/two_axis_gimbal_solver.hpp`:
- Line 3: 头文件 librmcs/utility/logging.hpp 在 two_axis_gimbal_solver.hpp
中被包含但未使用,因为所有 LOG_INFO 调用已被注释(参见被注释的 LOG_INFO 在第 113-115 行和第 212-213
行);请修复:要么直接移除该 include 语句以消除未使用包含和静态分析警告,要么恢复这些被注释的 LOG_INFO 调用(保留正确的上下文变量)以重新使用
logging.hpp;在修复时参考包含语句和 LOG_INFO 标识符以定位修改点。
- Around line 183-198: The yaw-limit branch currently only scales the x
component (using yaw_projection.x()), which breaks directional consistency
versus the pitch-limit logic; change the branches that handle y_ >
yaw_upper_limit_.y() and y_ < yaw_lower_limit_.y() to scale the entire
yaw_projection vector (e.g., scaled = yaw_projection * yaw_upper_limit_.x() or *
yaw_lower_limit_.x()) and then assign both x and y from that scaled vector,
while scaling z_ by the same factor to preserve the x/z ratio; update references
to control_direction, yaw_projection, yaw_upper_limit_, and yaw_lower_limit_
accordingly.
In `@rmcs_ws/src/rmcs_core/src/hardware/flight.cpp`:
- Around line 75-82: The wheel transform coordinates in flight.cpp are incorrect
for LeftBackWheelLink, RightBackWheelLink, and RightFrontWheelLink; update the
Eigen::Translation3d arguments passed to tf_->set_transform for the specific
templates LeftBackWheelLink, RightBackWheelLink, and RightFrontWheelLink so they
match the standard layout used in infantry.cpp (front = +x, back = -x, left =
+y, right = -y): ensure LeftBackWheelLink uses (-rotor_distance_x/2,
+rotor_distance_y/2, 0), RightBackWheelLink uses (-rotor_distance_x/2,
-rotor_distance_y/2, 0), and RightFrontWheelLink uses (+rotor_distance_x/2,
-rotor_distance_y/2, 0) while leaving LeftFrontWheelLink unchanged.
🧹 Nitpick comments (7)
.script/template/env_setup.zsh (1)
20-22: 建议:考虑添加compinit缓存以优化启动性能。每次 shell 启动时执行
compinit可能会导致轻微的性能开销。可以考虑添加缓存检查:♻️ 可选优化
fpath=(${RMCS_PATH}/.script/complete $fpath) autoload -Uz compinit -compinit +if [[ -n ${ZDOTDIR}/.zcompdump(`#qN.mh`+24) ]]; then + compinit +else + compinit -C +fi这将在缓存文件超过 24 小时时才重新生成补全缓存,可显著加速 shell 启动。
.script/foxglove (1)
1-5: 建议:添加错误处理并统一 shebang 格式。
- Shebang 格式
#! /bin/bash与其他脚本(如env_setup.bash使用#!/bin/bash)不一致- 如果
env_setup.bash不存在,脚本会静默失败♻️ 建议修改
-#! /bin/bash +#!/bin/bash + +set -e -source ~/env_setup.bash +if [[ -f ~/env_setup.bash ]]; then + source ~/env_setup.bash +else + echo "Error: ~/env_setup.bash not found" >&2 + exit 1 +fi ros2 launch foxglove_bridge foxglove_bridge_launch.xml port:=8765docker-compose.yml (1)
4-4: 注意:硬编码的用户 ID 假设。将
user从${CONTAINER_USER}改为硬编码的"1000:1000"假设主机用户的 UID/GID 始终为 1000。如果开发者的 UID 不同,可能会导致权限问题。鉴于这是开发容器配置,此简化是可以接受的,但建议在文档或注释中说明此假设。
Based on learnings: "In the RMCS repository, development containers are configured via docker-compose.yml. For development environments, it is acceptable to mount broader user config directories..."
rmcs_ws/src/rmcs_core/src/hardware/flight.cpp (2)
213-219: 建议将flight_成员设为私有。
FlightCommand类中的flight_成员当前为 public,但只在update()方法内部使用。将其设为 private 可以更好地封装内部状态。♻️ 建议修改
class FlightCommand : public rmcs_executor::Component { public: explicit FlightCommand(Flight& flight) : flight_(flight) {} void update() override { flight_.command_update(); } + +private: Flight& flight_; };
42-42: 建议为 BMI088 初始化参数添加注释或命名常量。
bmi088_(500.0, 0.3, 0.005)中的魔法数字含义不明确,建议添加注释说明各参数的用途(如采样率、滤波系数等)。rmcs_ws/src/rmcs_core/plugins.xml (1)
11-13: 建议更新插件描述。
description当前为 "Test plugin.",建议更新为更具描述性的内容,如 "Flight hardware component for gimbal control"。rmcs_ws/src/rmcs_bringup/config/flight.yaml (1)
64-69: 限位参数命名可能引起混淆。
upper_limit: -0.149的数值比lower_limit: 0.149小,这种命名方式容易造成误解。建议在配置文件中添加注释说明这些值的含义(如角度方向约定)。
rmcs_ws/src/rmcs_core/src/controller/gimbal/two_axis_gimbal_solver.hpp
Outdated
Show resolved
Hide resolved
| tf_->set_transform<BaseLink, LeftFrontWheelLink>( | ||
| Eigen::Translation3d{rotor_distance_x / 2, rotor_distance_y / 2, 0}); | ||
| tf_->set_transform<BaseLink, LeftBackWheelLink>( | ||
| Eigen::Translation3d{rotor_distance_x / 2, -rotor_distance_y / 2, 0}); | ||
| tf_->set_transform<BaseLink, RightBackWheelLink>( | ||
| Eigen::Translation3d{-rotor_distance_x / 2, rotor_distance_y / 2, 0}); | ||
| tf_->set_transform<BaseLink, RightFrontWheelLink>( | ||
| Eigen::Translation3d{-rotor_distance_x / 2, -rotor_distance_y / 2, 0}); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, find and examine the flight.cpp file
find . -name "flight.cpp" -type f | head -5Repository: Alliance-Algorithm/RMCS
Length of output: 114
🏁 Script executed:
# Search for the specific file mentioned
find . -path "*rmcs_core/src/hardware/flight.cpp" -type fRepository: Alliance-Algorithm/RMCS
Length of output: 114
🏁 Script executed:
# Broader search for flight-related files
find . -name "*flight*" -type f | grep -E "\.(cpp|hpp|h)$"Repository: Alliance-Algorithm/RMCS
Length of output: 114
🏁 Script executed:
# Search for WheelLink references in the codebase
rg -n "WheelLink" --type cpp -C 2Repository: Alliance-Algorithm/RMCS
Length of output: 11568
🏁 Script executed:
# Look for any coordinate system or wheel position documentation
rg -n "(wheel|coordinate|position)" --type cpp -i | head -50Repository: Alliance-Algorithm/RMCS
Length of output: 5837
🏁 Script executed:
# Verify the exact lines once more to be absolutely certain
sed -n '75,82p' ./rmcs_ws/src/rmcs_core/src/hardware/flight.cppRepository: Alliance-Algorithm/RMCS
Length of output: 630
🏁 Script executed:
# Check infantry.cpp for comparison
sed -n '93,100p' ./rmcs_ws/src/rmcs_core/src/hardware/infantry.cppRepository: Alliance-Algorithm/RMCS
Length of output: 630
轮子位置坐标全部错误,需要立即修正。
与 infantry.cpp 和 tunnel_infantry.cpp 中的标准布局对比,flight.cpp 中三个轮子的坐标均不正确:
| 轮子 | 当前坐标 | 正确坐标 | 说明 |
|---|---|---|---|
| LeftFrontWheelLink | (+x/2, +y/2) | (+x/2, +y/2) | ✓ 正确 |
| LeftBackWheelLink | (+x/2, -y/2) | (-x/2, +y/2) | ✗ x坐标错误 |
| RightBackWheelLink | (-x/2, +y/2) | (-x/2, -y/2) | ✗ y坐标错误 |
| RightFrontWheelLink | (-x/2, -y/2) | (+x/2, -y/2) | ✗ x坐标错误 |
标准约定:前轮在 +x,后轮在 -x;左轮在 +y,右轮在 -y。
参考实现可查看 infantry.cpp 第 93-100 行的正确布局。
🤖 Prompt for AI Agents
In `@rmcs_ws/src/rmcs_core/src/hardware/flight.cpp` around lines 75 - 82, The
wheel transform coordinates in flight.cpp are incorrect for LeftBackWheelLink,
RightBackWheelLink, and RightFrontWheelLink; update the Eigen::Translation3d
arguments passed to tf_->set_transform for the specific templates
LeftBackWheelLink, RightBackWheelLink, and RightFrontWheelLink so they match the
standard layout used in infantry.cpp (front = +x, back = -x, left = +y, right =
-y): ensure LeftBackWheelLink uses (-rotor_distance_x/2, +rotor_distance_y/2,
0), RightBackWheelLink uses (-rotor_distance_x/2, -rotor_distance_y/2, 0), and
RightFrontWheelLink uses (+rotor_distance_x/2, -rotor_distance_y/2, 0) while
leaving LeftFrontWheelLink unchanged.
0f59d7a to
e89679b
Compare
合并下游 Gimbal 控制用于飞行
概述
本PR将下游 gimbal 分支的改动合并到 flight 分支,主要涉及飞行硬件集成、Gimbal 控制器增强以及开发环境优化。
主要改动
硬件集成
新增 Flight 硬件组件 (
rmcs_core/src/hardware/flight.cpp):实现了完整的飞行硬件管理器,集成了多个硬件子系统:插件注册:新增 Flight 和 GimbalTfPublisher 两个组件插件
Gimbal 控制器增强
双轴云台求解器升级 (
two_axis_gimbal_solver.hpp):Hero 和 Simple 云台控制器更新:适配新的求解器参数接口
配置系统
flight.yaml):环境和部署优化
环境设置:
ROS_LOCALHOST_ONLY替换为ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOSTenv_setup.zsh),包含自动补全设置脚本增强:
play-autoaim脚本,支持参数化用户监控、远程 SDP、复制控制、IP 监控等功能foxglove启动脚本,用于可视化桥接(端口 8765)Docker 配置:
IP 配置:添加特定网络地址 (169.254.233.233)
文档更新
框架改进
rmcs_executor/component.hpp):register_output和create_partner_component模板添加构造约束持续集成
技术亮点