Skip to content

Commit

Permalink
Merge pull request #358 from spacelab-ufsc/feature_predict
Browse files Browse the repository at this point in the history
Feature predict
  • Loading branch information
c-porto authored Aug 30, 2024
2 parents c15ace9 + 0fe432a commit 02e4603
Show file tree
Hide file tree
Showing 82 changed files with 4,339 additions and 15,488 deletions.
52 changes: 0 additions & 52 deletions firmware/app/libs/libpredict/.gitignore

This file was deleted.

30 changes: 0 additions & 30 deletions firmware/app/libs/libpredict/CONTRIBUTING.md

This file was deleted.

File renamed without changes.
45 changes: 32 additions & 13 deletions firmware/app/libs/libpredict/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
TARGET=libpredict.a
LIB_PREDICT_VERSION = 0.5

ifndef BUILD_DIR
BUILD_DIR=$(CURDIR)
endif
STATIC_TARGET := libpredict.a
SHARED_TARGET := libpredict.so.$(LIB_PREDICT_VERSION)

AR=ar
FLAGS=rcs
BUILD_DIR ?= $(CURDIR)

BUILD_DIR_ABS = $(abspath $(BUILD_DIR))

INSTALL_DIR ?= /usr/lib/

TOOLCHAIN_PREFIX ?=
AR_FLAGS_APPEND ?=
LD_FLAGS_APPEND ?=
CC_FLAGS_APPEND ?=

AR_FLAGS := rcs
LD_FLAGS := -shared -soname $(SHARED_TARGET) -lc -lm

AR_FLAGS += $(AR_FLAGS_APPEND)
LD_FLAGS += $(LD_FLAGS_APPEND)

AR := $(TOOLCHAIN_PREFIX)ar
LD := $(TOOLCHAIN_PREFIX)ld

.PHONY: all
all:
@echo "Compiling libpredict..."
$(MAKE) BUILD_DIR=$(BUILD_DIR) -C src
$(AR) $(FLAGS) $(BUILD_DIR)/$(TARGET) $(BUILD_DIR)/*.o
$(MAKE) -C src BUILD_DIR=$(BUILD_DIR_ABS) TOOLCHAIN_PREFIX=$(TOOLCHAIN_PREFIX) CC_FLAGS_APPEND="$(CC_FLAGS_APPEND)"
$(AR) $(AR_FLAGS) $(BUILD_DIR_ABS)/$(STATIC_TARGET) $(BUILD_DIR_ABS)/*.o
$(LD) $(LD_FLAGS) -o $(BUILD_DIR_ABS)/$(SHARED_TARGET) $(BUILD_DIR_ABS)/*.o

.PHONY: install
install:
@echo "Installing libpredict driver..."
cp -r $(BUILD_DIR)/$(TARGET) /usr/lib/
@echo "Installing libpredict..."
cp -r $(BUILD_DIR_ABS)/$(SHARED_TARGET) $(INSTALL_DIR)
cp -r $(BUILD_DIR_ABS)/$(STATIC_TARGET) $(INSTALL_DIR)
cp -r include/predict /usr/include/

.PHONY: uninstall
uninstall:
@echo "Uninstalling libpredict driver..."
rm /usr/lib/$(TARGET)
@echo "Uninstalling libpredict..."
rm $(INSTALL_DIR)/$(STATIC_TARGET)
rm $(INSTALL_DIR)/$(SHARED_TARGET)
rm -r /usr/include/predict/

.PHONY: clean
clean:
rm $(BUILD_DIR)/*.o $(BUILD_DIR)/*.a
rm $(BUILD_DIR_ABS)/*.o $(BUILD_DIR_ABS)/*.a $(BUILD_DIR_ABS)/*.so*
114 changes: 46 additions & 68 deletions firmware/app/libs/libpredict/README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,64 @@
libpredict
==========
<h1 align='center'> libpredict </h1>

A satellite orbit prediction library.
<h2 align='center'> <strong> A satellite orbit prediction library. </strong> </h2>

This is a fork of **[la1k/libpredict](https://github.com/la1k/libpredict/)** and is inspired by **[philcrump's](https://github.com/philcrump/libpredict/)** fork of the same library.

Building
--------
## Major differences from la1k's library

We recommend using out-of-source builds.
This fork is intended to be used on embedded systems, therefore it supports static allocated
structs, instead of the dynamic allocated ones from the original library. Another major
change is that this fork intends to make the library MISRA-C 2012 compliant, which is
a requirement for many critical embedded applications, like spacecraft. Because of
compliance, pretty much every single function of the original library will be modified.

```
cd $SOURCEDIR
mkdir build
cd build
cmake ..
make
```
## MISRA-C 2012 Compliance Progress

The following list contains the status of the library files:

- [X] Headers
- [X] Orbit
- [ ] Observer
- [X] SGP4
- [ ] SDP4
- [X] Sun
- [ ] Moon
- [X] Unsorted
- [X] Julian Date
- [ ] Refraction

## Building

Installation
------------
To build the library it should be as simple as running:

``` bash
make
```
make install

To specify a custom build directory you can do as follows:

``` bash
make BUILD_DIR=/your/build/dir/
```

The install location is defined by `CMAKE_INSTALL_PREFIX`, which
defaults to `/usr/local`. To relocate the whole installation (to make
usr/local etc. inside another directory, e.g., if you want to make a
tarball or package it afterwards), use `make DESTDIR=/foo/bar install`.
To specify a custom toolchain prefix, like the arm-none-eabi, you can do as follows:

Linking
-------
``` bash
make TOOLCHAIN_PREFIX=arm-none-eabi- CC_FLAGS_APPEND="-mthumb -mcpu=cortex-m3"
```

The library comes with pkg-config information, so the include and
library paths and flags can be found using the `pkg-config` command or
by using the `PKG_CHECK_MODULES` autotools macro or CMake command.
Note that any compiler, linker and ar flags can be appended to the default ones using
`CC_FLAGS_APPEND`, `LD_FLAGS_APPEND` and `AR_FLAGS_APPEND` variables. The previous
toolchain example shows how its done aswell.

Quickstart
----------

We recommend to investigate the examples under `examples/` and the API documentation in `include/predict/predict.h`.
## Installation

A condensed version is that
```
predict_orbital_elements_t *orbital_elements = orbital_elements = predict_parse_tle(tle_line_1, tle_line_2);
```
parses a TLE in the form of two char arrays to orbital elements representing a satellite, and that
```
predict_observer_t *observer = predict_create_observer(name, latitude_radians, longitude_radians, altitude_meters);
```
defines a QTH for observation. For prediction,
```
struct predict_position orbit;
predict_orbit(orbital_elements, &orbit, prediction_time);
```
can be used to calculate properties that are independent of an observer (longitude, latitude, ...), while
```
struct predict_observation observation;
predict_observe_orbit(observer, &orbit, &observation);
make install
```
will convert to properties that will be relative to our observer (azimuth, elevation, ...).

License
-------

Copyright 1991-2006 John A. Magliacane (KD2BD)

Copyright 2013- Akademisk radioklubb (LA1K)

Copyright 2013-2015 Knut Magnus Kvamtrø (LA3DPA)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

The install location is defined by `INSTALL_DIR`, which
defaults to `/usr/lib`. To relocate the whole installation (to make
usr/local etc. inside another directory, e.g., if you want to make a
tarball or package it afterwards), use `make INSTALL_DIR=/foo/bar install`.
1 change: 0 additions & 1 deletion firmware/app/libs/libpredict/examples/basic/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions firmware/app/libs/libpredict/examples/basic/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions firmware/app/libs/libpredict/examples/basic/README

This file was deleted.

69 changes: 0 additions & 69 deletions firmware/app/libs/libpredict/examples/basic/main.c

This file was deleted.

6 changes: 0 additions & 6 deletions firmware/app/libs/libpredict/examples/orbit-2d/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 02e4603

Please sign in to comment.