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
5de459a1
Commit
5de459a1
authored
13 years ago
by
Jason Short
Browse files
Options
Downloads
Patches
Plain Diff
tweaks to Loiter
parent
06d54bf0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ArduCopter/navigation.pde
+17
-7
17 additions, 7 deletions
ArduCopter/navigation.pde
with
17 additions
and
7 deletions
ArduCopter/navigation.pde
+
17
−
7
View file @
5de459a1
...
...
@@ -44,8 +44,8 @@ static void calc_XY_velocity(){
static
int32_t
last_longitude
=
0
;
static
int32_t
last_latitude
=
0
;
//
static int16_t x_speed_old = 0;
//
static int16_t y_speed_old = 0;
static
int16_t
x_speed_old
=
0
;
static
int16_t
y_speed_old
=
0
;
// y_GPS_speed positve = Up
// x_GPS_speed positve = Right
...
...
@@ -55,8 +55,14 @@ static void calc_XY_velocity(){
// straightforward approach:
///*
x_actual_speed
=
(
float
)(
g_gps
->
longitude
-
last_longitude
)
*
tmp
;
y_actual_speed
=
(
float
)(
g_gps
->
latitude
-
last_latitude
)
*
tmp
;
x_actual_speed
=
x_speed_old
+
(
float
)(
g_gps
->
longitude
-
last_longitude
)
*
tmp
;
y_actual_speed
=
y_speed_old
+
(
float
)(
g_gps
->
latitude
-
last_latitude
)
*
tmp
;
x_actual_speed
=
x_actual_speed
>>
1
;
y_actual_speed
=
y_actual_speed
>>
1
;
x_speed_old
=
x_actual_speed
;
y_speed_old
=
y_actual_speed
;
/*
// Ryan Beall's forward estimator:
...
...
@@ -92,18 +98,22 @@ static void calc_location_error(struct Location *next_loc)
lat_error
=
next_loc
->
lat
-
current_loc
.
lat
;
// 500 - 0 = 500 Go North
}
#define NAV_ERR_MAX
8
00
#define NAV_ERR_MAX
6
00
static
void
calc_loiter
(
int
x_error
,
int
y_error
)
{
// East/West
x_error
=
constrain
(
x_error
,
-
NAV_ERR_MAX
,
NAV_ERR_MAX
);
//800
int16_t
x_target_speed
=
g
.
pi_loiter_lon
.
get_p
(
x_error
);
x_target_speed
=
constrain
(
x_error
,
-
150
,
150
);
// limit windup
x_error
=
constrain
(
x_error
,
-
NAV_ERR_MAX
,
NAV_ERR_MAX
);
int16_t
x_iterm
=
g
.
pi_loiter_lon
.
get_i
(
x_error
,
dTnav
);
x_rate_error
=
x_target_speed
-
x_actual_speed
;
// North/South
y_error
=
constrain
(
y_error
,
-
NAV_ERR_MAX
,
NAV_ERR_MAX
);
int16_t
y_target_speed
=
g
.
pi_loiter_lat
.
get_p
(
y_error
);
y_target_speed
=
constrain
(
y_error
,
-
150
,
150
);
// limit windup
y_error
=
constrain
(
y_error
,
-
NAV_ERR_MAX
,
NAV_ERR_MAX
);
int16_t
y_iterm
=
g
.
pi_loiter_lat
.
get_i
(
y_error
,
dTnav
);
y_rate_error
=
y_target_speed
-
y_actual_speed
;
...
...
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