Skip to content

Commit a504d54

Browse files
Merge pull request #64 from JuliaSpaceMissionDesign/dev
Dev
2 parents 890bf20 + 9a2159b commit a504d54

File tree

17 files changed

+1021
-4
lines changed

17 files changed

+1021
-4
lines changed

docs/src/Examples/gen/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/src/Examples/gen/e01_cr3bp.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using FrameTransformations
2+
3+
CR3BP = FrameSystem{2, Float64}()
4+
5+
add_axes_root!(CR3BP, :InertialAx, 1)
6+
add_point_root!(CR3BP, :EMBc, 1, 1)
7+
8+
using ReferenceFrameRotations
9+
10+
f(t) = angle_to_dcm(t, :Z)
11+
12+
add_axes_rotating!(CR3BP, :SynodicAx, 2, 1, f)
13+
14+
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl

docs/src/Examples/gen/e01_cr3bp.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
```@meta
2+
EditURL = "../e01_cr3bp.jl"
3+
```
4+
5+
# [Use Case: CR3BP](@id example_01_cr3bp)
6+
_This example was generated on 2024-05-31T10:00:28.409._
7+
8+
The power of the [`FrameSystem`](@ref) is its capability to handle axes
9+
transformations and point translations of both high-accuracy and simplified
10+
models. The use-case here presented includes the case of the Circular-Restricted
11+
Three-Body Problem (CR3BP) rotating frame transformation handling.
12+
13+
In particular, when dealing with the [CR3BP](https://orbital-mechanics.space/the-n-body-problem/circular-restricted-three-body-problem.html),
14+
mission analysis are used to exploit non-dimensional, rotating coordinates
15+
to express the equations of motion and perform the computations.
16+
17+
In this tutorial, we create a [`FrameSystem`](@ref) to handle transformations
18+
within the Earth-Moon CR3BP, which is characterized by a mass ratio of
19+
approximately `μ = 0.012`. We start off by creating a frame system without any
20+
ephemeris provider, since we are using a simplified model.
21+
22+
````@example e01_cr3bp
23+
using FrameTransformations
24+
25+
CR3BP = FrameSystem{2, Float64}()
26+
````
27+
28+
As always, the first step requires the definition of the root axes and points.
29+
In this case, we use the a generic set of _inertial axes_ and the Earth-Moon
30+
Barycenter (EMB).
31+
32+
````@example e01_cr3bp
33+
add_axes_root!(CR3BP, :InertialAx, 1)
34+
add_point_root!(CR3BP, :EMBc, 1, 1)
35+
````
36+
37+
We now proceed to add our synodic axes: in the CR3BP these are uniformly
38+
rotating with respect to the `InertialAx` about the Z-axis. Therefore, we
39+
leverage rotating axes.
40+
41+
````@example e01_cr3bp
42+
using ReferenceFrameRotations
43+
44+
f(t) = angle_to_dcm(t, :Z)
45+
46+
add_axes_rotating!(CR3BP, :SynodicAx, 2, 1, f)
47+
````
48+
49+
Note that there is no need to specify the rotation derivatives, as they'll
50+
be computed by automatic differentiation via the
51+
[ForwardDiff](https://github.com/JuliaSpaceMissionDesign/Ephemerides.jl) package.
52+
For performace-critical transformations, however, it is reccomended to manually
53+
define these derivatives.
54+
55+
---
56+
57+
*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
58+

docs/src/Examples/gen/e02_hifi.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FrameTransformations
2+
using Ephemerides
3+
using LinearAlgebra
4+
using ReferenceFrameRotations
5+
6+
url_pck = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/moon_pa_de421_1900-2050.bpc";
7+
url_spk = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de432s.bsp";
8+
9+
EPH = EphemerisProvider([download(url_spk), download(url_pck)])
10+
11+
FRAMES = FrameSystem{3, Float64}()
12+
13+
add_axes_icrf!(FRAMES)
14+
15+
add_point_root!(FRAMES, :SSB, 0, 1)
16+
add_point_ephemeris!(FRAMES, EPH, :EMB, 3)
17+
add_point_ephemeris!(FRAMES, EPH, :Sun, 10)
18+
add_point_ephemeris!(FRAMES, EPH, :Earth, 399)
19+
add_point_ephemeris!(FRAMES, EPH, :Moon, 301)
20+
21+
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl

docs/src/Examples/gen/e02_hifi.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
```@meta
2+
EditURL = "../e02_hifi.jl"
3+
```
4+
5+
# [Use Case: High Fidelity](@id example_02_hifi)
6+
_This example was generated on 2024-05-31T10:00:28.413._
7+
8+
Once the general structure of the [`FrameSystem`](@ref) is understood, we can pass to
9+
a use case in which we want to build and exploit our frame system to perform computations
10+
in a high-fidelity environment.
11+
12+
### Frame system setup
13+
14+
In this example, we plan on using ephemeris data to retrieve accurate positions
15+
of the planets and the orientation of certain reference frames. Therefore, we
16+
create an ephemeris provider object leveraging our own
17+
[`Ephemerides.jl`](https://github.com/JuliaSpaceMissionDesign/Ephemerides.jl) package
18+
and use it to generate a frame system instance:
19+
20+
````@example e02_hifi
21+
using FrameTransformations
22+
using Ephemerides
23+
using LinearAlgebra
24+
using ReferenceFrameRotations
25+
26+
url_pck = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/moon_pa_de421_1900-2050.bpc";
27+
url_spk = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de432s.bsp";
28+
29+
EPH = EphemerisProvider([download(url_spk), download(url_pck)])
30+
31+
FRAMES = FrameSystem{3, Float64}()
32+
````
33+
34+
Once the graph is created, we assign the `ICRF` (International Celestial Reference
35+
Frame) as our set of inertial root-axes:
36+
37+
````@example e02_hifi
38+
add_axes_icrf!(FRAMES)
39+
````
40+
41+
These axes are practically coincident with the `GCRF`.
42+
43+
In this scenario, we will be working within the Cislunar environment, therefore
44+
we will need the major bodies that influence this dynamic regime, i..e, the Earth,
45+
the Moon and the Sun. To do so, we also define the Solar System Barycenter (SSB) and
46+
the Earth-Moon Barycenter (EMB) as the ephemeris data of the remaining bodies is
47+
expressed with respect to those.
48+
49+
For this example, we will assume the SSB is our root point:
50+
51+
````@example e02_hifi
52+
add_point_root!(FRAMES, :SSB, 0, 1)
53+
add_point_ephemeris!(FRAMES, EPH, :EMB, 3)
54+
add_point_ephemeris!(FRAMES, EPH, :Sun, 10)
55+
add_point_ephemeris!(FRAMES, EPH, :Earth, 399)
56+
add_point_ephemeris!(FRAMES, EPH, :Moon, 301)
57+
````
58+
59+
---
60+
61+
*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
62+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using FrameTransformations
2+
3+
G = FrameSystem{4, Float64}()
4+
5+
add_axes_icrf!(G)
6+
add_point_root!(G, :Earth, 399, 1)
7+
8+
using JSMDInterfaces.Math: interpolate
9+
using JSMDUtils.Math: InterpCubicSplines
10+
11+
c = 2π/86400
12+
de = 0:3600:2*86400;
13+
fv(t) = [cos(c*t), sin(c*t), 0, -c*sin(c*t), c*cos(c*t), 0];
14+
fv2(t) = [sin(c*t), cos(c*t), 0];
15+
const ORB1 = InterpCubicSplines(de, hcat([fv(e) for e in de]...));
16+
const ORB2 = InterpCubicSplines(de, hcat([fv2(e) for e in de]...));
17+
18+
add_point_dynamical!(G, :SC1, -1, 399, 1, t->interpolate(ORB1, t)[1:3], t->interpolate(ORB1, t))
19+
add_point_dynamical!(G, :SC2, -2, 399, 1, t->interpolate(ORB2, t))
20+
21+
vector12(G, 399, -1, 1, 12345.0)
22+
23+
vector12(G, -1, -2, 1, 12345.0)
24+
25+
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
```@meta
2+
EditURL = "../e03_customorb.jl"
3+
```
4+
5+
# [Use Case: Custom spacecraft orbit](@id example_03_orb)
6+
_This example was generated on 2024-05-31T10:00:28.419._
7+
8+
Once the general structure of the [`FrameSystem`](@ref) is understood, we can pass to
9+
a use case in which we want to build and exploit our frame system to perform computations
10+
inserting a custom orbit. This becomes especially crucial in complex cases like Trajectory
11+
Optimization and Navigation Analysis.
12+
13+
In such scenarios, the trajectory is under design, and the trajectory information might
14+
not be completely available. Moreover, in these cases derivatives could be required for
15+
various quantities such as time, states, and parameters.
16+
17+
In this context, we shall remember that `FrameTransformations` is able to perform operations,
18+
including AD, on the frames **independent variable**, e.g. only time.
19+
20+
A proper orbit representation is essential to avoid perturbation confusion and ensure
21+
proper custom orbit handling. For this purpose, two point types can seems suitable:
22+
`updatable` and `dynamical` points.
23+
In this case, however, `updatable` points are not well-suited as they are essentially
24+
constants for the AD system. Then, `dynamical` points can effectively handle this scenario.
25+
26+
### Frame system setup
27+
28+
First of all, a new [`FrameSystem`](@ref) shall be created.
29+
30+
````@example e03_customorb
31+
using FrameTransformations
32+
33+
G = FrameSystem{4, Float64}()
34+
35+
add_axes_icrf!(G)
36+
add_point_root!(G, :Earth, 399, 1)
37+
````
38+
39+
!!! note
40+
As the orbit considered in this example is custom, there is no requirement
41+
to load ephemeris.
42+
43+
### Custom orbit model
44+
45+
A custom orbit model is then required. In this case two dummy orbits are
46+
created and stored in a `CubicSpline` object.
47+
48+
````@example e03_customorb
49+
using JSMDInterfaces.Math: interpolate
50+
using JSMDUtils.Math: InterpCubicSplines
51+
52+
c = 2π/86400
53+
de = 0:3600:2*86400;
54+
fv(t) = [cos(c*t), sin(c*t), 0, -c*sin(c*t), c*cos(c*t), 0];
55+
fv2(t) = [sin(c*t), cos(c*t), 0];
56+
const ORB1 = InterpCubicSplines(de, hcat([fv(e) for e in de]...));
57+
const ORB2 = InterpCubicSplines(de, hcat([fv2(e) for e in de]...));
58+
nothing #hide
59+
````
60+
61+
### Custom orbit handling
62+
63+
Given the custom orbit model, [`add_point_dynamical!`](@ref) could be used
64+
to link it to the frame system.
65+
66+
Insert dynamical points
67+
68+
````@example e03_customorb
69+
add_point_dynamical!(G, :SC1, -1, 399, 1, t->interpolate(ORB1, t)[1:3], t->interpolate(ORB1, t))
70+
add_point_dynamical!(G, :SC2, -2, 399, 1, t->interpolate(ORB2, t))
71+
````
72+
73+
Once in the frame system, AD could be exploited to retrieve states+gradients w.r.t.
74+
time in any registered frame:
75+
76+
````@example e03_customorb
77+
vector12(G, 399, -1, 1, 12345.0)
78+
````
79+
80+
It is also possible to use the computational graph to compute quantities between
81+
completely custom states representations:
82+
83+
````@example e03_customorb
84+
vector12(G, -1, -2, 1, 12345.0)
85+
````
86+
87+
---
88+
89+
*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
90+

docs/src/Tutorials/gen/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FrameTransformations
2+
using Tempo
3+
4+
F = FrameSystem{2, Float64}()
5+
6+
F = FrameSystem{2, Float64, InternationalAtomicTime}()
7+
8+
has_point(F, 1)
9+
10+
has_axes(F, 1)
11+
12+
has_direction(F, :Root)
13+
14+
axes(F)
15+
16+
points(F)
17+
18+
order(F)
19+
20+
FrameTransformations.timescale(F)
21+
22+
using Ephemerides, Downloads
23+
24+
url = "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/a_old_versions/de421.bsp";
25+
eph = EphemerisProvider(Downloads.download(url));
26+
27+
F = FrameSystem{2, Float64}()
28+
29+
add_axes_icrf!(F)
30+
add_point_root!(F, :SSB, 0, 1)
31+
32+
add_point_ephemeris!(F, eph, :Sun, 10)
33+
add_point_ephemeris!(F, eph, :EMB, 3)
34+
35+
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl

0 commit comments

Comments
 (0)