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: Alexmos: increase precision on parsed angle #27305

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

MattKear
Copy link
Contributor

@MattKear MattKear commented Jun 14, 2024

Noticed this issue when helping someone out. We are using integer math when calculating the angle in degrees from the provided value. This minor rework helps to maintaining a little more accuracy so that we don't round to integer degrees.

I have also done a little tidying by moving the defines to the .cpp.

@MattKear MattKear requested a review from rmackay9 June 14, 2024 15:18
#define AP_MOUNT_ALEXMOS_SPEED 30 // deg/s

#define INT14_DEGREES = (360.0f / 0x3FFF) // 1 full rotation in degrees over 14 bit range
#define VALUE_TO_DEGREE(d) (float(d)*INT14_DEGREES)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the key bit that has changed to improve the angle precision

@MattKear MattKear force-pushed the pr_alexmos_gimbal_tidy branch from 7760490 to 09b9e6c Compare June 14, 2024 15:23
@MattKear MattKear force-pushed the pr_alexmos_gimbal_tidy branch from 09b9e6c to f9953f9 Compare June 14, 2024 20:11
@rmackay9
Copy link
Contributor

This looks OK to me and it has been tested of course?

@MattKear
Copy link
Contributor Author

A client is testing this for me. I will report back once the testing has shown the improvement works.

@IamPete1
Copy link
Member

IamPete1 commented Jun 15, 2024

Before we get integers:

image

After we get much smoother:
image

@peterbarker peterbarker merged commit e1a1d15 into ArduPilot:master Jun 20, 2024
92 checks passed
@MattKear MattKear deleted the pr_alexmos_gimbal_tidy branch July 22, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants