Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
Ardupilot
Commits
f4d45c9b
Commit
f4d45c9b
authored
10 years ago
by
Randy Mackay
Browse files
Options
Downloads
Patches
Plain Diff
Tracker: limit yaw to YAW_RANGE
parent
e7e0dd35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AntennaTracker/servos.pde
+25
-6
25 additions, 6 deletions
AntennaTracker/servos.pde
with
25 additions
and
6 deletions
AntennaTracker/servos.pde
+
25
−
6
View file @
f4d45c9b
...
...
@@ -163,6 +163,7 @@ static void update_yaw_position_servo(float yaw)
{
int32_t
ahrs_yaw_cd
=
wrap_180_cd
(
ahrs
.
yaw_sensor
);
int32_t
yaw_cd
=
wrap_180_cd
(
yaw
*
100
);
int32_t
yaw_limit_cd
=
g
.
yaw_range
*
100
/
2
;
const
int16_t
margin
=
500
;
// 5 degrees slop
// Antenna as Ballerina. Use with antenna that do not have continuously rotating servos, ie at some point in rotation
...
...
@@ -238,6 +239,10 @@ static void update_yaw_position_servo(float yaw)
slew_dir
=
new_slew_dir
;
// initialise limit flags
servo_limit
.
yaw_lower
=
false
;
servo_limit
.
yaw_upper
=
false
;
int16_t
new_servo_out
;
if
(
slew_dir
!=
0
)
{
new_servo_out
=
slew_dir
*
18000
;
...
...
@@ -248,18 +253,32 @@ static void update_yaw_position_servo(float yaw)
new_servo_out
=
constrain_float
(
channel_yaw
.
servo_out
-
servo_change
,
-
18000
,
18000
);
}
//
add slew
rate limit
// rate limit
yaw servo
if
(
g
.
yaw_slew_time
>
0.02
f
)
{
uint16_t
max_change
=
0.02
f
*
100.0
f
*
g
.
yaw_range
/
g
.
yaw_slew_time
;
uint16_t
max_change
=
0.02
f
*
yaw_limit_cd
/
g
.
yaw_slew_time
;
if
(
max_change
<
1
)
{
max_change
=
1
;
}
new_servo_out
=
constrain_float
(
new_servo_out
,
channel_yaw
.
servo_out
-
max_change
,
channel_yaw
.
servo_out
+
max_change
);
if
(
new_servo_out
<=
channel_yaw
.
servo_out
-
max_change
)
{
new_servo_out
=
channel_yaw
.
servo_out
-
max_change
;
servo_limit
.
yaw_lower
=
true
;
}
if
(
new_servo_out
>=
channel_yaw
.
servo_out
+
max_change
)
{
new_servo_out
=
channel_yaw
.
servo_out
+
max_change
;
servo_limit
.
yaw_upper
=
true
;
}
}
channel_yaw
.
servo_out
=
new_servo_out
;
// position limit pitch servo
if
(
channel_yaw
.
servo_out
<=
-
yaw_limit_cd
)
{
channel_yaw
.
servo_out
=
-
yaw_limit_cd
;
servo_limit
.
yaw_lower
=
true
;
}
if
(
channel_yaw
.
servo_out
>=
yaw_limit_cd
)
{
channel_yaw
.
servo_out
=
yaw_limit_cd
;
servo_limit
.
yaw_upper
=
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment