Skip to content

Commit cdb904c

Browse files
committedNov 29, 2021
Updated interface to work with Arduino and CMake build systems
1 parent e65998a commit cdb904c

12 files changed

+111
-17
lines changed
 

‎.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Lint:
88
tags:
99
- bfs
1010
script:
11-
- cpplint --verbose=0 include/airdata/airdata.h
11+
- cpplint --verbose=0 src/airdata.h
1212
Compile:
1313
stage: build
1414
tags:

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v3.0.0
4+
- Updated interface to work with Arduino and CMake build systems
5+
36
## v2.1.0
47
- Templated functions against the input type
58

‎CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
cmake_minimum_required(VERSION 3.13)
22
# Project information
33
project(Airdata
4-
VERSION 2.1.0
4+
VERSION 3.0.0
55
DESCRIPTION "Airdata functions."
66
LANGUAGES CXX
77
)
8+
# Add definition that we're building with CMake
9+
add_definitions(-D__CMAKE__)
810
include(FetchContent)
911
# Fetch global defs
1012
FetchContent_Declare(
1113
units
1214
GIT_REPOSITORY https://github.com/bolderflight/units.git
13-
GIT_TAG v3.2.0
15+
GIT_TAG v4.0.1
1416
)
1517
FetchContent_MakeAvailable(units)
1618
# Add the library target
@@ -20,12 +22,12 @@ target_link_libraries(airdata
2022
units
2123
)
2224
# Setup include directories
23-
target_include_directories(airdata INTERFACE include/)
25+
target_include_directories(airdata INTERFACE src/)
2426

2527
# Example and unit testing if this project is built separately
2628
if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
2729
# Add the example target
28-
add_executable(airdata_example examples/airdata_example.cc)
30+
add_executable(airdata_example examples/cmake/airdata_example.cc)
2931
# Add the includes
3032
target_include_directories(airdata_example PUBLIC
3133
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

‎README.md

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1+
[![Pipeline](https://gitlab.com/bolderflight/software/airdata/badges/main/pipeline.svg)](https://gitlab.com/bolderflight/software/airdata/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2+
3+
![Bolder Flight Systems Logo](img/logo-words_75.png) &nbsp; &nbsp; ![Arduino Logo](img/arduino_logo_75.png)
4+
15
# Airdata
2-
This library contains airdata functions.
6+
This library contains functions for computing indicated airspeed, equivalent airspeed, true airspeed, pressure altitude, density altitude, and estimating outside air temperature (OAT) and air density. This library is compatible with Arduino ARM and with CMake build systems. It would also be easy to include with other projects, since it is a header only library consisting of a single file.
37
* [License](LICENSE.md)
48
* [Changelog](CHANGELOG.md)
59
* [Contributing guide](CONTRIBUTING.md)
610

7-
## Installation
8-
CMake is used to build this library, which is exported as a library target called *airdata*. The header is added as:
11+
# Installation
912

13+
## Arduino
14+
Use the Arduino Library Manager to install this library or clone to your Arduino/libraries folder. Additionally, the [Bolder Flight Systems Units library](https://github.com/bolderflight/units) must be installed. This library is added as:
15+
16+
```C++
17+
#include "airdata.h"
1018
```
11-
#include "airdata/airdata.h"
19+
20+
An example Arduino executable is located at *examples/arduino/airdata_example/airdata_example.ino*. Teensy 3.x, 4.x, and LC devices are used for testing under Arduino and this library should be compatible with other ARM devices. This library is *not* expected to work on AVR devices.
21+
22+
## CMake
23+
CMake is used to build this library, which is exported as a library target called *airdata*. The header is added as:
24+
25+
```C++
26+
#include "airdata.h"
1227
```
1328

1429
The library can be also be compiled stand-alone using the CMake idiom of creating a *build* directory and then, from within that directory issuing:
@@ -18,7 +33,7 @@ cmake ..
1833
make
1934
```
2035

21-
This will build the library, an example executable called *airdata_example*, and an executable for testing using the Google Test framework, called *airdata_test*. The example executable source file is located at *examples/airdata_example.cc*.
36+
This will build the library, an example executable called *airdata_example*, and an executable for testing using the Google Test framework, called *airdata_test*. The example executable source file is located at *examples/cmake/airdata_example.cc*.
2237

2338
## Namespace
2439
This library is within the namespace *bfs*.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Brian R Taylor
3+
* brian.taylor@bolderflight.com
4+
*
5+
* Copyright (c) 2021 Bolder Flight Systems Inc
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the “Software”), to
9+
* deal in the Software without restriction, including without limitation the
10+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11+
* sell copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23+
* IN THE SOFTWARE.
24+
*/
25+
26+
#include "airdata.h"
27+
28+
void setup() {
29+
Serial.begin(115200);
30+
while (!Serial) {}
31+
float ias = bfs::Ias_mps(500.0f);
32+
Serial.print("IAS (m/s): ");
33+
Serial.println(ias);
34+
float eas = bfs::Eas_mps(500.0f, 90000.0f);
35+
Serial.print("EAS (m/s): ");
36+
Serial.println(eas);
37+
float tas = bfs::Tas_mps(eas, 17.0f);
38+
Serial.print("TAS (m/s): ");
39+
Serial.println(tas);
40+
float pa = bfs::PressureAltitude_m(90000.0f);
41+
Serial.print("Pressure Altitude (m): ");
42+
Serial.println(pa);
43+
float da = bfs::DensityAltitude_m(90000.0f, 10.0f);
44+
Serial.print("Density Altitude (m): ");
45+
Serial.println(da);
46+
float oat = bfs::Oat_c(15.0f, 400.0f);
47+
Serial.print("OAT (C): ");
48+
Serial.println(oat);
49+
float density = bfs::AirDensity_kgpm3(101325.0f, 15.0f);
50+
Serial.print("Air Density (kg/m^3): ");
51+
Serial.println(density);
52+
}
53+
54+
void loop() {}

‎examples/airdata_example.cc ‎examples/cmake/airdata_example.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
#include <iostream>
28-
#include "airdata/airdata.h"
28+
#include "airdata.h"
2929

3030
int main() {
3131
float ias = bfs::Ias_mps(500.0f);

‎img/arduino_logo_75.png

18.9 KB
Loading

‎img/logo-words_75.png

13.4 KB
Loading

‎keywords.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Ias_mps KEYWORD2
2+
Eas_mps KEYWORD2
3+
Tas_mps KEYWORD2
4+
PressureAltitude_m KEYWORD2
5+
DensityAltitude_m KEYWORD2
6+
Oat_c KEYWORD2
7+
AirDensity_kgpm3 KEYWORD2

‎library.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=Bolder Flight Systems Airdata Calculations
2+
version=3.0.0
3+
author=Brian Taylor <brian.taylor@bolderflight.com>
4+
maintainer=Brian Taylor <brian.taylor@bolderflight.com>
5+
sentence=Airdata library.
6+
paragraph=This library includes functions for computing indicated, equivalent, and true airspeed, pressure altitude, density altitude, and estimating outside air temperature and air density.
7+
category=Data Processing
8+
url=https://github.com/bolderflight/airdata
9+
architectures=*
10+
includes=airdata.h
11+
depends=Bolder Flight Systems Units

‎include/airdata/airdata.h ‎src/airdata.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323
* IN THE SOFTWARE.
2424
*/
2525

26-
#ifndef INCLUDE_AIRDATA_AIRDATA_H_
27-
#define INCLUDE_AIRDATA_AIRDATA_H_
26+
#ifndef SRC_AIRDATA_H_
27+
#define SRC_AIRDATA_H_
2828

29+
#if defined(ARDUINO)
30+
#include <Arduino.h>
31+
#endif
2932
#include <cmath>
3033
#include <type_traits>
31-
#include "units/units.h"
34+
#include "units.h" // NOLINT
3235

3336
namespace bfs {
3437
/*
@@ -135,4 +138,4 @@ T AirDensity_kgpm3(T p, const T t) {
135138
}
136139
} // namespace bfs
137140

138-
#endif // INCLUDE_AIRDATA_AIRDATA_H_
141+
#endif // SRC_AIRDATA_H_

‎tests/airdata_test.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
* IN THE SOFTWARE.
2424
*/
2525

26-
#include "airdata/airdata.h"
26+
#include "airdata.h"
2727
#include "gtest/gtest.h"
2828

29-
3029
/* Test IAS zero input */
3130
TEST(Ias, Zero) {
3231
EXPECT_EQ(0, bfs::Ias_mps(0.0f));

0 commit comments

Comments
 (0)
Please sign in to comment.