Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Mount: add CADDX gimbal support #28942

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

rmackay9
Copy link
Contributor

This is a simplified version of @Hwurzburg's previous PR #28373 to add support for the CADDX GM3 gimbal

This simply adds support for the gimbal without trying to support the extra lock types that the gimbal provides. These extra lock types add the ability to control each axis (roll, pitch and yaw) in earth or body frame independently. For example roll control could be in body frame while pitch is in earth frame. This new ability is not supported in this PR.

This has been tested on real hardware and seems OK.

The corresponding wiki PR is here ArduPilot/ardupilot_wiki#6441

@Hwurzburg
Copy link
Collaborator

why drop the lock types and control?

@rmackay9
Copy link
Contributor Author

Hi @Hwurzburg,

I dropped the lock types and control because I couldn't get them to work and also they are really an enhancement so they naturally fall into a follow-up PR that could potentially affect other gimbals as well. The Siyi gimbal for example also supports FPV mode and users have been asking for that for a long time so we could do the two together

@Lalbabu2001
Copy link

Hi please add support for this board
https://www.6sfull.cz/en/neutronrc-mini-f405-2-6s-20--20-30--30/

Don't forget to add Bmp 280 baro because new versions come with bmp280.
Also add support for PPM .
Thanks.

@rmackay9
Copy link
Contributor Author

Hi @Lalbabu2001,

I've created an issue here to capture this enhancement request #28945. No promises on when/if it will be done though. I'm not personally very experienced porting AP to new boards.

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Dec 30, 2024
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

partial on-call review only :-)

libraries/AP_Mount/AP_Mount_CADDX.h Outdated Show resolved Hide resolved
libraries/AP_Mount/AP_Mount_CADDX.h Outdated Show resolved Hide resolved
libraries/AP_Mount/AP_Mount_CADDX.h Outdated Show resolved Hide resolved
@rmackay9 rmackay9 dismissed peterbarker’s stale review January 2, 2025 03:05

PeterB's requests addressed, thanks!

@rmackay9 rmackay9 force-pushed the caddx-mount-serial branch from 358d493 to 317c8b3 Compare January 2, 2025 03:07
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Looks pretty good.

libraries/AP_Mount/AP_Mount_CADDX.h Outdated Show resolved Hide resolved

#include "AP_Mount_Backend_Serial.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include <AP_Math/AP_Math.h>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed include, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I've put this back because AP_Math.h is where "quaternion" is included

Copy link
Contributor

Choose a reason for hiding this comment

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

diff --git a/libraries/AP_Mount/AP_Mount_CADDX.h b/libraries/AP_Mount/AP_Mount_CADDX.h
index fe423f55459..3d831209bf7 100644
--- a/libraries/AP_Mount/AP_Mount_CADDX.h
+++ b/libraries/AP_Mount/AP_Mount_CADDX.h
@@ -8,8 +8,7 @@
 #if HAL_MOUNT_CADDX_ENABLED
 
 #include "AP_Mount_Backend_Serial.h"
-#include <AP_Math/AP_Math.h>
-#include <AP_Common/AP_Common.h>
+#include <AP_Math/quaternion.h>
 
 class AP_Mount_CADDX : public AP_Mount_Backend_Serial
 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok thanks. Updated to remove AP_Common.h and change to <AP_Math/quaternion.h>. I'm surprised we don't need AP_Common.h in there. We include that in every other AP_Mount backend so I guess we could remove it from many places

Copy link
Contributor

Choose a reason for hiding this comment

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

ok thanks. Updated to remove AP_Common.h and change to <AP_Math/quaternion.h>. I'm surprised we don't need AP_Common.h in there. We include that in every other AP_Mount backend so I guess we could remove it from many places

Probably, yes - and that will save compile time, which everybody likes.

We're getting away with some shenanigans by having those all around the place - things like the stdint.h include come to mind :-)

protected:

// get attitude as a quaternion. returns true on success
bool get_attitude_quaternion(Quaternion& att_quat) override;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool get_attitude_quaternion(Quaternion& att_quat) override;
bool get_attitude_quaternion(class Quaternion& att_quat) override;

Not actually including the right header to get this - just getting it transitively somehow

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'm going to skip this change I think because it leads to a compile failure and would make it inconsistent with the virtual method that it is overriding and also all other drivers. Apologies, I'm probably misunderstanding something


// lock mode enum
enum class LockMode {
FOLLOW = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't make a lot of sense!

Suggested change
FOLLOW = 0,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @peterbarker, thanks for the review. I've removed this line because we don't use it but I can imagine that we could use it as a default value so not sure why it doesn't makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally we don't use the same enumeration which is giving names to bit-offsets for combinations of those bits (AKA a "mask").

It would be nice to have some type-safety around this sort of thing, but I've never managed to propose a PR to add that....

@rmackay9 rmackay9 force-pushed the caddx-mount-serial branch from 317c8b3 to 190f25e Compare January 2, 2025 03:28
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

LGTM


#include "AP_Mount_Backend_Serial.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

diff --git a/libraries/AP_Mount/AP_Mount_CADDX.h b/libraries/AP_Mount/AP_Mount_CADDX.h
index fe423f55459..3d831209bf7 100644
--- a/libraries/AP_Mount/AP_Mount_CADDX.h
+++ b/libraries/AP_Mount/AP_Mount_CADDX.h
@@ -8,8 +8,7 @@
 #if HAL_MOUNT_CADDX_ENABLED
 
 #include "AP_Mount_Backend_Serial.h"
-#include <AP_Math/AP_Math.h>
-#include <AP_Common/AP_Common.h>
+#include <AP_Math/quaternion.h>
 
 class AP_Mount_CADDX : public AP_Mount_Backend_Serial
 {

libraries/AP_Mount/AP_Mount_CADDX.cpp Outdated Show resolved Hide resolved
@rmackay9 rmackay9 force-pushed the caddx-mount-serial branch from 190f25e to 950b0f2 Compare January 2, 2025 07:15
@rmackay9
Copy link
Contributor Author

rmackay9 commented Jan 2, 2025

I've updated with @peterbarker's requests and marked as "MergeOnCIPass"

@peterbarker peterbarker merged commit e2e7d1d into ArduPilot:master Jan 2, 2025
99 checks passed
@peterbarker
Copy link
Contributor

Merged it!

@rmackay9 rmackay9 deleted the caddx-mount-serial branch January 3, 2025 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Pending
Development

Successfully merging this pull request may close these issues.

5 participants