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
f4784fe6
Commit
f4784fe6
authored
11 years ago
by
Emile Castelnuovo
Committed by
Andrew Tridgell
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
AP_Baro: new files for VRBRAIN board
parent
bbe03626
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libraries/AP_Baro/AP_Baro.h
+1
-0
1 addition, 0 deletions
libraries/AP_Baro/AP_Baro.h
libraries/AP_Baro/AP_Baro_VRBRAIN.cpp
+86
-0
86 additions, 0 deletions
libraries/AP_Baro/AP_Baro_VRBRAIN.cpp
libraries/AP_Baro/AP_Baro_VRBRAIN.h
+29
-0
29 additions, 0 deletions
libraries/AP_Baro/AP_Baro_VRBRAIN.h
with
116 additions
and
0 deletions
libraries/AP_Baro/AP_Baro.h
+
1
−
0
View file @
f4784fe6
...
@@ -90,5 +90,6 @@ private:
...
@@ -90,5 +90,6 @@ private:
#include
"AP_Baro_BMP085.h"
#include
"AP_Baro_BMP085.h"
#include
"AP_Baro_HIL.h"
#include
"AP_Baro_HIL.h"
#include
"AP_Baro_PX4.h"
#include
"AP_Baro_PX4.h"
#include
"AP_Baro_VRBRAIN.h"
#endif // __AP_BARO_H__
#endif // __AP_BARO_H__
This diff is collapsed.
Click to expand it.
libraries/AP_Baro/AP_Baro_VRBRAIN.cpp
0 → 100644
+
86
−
0
View file @
f4784fe6
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
#include
<AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#include
<AP_Baro.h>
#include
"AP_Baro_VRBRAIN.h"
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<unistd.h>
#include
<drivers/drv_baro.h>
#include
<drivers/drv_hrt.h>
extern
const
AP_HAL
::
HAL
&
hal
;
// Public Methods //////////////////////////////////////////////////////////////
bool
AP_Baro_VRBRAIN
::
init
(
void
)
{
if
(
_baro_fd
<=
0
)
{
_baro_fd
=
open
(
BARO_DEVICE_PATH
,
O_RDONLY
);
if
(
_baro_fd
<
0
)
{
hal
.
scheduler
->
panic
(
"Unable to open "
BARO_DEVICE_PATH
);
}
/* set the driver to poll at 150Hz */
ioctl
(
_baro_fd
,
SENSORIOCSPOLLRATE
,
SENSOR_POLLRATE_MAX
);
// average over up to 20 samples
ioctl
(
_baro_fd
,
SENSORIOCSQUEUEDEPTH
,
20
);
// give the timer a chance to run and gather one sample
hal
.
scheduler
->
delay
(
40
);
_accumulate
();
}
return
true
;
}
// Read the sensor
uint8_t
AP_Baro_VRBRAIN
::
read
(
void
)
{
// try to accumulate one more sample, so we have the latest data
_accumulate
();
// consider the baro healthy if we got a reading in the last 0.2s
healthy
=
(
hrt_absolute_time
()
-
_last_timestamp
<
200000
);
if
(
!
healthy
||
_sum_count
==
0
)
{
return
healthy
;
}
_pressure
=
(
_pressure_sum
/
_sum_count
)
*
100.0
f
;
_temperature
=
_temperature_sum
/
_sum_count
;
_pressure_samples
=
_sum_count
;
_last_update
=
(
uint32_t
)
_last_timestamp
/
1000
;
_pressure_sum
=
0
;
_temperature_sum
=
0
;
_sum_count
=
0
;
return
1
;
}
// accumulate sensor values
void
AP_Baro_VRBRAIN
::
_accumulate
(
void
)
{
struct
baro_report
baro_report
;
while
(
::
read
(
_baro_fd
,
&
baro_report
,
sizeof
(
baro_report
))
==
sizeof
(
baro_report
)
&&
baro_report
.
timestamp
!=
_last_timestamp
)
{
_pressure_sum
+=
baro_report
.
pressure
;
// Pressure in mbar
_temperature_sum
+=
baro_report
.
temperature
;
// degrees celcius
_sum_count
++
;
_last_timestamp
=
baro_report
.
timestamp
;
}
}
float
AP_Baro_VRBRAIN
::
get_pressure
()
{
return
_pressure
;
}
float
AP_Baro_VRBRAIN
::
get_temperature
()
{
return
_temperature
;
}
#endif // CONFIG_HAL_BOARD
This diff is collapsed.
Click to expand it.
libraries/AP_Baro/AP_Baro_VRBRAIN.h
0 → 100644
+
29
−
0
View file @
f4784fe6
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
#ifndef __AP_BARO_VRBRAIN_H__
#define __AP_BARO_VRBRAIN_H__
#include
"AP_Baro.h"
class
AP_Baro_VRBRAIN
:
public
AP_Baro
{
public:
bool
init
();
uint8_t
read
();
float
get_pressure
();
float
get_temperature
();
private:
float
_temperature
;
float
_pressure
;
float
_pressure_sum
;
float
_temperature_sum
;
uint32_t
_sum_count
;
void
_accumulate
(
void
);
void
_baro_timer
(
uint32_t
now
);
uint64_t
_last_timestamp
;
// baro driver handle
int
_baro_fd
;
};
#endif // __AP_BARO_VRBRAIN_H__
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