Conversation
适配上位机新的云台控制命令(包含欧拉角 角速度 角加速度)
Reviewer's GuideRefactors HostData to subscribe to a richer gimbal target topic (position, velocity, acceleration) instead of a simple Euler-angle topic, wiring the additional data into HostCMD and updating member types and callbacks accordingly. Sequence diagram for updated gimbal topic handling in HostDatasequenceDiagram
participant Topic as host_gimbal_data_tp_
participant ISR as LibXR_ISR
participant Host as HostData
participant CMD as CMD
Topic->>ISR: OnDataReceived(raw_data)
ISR->>Host: euler_callback(in_isr, Host, raw_data)
activate Host
Host->>Host: LibXR::Memory::FastCopy(t, raw_data.addr_, sizeof(t))
Host->>Host: host_euler_ = LibXR::EulerAngle(t.rol, t.pit, t.yaw)
Host->>Host: host_gyro_ = Eigen::Matrix( t.rol_dot, t.pit_dot, t.yaw_dot )
Host->>Host: host_accl_ = Eigen::Matrix( t.rol_ddot, t.pit_ddot, t.yaw_ddot )
Host->>Host: last_gimbal_time_ = LibXR::Timebase::GetMilliseconds()
Host->>Host: HostCMD(in_isr)
Host->>CMD: update host_cmd.gimbal (pos, vel, accel)
deactivate Host
Updated class diagram for HostData gimbal subscription refactorclassDiagram
class HostData {
+HostData(LibXR::HardwareContainer& hw, LibXR::ApplicationManager& app, CMD& cmd, const char* host_gimbal_topic_name, const char* host_chassis_data_topic_name, const char* host_fire_topic_name)
+void HostCMD(bool in_isr)
-CMD* cmd_
-ChassisCMD host_chassis_target_
-LauncherCMD host_fire_notify_
-LibXR::EulerAngle~float~ host_euler_
-Eigen::Matrix~float,3,1~ host_gyro_
-Eigen::Matrix~float,3,1~ host_accl_
-uint32_t last_gimbal_time_
-LibXR::Topic host_gimbal_data_tp_
-LibXR::Topic host_chassis_data_tp_
-LibXR::Topic host_fire_notify_tp_
}
class HostChassisTarget {
+float vx
+float vy
+float wz
+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 CMD {
+HostCMDData host_cmd
}
class HostCMDData {
+GimbalTarget gimbal
+bool gimbal_online
}
class GimbalTarget {
+float rol
+float pit
+float yaw
+float rol_dot
+float pit_dot
+float yaw_dot
+float rol_ddot
+float pit_ddot
+float yaw_ddot
}
HostData --> HostChassisTarget : publishes
HostData --> HostGimbalTarget : subscribes
HostData --> CMD : updates
CMD --> HostCMDData : owns
HostCMDData --> GimbalTarget : has
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:
- Now that the topic and payload have been generalized to a full gimbal state (
HostGimbalTarget), consider renaming variables likehost_euler_andeuler_callbackto reflect that they carry position, velocity, and acceleration, to keep the intent of the data clear. - Because
HostGimbalTargetis being memcpy’d from raw bytes, it would be safer to explicitly control or assert its layout (e.g.,static_assert(sizeof(HostGimbalTarget) == expected_size)or using a packed/standard-layout type) to avoid issues from padding or alignment changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that the topic and payload have been generalized to a full gimbal state (`HostGimbalTarget`), consider renaming variables like `host_euler_` and `euler_callback` to reflect that they carry position, velocity, and acceleration, to keep the intent of the data clear.
- Because `HostGimbalTarget` is being memcpy’d from raw bytes, it would be safer to explicitly control or assert its layout (e.g., `static_assert(sizeof(HostGimbalTarget) == expected_size)` or using a packed/standard-layout type) to avoid issues from padding or alignment changes.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
Update host data handling to consume full gimbal state (angles, angular rates, and accelerations) and propagate this richer information into host commands.
New Features:
Enhancements: