Giter Site home page Giter Site logo

gavineadie / satellitekit Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 6.0 358 KB

SatelliteKit is a library, written in Swift, implementing the SGP4/SDP4 earth-orbiting satellite propagation algorithms first published in the SpaceTrack Report #3 and later refined by Vallado et al in Revisiting Spacetrack Report #3.

License: MIT License

Swift 100.00%

satellitekit's People

Contributors

gavineadie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

satellitekit's Issues

propagator.getPVCoordinates(minsAfterEpoch:) crash

Summary

I am experiencing the following fatal error:

SatKitError.SGP("ERROR 4: semi-latus rectum < 0.0")

When I try to calculate the position of the JWST using:

Satellite.geoPosition(minsAfterEpoch:)

Detail

I have the following TLE for JWST:

0 JWST
1 50463U 21130A 21362.00000000 .00000000 00000-0 00000-0 0 9999
2 50463 4.6198 89.0659 9884983 192.3200 17.4027 0.01958082 27

Which I fetched from space-track.org

I am constructing the Satellite like so:

guard formatOK(TLE_LINE1, TLE_LINE2) else {
    throw TLEError.formatNotOkay
}
let elements = try Elements(TLE_LINE0, TLE_LINE1, TLE_LINE2)
let satellite = Satellite(elements: elements)
return satellite.geoPosition(minsAfterEpoch: 10)

Thanks for any help!

Crash when getting geo position

Summary

App crashes when geoPosition(julianDays:) is called.

STR

  1. use this data set
  2. parse data using:
let satellites = preProcessTLEs(content)
             .filter { formatOK($0.1, $0.2) }
             .compactMap { try? TLE($0.0, $0.1, $0.2) }
             .map { Satellite(withTLE: $0) }
  1. try to get geo location for each satellite using:
let date = Date().julianDate
satellites.forEach { sat in
     let lat = sat.geoPosition(julianDays: date).lat
     let lon = sat.geoPosition(julianDays: date).lon
}
  1. app crashes on SatelliteKit/Satellite.swift:72: Fatal error: Satellite Position Error FALCON 9 DEB .. SatelliteKit.SatKitError (1)

Is this a bug, or am I doing something wrong? It works just fine for some satellites in a set, but crashes on FALCON 9 DEB each time.

Issue with velocity from PV coordinates

This is most likely an issue in my understanding, however I am seeing an inconsistency between the direction of a satellites velocity vector and where it actually ends up moving. The image below shows the discrepancy.

The green dots are the positions of the ISS calculated at 10 second intervals. The blue dots are estimated positions of the ISS by adding the initial velocity vector to the initial position, scaled at 10 second intervals. As you can see there is about a 2 degree difference in direction. (Ignore the different spacing between dots - that's a different issue)

Satellite issue

Here is the code I used to generate these points. Any help with this issue would be greatly appreciated.

private func testPropagate(_ p: Propagator) {
    var date = Date.now
    
    let initialPV = try! p.getPVCoordinates(date)
    
    let geo = eci2geo(julianDays: date.julianDate, celestial: initialPV.position)
    let initialXYZ = self.convertRealPositionTo3DSpace(geo2xyz(geodetic: geo).simd, ofEarthRadius: 1)
    
    let velGeo = eci2geo(julianDays: date.julianDate, celestial: initialPV.velocity)
    let initialVel = self.convertRealPositionTo3DSpace(geo2xyz(geodetic: velGeo).simd, ofEarthRadius: 1)
    
    let startNode = self.createDebugNode()
    startNode.simdPosition = initialXYZ
    startNode.simdPosition = simd_normalize(startNode.simdPosition)
    
    let timeStep = Float(10)
    for i in 0..<100 {
        
        date = date.addingTimeInterval(Double(timeStep))
        
        let vNode = createDebugNode(color: .systemCyan)
        vNode.simdPosition = initialXYZ + (initialVel * simd_float3(repeating: timeStep * Float(i)))
        vNode.simdPosition = simd_normalize(vNode.simdPosition)
        
        let newPV = try! p.propagator.getPVCoordinates(date)
        let newGeo = eci2geo(julianDays: date.julianDate, celestial: newPV.position)
        let newXYZ = self.convertRealPositionTo3DSpace(geo2xyz(geodetic: newGeo).simd, ofEarthRadius: 1)
        let pNode = createDebugNode(color: .systemGreen)
        pNode.simdPosition = simd_normalize(newXYZ)
        
    }
}
private func convertRealPositionTo3DSpace(_ position: simd_float3, ofEarthRadius earthRadius: Float) -> simd_float3 {
    let realEarthRadius = Float(EarthConstants.Rโ‚‘)
    return simd_float3(
        position.x / 1000 / realEarthRadius / earthRadius,
        position.y / 1000 / realEarthRadius / earthRadius,
        position.z / 1000 / realEarthRadius / earthRadius
    )
}
extension Vector {
    /// Converts Vector into Scenekit coordinate system
    var simd: simd_float3 {
        return simd_float3(Float(-self.x),
                           Float(self.z),
                           Float(self.y))
    }
}

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.