Skip to content

适配上位机新的云台控制命令(包含欧拉角 角速度 角加速度)#1

Merged
llLeo306 merged 1 commit intoQDU-Robomaster:devfrom
EEErink:master
Apr 10, 2026
Merged

适配上位机新的云台控制命令(包含欧拉角 角速度 角加速度)#1
llLeo306 merged 1 commit intoQDU-Robomaster:devfrom
EEErink:master

Conversation

@EEErink
Copy link
Copy Markdown
Contributor

@EEErink EEErink commented Apr 10, 2026

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:

  • Introduce a HostGimbalTarget message struct carrying Euler angles, angular velocities, and angular accelerations for the gimbal.

Enhancements:

  • Update HostData to subscribe to the new gimbal topic type and translate incoming messages into Euler angle, gyro, and acceleration state for downstream commands.
  • Extend the propagated gimbal command to include pitch and yaw angular velocity and acceleration fields while maintaining online/offline detection based on received data.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 10, 2026

Reviewer's Guide

Adapt 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 HostData

sequenceDiagram
  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
Loading

Class diagram for HostData with new HostGimbalTarget protocol

classDiagram
  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
Loading

File-Level Changes

Change Details Files
Switch gimbal input from a raw EulerAngle topic to a structured HostGimbalTarget containing angles, angular velocities, and angular accelerations, and map these into internal state.
  • Introduce HostGimbalTarget struct carrying rol/pit/yaw and corresponding first and second derivatives.
  • Change constructor to subscribe to a HostGimbalTarget topic instead of LibXR::EulerAngle and register the existing callback on this new topic.
  • Update the gimbal callback to copy raw data into a HostGimbalTarget, then populate host_euler_, host_gyro_, and host_accl_ and refresh last_gimbal_time_.
  • Add host_gyro_ and host_accl_ members initialized to zero and replace host_euler_data_tp_ with host_gimbal_data_tp_.
HostData.hpp
Extend the outgoing host_cmd.gimbal structure to include velocity and acceleration terms for pitch and yaw derived from the new input data.
  • Update the default offline gimbal assignment to zero-initialize all angle, velocity, and acceleration fields.
  • When gimbal data is valid, set pit and yaw from host_euler_ and populate pit_dot, pit_ddot, yaw_dot, and yaw_ddot from host_gyro_ and host_accl_.
  • Preserve gimbal_online semantics while using the new extended gimbal target fields.
HostData.hpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@llLeo306 llLeo306 merged commit b03b7d2 into QDU-Robomaster:dev Apr 10, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants