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
11212546
Commit
11212546
authored
12 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
AP_InertialSensor: added filter frequency support to PX4 driver
parent
5643c371
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
+22
-0
22 additions, 0 deletions
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
libraries/AP_InertialSensor/AP_InertialSensor_PX4.h
+6
-0
6 additions, 0 deletions
libraries/AP_InertialSensor/AP_InertialSensor_PX4.h
with
28 additions
and
0 deletions
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
+
22
−
0
View file @
11212546
...
...
@@ -29,13 +29,16 @@ uint16_t AP_InertialSensor_PX4::_init_sensor( Sample_rate sample_rate )
switch
(
sample_rate
)
{
case
RATE_50HZ
:
_sample_divider
=
4
;
_default_filter_hz
=
10
;
break
;
case
RATE_100HZ
:
_sample_divider
=
2
;
_default_filter_hz
=
42
;
break
;
case
RATE_200HZ
:
default:
_sample_divider
=
1
;
_default_filter_hz
=
42
;
break
;
}
...
...
@@ -67,9 +70,23 @@ uint16_t AP_InertialSensor_PX4::_init_sensor( Sample_rate sample_rate )
// register a 1kHz timer to read from PX4 sensor drivers
hal
.
scheduler
->
register_timer_process
(
_ins_timer
);
_set_filter_frequency
(
_mpu6000_filter
);
return
AP_PRODUCT_ID_PX4
;
}
/*
set the filter frequency
*/
void
AP_InertialSensor_PX4
::
_set_filter_frequency
(
uint8_t
filter_hz
)
{
if
(
filter_hz
==
0
)
{
filter_hz
=
_default_filter_hz
;
}
ioctl
(
_gyro_fd
,
GYROIOCSLOWPASS
,
filter_hz
);
ioctl
(
_accel_fd
,
ACCELIOCSLOWPASS
,
filter_hz
);
}
/*================ AP_INERTIALSENSOR PUBLIC INTERFACE ==================== */
bool
AP_InertialSensor_PX4
::
update
(
void
)
...
...
@@ -106,6 +123,11 @@ bool AP_InertialSensor_PX4::update(void)
_gyro
.
rotate
(
_board_orientation
);
_gyro
-=
_gyro_offset
;
if
(
_last_filter_hz
!=
_mpu6000_filter
)
{
_set_filter_frequency
(
_mpu6000_filter
);
_last_filter_hz
=
_mpu6000_filter
;
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
libraries/AP_InertialSensor/AP_InertialSensor_PX4.h
+
6
−
0
View file @
11212546
...
...
@@ -41,6 +41,12 @@ private:
static
uint64_t
_last_gyro_timestamp
;
uint8_t
_sample_divider
;
// support for updating filter at runtime
uint8_t
_last_filter_hz
;
uint8_t
_default_filter_hz
;
void
_set_filter_frequency
(
uint8_t
filter_hz
);
// accelerometer and gyro driver handles
static
int
_accel_fd
;
static
int
_gyro_fd
;
...
...
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