Skip to content

Conversation

@peterbarker
Copy link
Contributor

This is a Draft Pull Request, not intended for review at this point.

It:

  • moves SoloGimbal to use update_mnt_target (will be the target of a future PR)
  • is based on a PR which makes servo backend update_mnt_target (marked MergeOnCIPass)
  • inlines get_rc_target which previously allowed all of the backends to share this code. It is no longer needed as they all now call update_mnt_target. It's being inlined because it has an awkward signature and does some strange dancing within it which is better done with the code in update_mnt_target.
  • splits MountTarget into MountAngleTarget and MountRateTarget, and updates the mount_target object to contain one of each. Rate doesn't need anywhere near as much stuff in it as Angle!
  • adds new enumeration values so MountTarget can hold information that the mount should be neutral or retracted
    • uses that in the Servo and MAVLink backends
      • thus the servo backend stops using get_mode()
  • creates send_target_to_gimbal. All backends call this method (may fold call into update_mnt_targets and rename it?). It looks at mnt_target. If a backend natively supports that type of target it calls a method to send that target to the gimbal. If it does not then it converts from mnt_target.target_type` to a target type that the gimbal does understand and sends that instead.
  • allows for easy addition of MountLocationTarget, which I also have patches for based on something close to this

@peterbarker peterbarker force-pushed the pr/mount-send_targets branch 2 times, most recently from 4698a03 to cddf90b Compare December 18, 2025 00:40
};
class MountRateTarget {
public:
float roll;
Copy link
Contributor

Choose a reason for hiding this comment

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

txs for this. let's put units on these members. "rads" perhaps? We should do the same for the MountAngleTarget as well because roll is only an angle (in radians I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

txs for this. let's put units on these members. "rads" perhaps? We should do the same for the MountAngleTarget as well because roll is only an angle (in radians I think)

Can we do this as a follow-up PR?

It would be a lot of changed lines - if I do it as part of a follow-up PR then it will be a no-compiler-output change PR.

Changing this would also cause Henry significant issues!

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, sounds good to me

send_gimbal_device_set_rate(mnt_target.rate_rads.roll, mnt_target.rate_rads.pitch, mnt_target.rate_rads.yaw, mnt_target.rate_rads.yaw_is_ef);
break;
}
send_target_to_gimbal();
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, if possible I'd like to have more commenting. It's pretty obvious but I like it to be really obvious :-)

// directly commanded to move to a retracted state
uint8_t natively_supported_mount_target_types() const override {
return (
(1U<<unsigned(MountTargetType::ANGLE)) |
Copy link
Contributor

Choose a reason for hiding this comment

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

how about if we use defines or an enum to avoid the bit math here? It's going to be in every gimbal so I think just some ORing of defines or something might be easier. alternatively just three different methods, "bool supports_rate_targets() const { return true; }" might be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just pushed this up as four separate methods. Man, is that expensive in bytes, 'though!

Board,copter
CubeOrange,472

Yeah, the code is nicer, but I don't think it is 472 bytes nicer :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! The number is actually 240 bytes, I went against the wrong hash.

In any case I've pushed up a version which uses static const members to make the backends look nicer which doesn't cost any extra flash.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can replace this with the new pretty const exprs that you've added?

@peterbarker peterbarker force-pushed the pr/mount-send_targets branch from cddf90b to 762a12b Compare December 18, 2025 01:10
@peterbarker peterbarker force-pushed the pr/mount-send_targets branch from c895d3e to fb14250 Compare December 18, 2025 02:44
ANGLE = 0,
RATE = 1,
RETRACTED = 2,
NEUTRAL = 3,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need neutral? Isn't Neutral just ANGLE?

@rmackay9
Copy link
Contributor

This is looking quite good to me so we could promote it from Draft to a regular PR?

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