Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Emilio Corigliano
Skyward Boardcore
Commits
a67a97fe
Commit
a67a97fe
authored
1 year ago
by
Matteo Pignataro
Browse files
Options
Downloads
Patches
Plain Diff
[Pitot] Added new pitot formula from AER
parent
ecc9a494
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
src/shared/sensors/analog/Pitot/Pitot.h
+15
-17
15 additions, 17 deletions
src/shared/sensors/analog/Pitot/Pitot.h
src/tests/catch/test-pitot.cpp
+73
-0
73 additions, 0 deletions
src/tests/catch/test-pitot.cpp
with
89 additions
and
17 deletions
CMakeLists.txt
+
1
−
0
View file @
a67a97fe
...
@@ -133,6 +133,7 @@ add_executable(catch-tests-boardcore
...
@@ -133,6 +133,7 @@ add_executable(catch-tests-boardcore
src/tests/catch/test-modulemanager.cpp
src/tests/catch/test-modulemanager.cpp
src/tests/catch/test-MEA.cpp
src/tests/catch/test-MEA.cpp
src/tests/catch/test-airbrakesInterp.cpp
src/tests/catch/test-airbrakesInterp.cpp
src/tests/catch/test-pitot.cpp
)
)
target_compile_definitions
(
catch-tests-boardcore PRIVATE USE_MOCK_PERIPHERALS
)
target_compile_definitions
(
catch-tests-boardcore PRIVATE USE_MOCK_PERIPHERALS
)
sbs_target
(
catch-tests-boardcore stm32f429zi_stm32f4discovery
)
sbs_target
(
catch-tests-boardcore stm32f429zi_stm32f4discovery
)
...
...
This diff is collapsed.
Click to expand it.
src/shared/sensors/analog/Pitot/Pitot.h
+
15
−
17
View file @
a67a97fe
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#pragma once
#pragma once
#include
<algorithms/ReferenceValues.h>
#include
<algorithms/ReferenceValues.h>
#include
<drivers/timer/TimestampTimer.h>
#include
<sensors/Sensor.h>
#include
<sensors/Sensor.h>
#include
<utils/AeroUtils/AeroUtils.h>
#include
<utils/AeroUtils/AeroUtils.h>
...
@@ -36,9 +37,9 @@ namespace Boardcore
...
@@ -36,9 +37,9 @@ namespace Boardcore
class
Pitot
:
public
Sensor
<
PitotData
>
class
Pitot
:
public
Sensor
<
PitotData
>
{
{
public:
public:
Pitot
(
std
::
function
<
PressureD
at
a
()
>
get
Pitot
Pressure
,
Pitot
(
std
::
function
<
flo
at
()
>
get
Total
Pressure
,
std
::
function
<
float
()
>
getStaticPressure
)
std
::
function
<
float
()
>
getStaticPressure
)
:
get
Pitot
Pressure
(
get
Pitot
Pressure
),
:
get
Total
Pressure
(
get
Total
Pressure
),
getStaticPressure
(
getStaticPressure
)
getStaticPressure
(
getStaticPressure
)
{
{
}
}
...
@@ -56,27 +57,24 @@ public:
...
@@ -56,27 +57,24 @@ public:
PitotData
sampleImpl
()
override
PitotData
sampleImpl
()
override
{
{
float
airDensity
=
Aeroutils
::
relDensity
(
float
totalPressure
=
getTotalPressure
();
getStaticPressure
(),
reference
.
refPressure
,
reference
.
refAltitude
,
float
staticPressure
=
getStaticPressure
();
reference
.
refTemperature
);
if
(
airDensity
!=
0.0
)
// clang-format off
{
float
gamma
=
1.4
f
;
PitotData
pitotSpeed
;
float
c
=
sqrt
(
gamma
*
Constants
::
R
*
reference
.
refTemperature
);
float
M
=
sqrt
(((
pow
(
totalPressure
/
staticPressure
,
(
gamma
-
1
)
/
gamma
))
-
1
)
*
(
2
/
(
gamma
-
1
)));
// clang-format on
pitotSpeed
.
timestamp
=
getPitotPressure
().
pressureTimestamp
;
PitotData
pitotSpeed
;
pitotSpeed
.
deltaP
=
getPitotPressure
().
pressure
;
pitotSpeed
.
airspeed
=
M
*
c
;
pitotSpeed
.
airspeed
=
pitotSpeed
.
timestamp
=
TimestampTimer
::
getTimestamp
();
sqrtf
(
2
*
fabs
(
pitotSpeed
.
deltaP
)
/
airDensity
);
return
pitotSpeed
;
return
pitotSpeed
;
}
}
return
lastSample
;
}
private
:
private
:
std
::
function
<
PressureD
at
a
()
>
get
Pitot
Pressure
;
std
::
function
<
flo
at
()
>
get
Total
Pressure
;
std
::
function
<
float
()
>
getStaticPressure
;
std
::
function
<
float
()
>
getStaticPressure
;
ReferenceValues
reference
;
ReferenceValues
reference
;
...
...
This diff is collapsed.
Click to expand it.
src/tests/catch/test-pitot.cpp
0 → 100644
+
73
−
0
View file @
a67a97fe
/* Copyright (c) 2023 Skyward Experimental Rocketry
* Author: Matteo Pignataro
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include
<sensors/analog/Pitot/Pitot.h>
#include
<catch2/catch.hpp>
#include
<functional>
#include
<iostream>
using
namespace
Boardcore
;
float
totalPressures
[]
=
{
142319.922179851
,
142334.556779026
,
142334.990339878
,
142328.593255716
,
142334.485137298
,
142355.994981968
,
142375.515131591
,
142371.90326022
,
142369.472114238
,
142372.026452516
,
142374.830116745
};
float
staticPressures
[]
=
{
89427.1259035819
,
89399.4135799592
,
89370.6155267334
,
89337.8306466511
,
89307.6055280662
,
89287.1092122239
,
89265.7025543447
,
89231.9778726411
,
89199.4339163267
,
89171.8754442722
,
89144.5662981688
};
float
results
[]
=
{
291.616036301297
,
291.754323018779
,
291.863248891676
,
291.971052285523
,
292.098174588202
,
292.225543982517
,
292.351618537494
,
292.469497902937
,
292.585736754635
,
292.695003991533
,
292.803923124566
};
constexpr
float
referenceTemperature
=
298.15
;
constexpr
unsigned
int
SAMPLES_N
=
10
;
TEST_CASE
(
"Pitot Test"
)
{
Pitot
pitot
(
[]()
{
static
int
i
=
0
;
return
totalPressures
[
i
++
];
},
[]()
{
static
int
i
=
0
;
return
staticPressures
[
i
++
];
});
ReferenceValues
references
;
references
.
refTemperature
=
referenceTemperature
;
pitot
.
setReferenceValues
(
references
);
for
(
int
i
=
0
;
i
<
SAMPLES_N
;
i
++
)
{
pitot
.
sample
();
if
(
pitot
.
getLastSample
().
airspeed
!=
Approx
(
results
[
i
]).
epsilon
(
0.01
))
{
FAIL
(
"The computed value differs from the correct one: "
<<
pitot
.
getLastSample
().
airspeed
<<
" != "
<<
results
[
i
]);
}
}
}
\ No newline at end of file
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