适配上位机新的云台控制命令(包含欧拉角 角速度 角加速度)#1
Merged
llLeo306 merged 1 commit intoQDU-Robomaster:devfrom Apr 10, 2026
Merged
Conversation
Reviewer's GuideAdapt HostData to a new host gimbal control protocol that sends a full target state (Euler angles plus angular velocity and acceleration) instead of just Euler angles, wiring the new topic, data struct, and host command mapping accordingly. Sequence diagram for new host gimbal target processing in HostDatasequenceDiagram
actor HostPC
participant Transport
participant LibXR_Topic_host_gimbal_data_tp as LibXR_Topic_host_gimbal_data_tp
participant HostData
participant CMD
HostPC->>Transport: send HostGimbalTarget
Transport->>LibXR_Topic_host_gimbal_data_tp: deliver RawData
LibXR_Topic_host_gimbal_data_tp->>HostData: euler_callback(in_isr, host_data, raw_data)
activate HostData
HostData->>HostData: FastCopy RawData to HostGimbalTarget t
HostData->>HostData: host_euler_ = EulerAngle(t.rol, t.pit, t.yaw)
HostData->>HostData: host_gyro_ = [t.rol_dot, t.pit_dot, t.yaw_dot]
HostData->>HostData: host_accl_ = [t.rol_ddot, t.pit_ddot, t.yaw_ddot]
HostData->>HostData: last_gimbal_time_ = Timebase::GetMilliseconds()
HostData->>HostData: HostCMD(in_isr)
HostData->>CMD: update host_cmd with gimbal angles, velocity, acceleration
deactivate HostData
Class diagram for HostData with new HostGimbalTarget protocolclassDiagram
class HostChassisTarget {
float vx
float vy
float vw
bool is_remote
bool isfire
}
class HostGimbalTarget {
float rol
float pit
float yaw
float rol_dot
float pit_dot
float yaw_dot
float rol_ddot
float pit_ddot
float yaw_ddot
}
class LauncherCMD {
bool isfire
}
class EulerAngle_float {
+float Roll()
+float Pitch()
+float Yaw()
}
class EigenMatrix3x1_float {
float x
float y
float z
}
class Topic {
+RegisterCallback(callback)
}
class CMD {
+host_cmd
}
class HostData {
+HostData(hw, app, cmd, host_gimbal_topic_name, host_chassis_data_topic_name, host_fire_topic_name)
+HostCMD(in_isr)
-CMD* cmd_
-HostChassisTarget host_chassis_target_
-LauncherCMD host_fire_notify_
-EulerAngle_float host_euler_
-EigenMatrix3x1_float host_gyro_
-EigenMatrix3x1_float host_accl_
-Topic host_gimbal_data_tp_
-Topic host_chassis_data_tp_
-Topic host_fire_notify_tp_
-uint32 last_chassis_time_
-uint32 last_gimbal_time_
-uint32 last_fire_time_
}
HostData o-- HostChassisTarget
HostData o-- HostGimbalTarget : via topic payload
HostData o-- LauncherCMD
HostData o-- EulerAngle_float
HostData o-- EigenMatrix3x1_float : host_gyro_
HostData o-- EigenMatrix3x1_float : host_accl_
HostData o-- Topic : host_gimbal_data_tp_
HostData o-- Topic : host_chassis_data_tp_
HostData o-- Topic : host_fire_notify_tp_
HostData --> CMD
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
HostGimbalTargetis being populated viaFastCopyfrom raw data but is a plain struct with no packing/size guarantees; consider addingstatic_assert(sizeof(HostGimbalTarget) == expected_size)or an explicit packing attribute to avoid ABI‑dependent padding issues when decoding the protocol.- The offline case now assigns
host_cmd.gimbal = {0, 0, 0, 0, 0, 0, 0, 0, 0}, which is brittle if the struct layout changes; it may be safer to centralize default initialization (e.g., aReset()method or default constructor on the gimbal command) rather than relying on positional aggregate initialization.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- `HostGimbalTarget` is being populated via `FastCopy` from raw data but is a plain struct with no packing/size guarantees; consider adding `static_assert(sizeof(HostGimbalTarget) == expected_size)` or an explicit packing attribute to avoid ABI‑dependent padding issues when decoding the protocol.
- The offline case now assigns `host_cmd.gimbal = {0, 0, 0, 0, 0, 0, 0, 0, 0}`, which is brittle if the struct layout changes; it may be safer to centralize default initialization (e.g., a `Reset()` method or default constructor on the gimbal command) rather than relying on positional aggregate initialization.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary by Sourcery
Adapt host-side gimbal data handling to consume the new gimbal control message including Euler angles, angular velocity, and angular acceleration.
New Features:
Enhancements: