Code Monkey home page Code Monkey logo

sgp4-rs's Introduction

sgp4-rs

CI Status Docs Crate

This crate implements a wrapper around the C++ implementation of the SGP-4 orbital propagator as provided in the "Revisiting Spacetrack Report #3" paper (link). It provides high level bindings to the propagator library with a more modern interface.

Our approach separates the low-level unsafe bindings into the sgp4_sys module, while safe functions are exported through the library's root module. Because the underlying SGP4 implementation is thread-safe, this crate can be used in multithreaded environments and with async/await code.

We have not created bindings to every function in the library, especially as some of them are duplicative of Rust standard library functions. The core propagator functionality is exposed, and allows predicting an orbiting body's state vector at a given time from two line element data.

Building

sgp4 builds cleanly on the stable Rust channel, but does require a local C++ compiler to be present in order to build the wrapped SGP4 library.

Experimental Features

The tlegen feature adds basic support for creating custom TLEs from a set of orbital elements. This feature is subject to several important caveats, so it is not enabled by default. See the ClassicalOrbitalElements documentation for details.

Related

The sgp4 crate is a pure Rust reimplementation of the Vallado library which this crate wraps.

sgp4-rs's People

Contributors

barry-king-spire avatar dependabot[bot] avatar eilidh-spire avatar nick-pascucci-spire avatar spire-ffoston avatar spire-josh-singer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sgp4-rs's Issues

Undefined behavior in `test_negative_time_propagation`

I've been experimenting with a version of Miri that can execute foreign functions by interpreting the LLVM bytecode that is produced during a crate's build process. We're hoping that our results can assist with the Krabcake project.

Miri found the following error in the test case tests::test_negative_time_propagation

---- Foreign Error Trace ----

@ store i8 95, ptr %80, align 1, !dbg !639

.../sgp4-rs/src/sgp4/sgp4io.cpp:102:19
src/sgp4_sys.rs:463:9: 474:10
-----------------------------

error: Undefined Behavior: attempting a write access using <102969> at alloc26549[0xf], but that tag only grants SharedReadOnly permission for this location
    |
    = note: attempting a write access using <102969> at alloc26549[0xf], but that tag only grants SharedReadOnly permission for this location
    = note: this error occurs as part of an access at alloc26549[0xf..0x10]
    = note: (no span available)
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <102969> was created by a SharedReadOnly retag at offsets [0x0..0x46]
   --> src/sgp4_sys.rs:464:13
    |
464 |             l1.as_ptr(),
    |             ^^^^^^^^^^^

The pointer created by l1.as_ptr() has read-only permissions, but the C function twoline2rv mutates it.

  for (j = 10; j <= 15; j++)
    if (longstr1[j] == ' ')
      longstr1[j] = '_'

This seems like it would be non-trivial to fix, since l1 is an &str that's passed down through a constructor. Unless copying the string into a temporary variable would be a valid solution.

Idea: use `hifitime` instead of `chrono`

Hi there!

Sorry for jumping in out of the blue: I also work in astrodynamics and, over the past few years, I've developed hifitime. It's specifically for converting between different time scales. This is quite important in cislunar and interplanetary work, which is what I focus on.

Anyway, I saw that you were using DateTime<Utc> from chrono to store the epoch of your orbital elements. I developed hifitime specifically for Nyx initially (cf. the Orbit structure), but it does everything chrono and timers do, so I've been trying to see what projects might benefit from more precision.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.