Line data Source code
1 0 : /*
2 : * Copyright (c) 2023 Trackunit Corporation
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef ZEPHYR_INCLUDE_DATA_NAVIGATION_H_
8 : #define ZEPHYR_INCLUDE_DATA_NAVIGATION_H_
9 :
10 : #include <zephyr/types.h>
11 :
12 : /**
13 : * @brief Navigation utilities
14 : * @defgroup navigation Navigation
15 : * @ingroup utilities
16 : * @{
17 : */
18 :
19 : /**
20 : * @brief Navigation data structure
21 : *
22 : * @details The structure describes the momentary navigation details of a
23 : * point relative to a sphere (commonly Earth)
24 : */
25 1 : struct navigation_data {
26 : /** Latitudal position in nanodegrees (0 to +-180E9) */
27 1 : int64_t latitude;
28 : /** Longitudal position in nanodegrees (0 to +-180E9) */
29 1 : int64_t longitude;
30 : /** Bearing angle in millidegrees (0 to 360E3) */
31 1 : uint32_t bearing;
32 : /** Speed in millimeters per second */
33 1 : uint32_t speed;
34 : /** Altitude above MSL in millimeters */
35 1 : int32_t altitude;
36 : };
37 :
38 : /**
39 : * @brief Calculate the distance between two navigation points along the
40 : * surface of the sphere they are relative to.
41 : *
42 : * @param distance Destination for calculated distance in millimeters
43 : * @param p1 First navigation point
44 : * @param p2 Second navigation point
45 : *
46 : * @return 0 if successful
47 : * @return -EINVAL if either navigation point is invalid
48 : */
49 1 : int navigation_distance(uint64_t *distance, const struct navigation_data *p1,
50 : const struct navigation_data *p2);
51 :
52 : /**
53 : * @brief Calculate the bearing from one navigation point to another
54 : *
55 : * @param bearing Destination for calculated bearing angle in millidegrees
56 : * @param from First navigation point
57 : * @param to Second navigation point
58 : *
59 : * @return 0 if successful
60 : * @return -EINVAL if either navigation point is invalid
61 : */
62 1 : int navigation_bearing(uint32_t *bearing, const struct navigation_data *from,
63 : const struct navigation_data *to);
64 :
65 : /**
66 : * @}
67 : */
68 :
69 : #endif /* ZEPHYR_INCLUDE_DATA_NAVIGATION_H_ */
|