Skip to content

Commit c9dfa1f

Browse files
Update README.md
1 parent 3a84dd9 commit c9dfa1f

1 file changed

Lines changed: 181 additions & 1 deletion

File tree

README.md

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,183 @@
11
# FOVSimulator.jl
22

3-
Julia-based FOV simulator for a spacecraft camera.
3+
FOVSimulator.jl is a Julia package for simulating camera field of view (FOV) in space missions. It specializes in camera simulations for observing celestial bodies such as asteroids, providing high-precision position and attitude calculations using SPICE kernels and image generation capabilities through ray tracing.
4+
5+
## Features
6+
7+
- High-precision position and attitude calculations for spacecraft, cameras, and celestial bodies using SPICE kernels
8+
- Ray tracing-based intersection detection for asteroid shape models
9+
- Thermal image simulation in conjunction with thermophysical models
10+
- Fast intersection detection algorithms using bounding boxes
11+
- Support for multiple bodies (e.g., binary asteroid systems)
12+
13+
## Installation
14+
15+
You can install the package using Julia's package manager:
16+
17+
```julia
18+
using Pkg
19+
Pkg.add(url="https://github.com/Astroshaper/FOVSimulator.jl")
20+
```
21+
22+
Or in the package manager mode in Julia REPL (press `]` to enter):
23+
24+
```julia
25+
] add https://github.com/Astroshaper/FOVSimulator.jl
26+
```
27+
28+
## Dependencies
29+
30+
- LinearAlgebra
31+
- Rotations
32+
- StaticArrays
33+
- SPICE
34+
- AsteroidThermoPhysicalModels
35+
36+
## Basic Usage
37+
38+
### 1. Import Required Modules
39+
40+
```julia
41+
using FOVSimulator
42+
using SPICE
43+
```
44+
45+
### 2. Load SPICE Kernels
46+
47+
```julia
48+
# Load SPICE kernels
49+
SPICE.furnsh("path/to/kernel/file.tm")
50+
```
51+
52+
### 3. Set Up Camera
53+
54+
```julia
55+
# Specify camera NAIF ID, FOV angles, and image size
56+
camera_id = -12345 # Camera NAIF ID
57+
fov_angles = (10.0, 8.0) # FOV angles (width, height) [degrees]
58+
img_size = (1024, 768) # Image size (width, height) [pixels]
59+
60+
# Create camera object
61+
camera = SpiceCamera("CAMERA_NAME", camera_id, fov_angles, img_size)
62+
```
63+
64+
### 4. Set Up Spacecraft
65+
66+
```julia
67+
# Create spacecraft object
68+
spacecraft = SpiceSpacecraft("SPACECRAFT_NAME")
69+
70+
# Mount camera on spacecraft
71+
add_instrument!(spacecraft, camera)
72+
```
73+
74+
### 5. Set Up Asteroid
75+
76+
```julia
77+
# Load shape model
78+
shape = AsteroidThermoPhysicalModels.load_shape_obj("path/to/shape.obj", scale=1000) # `scale` factor converts [km] to [m]
79+
80+
# Create asteroid object
81+
asteroid = SpiceAsteroid("ASTEROID_NAME", shape, "ASTEROID_FIXED_FRAME")
82+
```
83+
84+
### 6. Update States
85+
86+
```julia
87+
# Set simulation time
88+
et = SPICE.str2et("2025-01-01T12:00:00") # Ephemeris time
89+
ref = "J2000" # Reference frame
90+
abcorr = "NONE" # Aberration correction flag
91+
obs = "EARTH" # Observer
92+
93+
# Update spacecraft and asteroid states
94+
update!(spacecraft, et, ref, abcorr, obs)
95+
update!(asteroid, et, ref, abcorr, obs)
96+
```
97+
98+
### 7. Generate Intersection Map
99+
100+
```julia
101+
# Perform intersection detection for each pixel
102+
intersection_map = generate_intersection_map(spacecraft.state.instruments["CAMERA_NAME"], asteroid)
103+
```
104+
105+
### 8. Generate Image
106+
107+
```julia
108+
# Generate thermal image using temperature data
109+
temperatures = fill(300.0, length(asteroid.static.shape.faces)) # Example: set all faces to 300K
110+
image = generate_image_temperature(intersection_map, temperatures)
111+
112+
# Generate radiance image using emissivity and temperature data
113+
emissivities = fill(0.9, length(asteroid.static.shape.faces)) # Example: set all faces to 0.9 emissivity
114+
radiance_image = generate_image_radiance(intersection_map, emissivities, temperatures)
115+
```
116+
117+
## Advanced Usage
118+
119+
### Binary Asteroid Simulation
120+
121+
```julia
122+
# Set up primary and secondary asteroids
123+
primary = SpiceAsteroid("PRIMARY", shape_primary, "PRIMARY_FIXED_FRAME")
124+
secondary = SpiceAsteroid("SECONDARY", shape_secondary, "SECONDARY_FIXED_FRAME")
125+
126+
# Update states
127+
update!(spacecraft, et, ref, abcorr, obs)
128+
update!(primary, et, ref, abcorr, obs)
129+
update!(secondary, et, ref, abcorr, obs)
130+
131+
# Generate intersection maps
132+
intersection_map1 = generate_intersection_map(spacecraft.state.instruments["CAMERA_NAME"], primary)
133+
intersection_map2 = generate_intersection_map(spacecraft.state.instruments["CAMERA_NAME"], secondary)
134+
135+
# Generate thermal image (considering both asteroids)
136+
image = generate_image_temperature(
137+
intersection_map1, temperatures_primary,
138+
intersection_map2, temperatures_secondary
139+
)
140+
```
141+
142+
### Integration with Thermophysical Models
143+
144+
You can integrate with the AsteroidThermoPhysicalModels package to calculate asteroid surface temperatures and use them for thermal image simulation. See the test file `test/TIRI_image_Didymos.jl` for a detailed example.
145+
146+
## Key Components
147+
148+
### SpiceCamera
149+
150+
Represents a camera model based on SPICE kernels. Manages static camera information (name, ID, FOV shape, etc.) and dynamic state (position, velocity, etc.).
151+
152+
### SpiceSpacecraft
153+
154+
Represents a spacecraft model based on SPICE kernels. Manages static spacecraft information and dynamic state, and can carry multiple instruments (cameras, etc.).
155+
156+
### SpiceAsteroid
157+
158+
Represents an asteroid model based on SPICE kernels. Manages static asteroid information (name, shape model, fixed frame, etc.) and dynamic state (position, velocity, etc.).
159+
160+
### Ray
161+
162+
Represents a ray for ray tracing. Contains an origin point and a direction vector.
163+
164+
### BoundingBox
165+
166+
Represents a bounding box for a shape model. Used to accelerate intersection detection.
167+
168+
### Intersection Detection Functions
169+
170+
- `intersect_ray_triangle`: Detects intersection between a ray and a triangle
171+
- `intersect_ray_shape`: Detects intersection between a ray and a shape model
172+
- `intersect_ray_bounding_box`: Detects intersection between a ray and a bounding box
173+
174+
### Image Generation Functions
175+
176+
- `generate_pixel_rays`: Generates rays corresponding to each pixel of a camera
177+
- `generate_intersection_map`: Generates intersection results for each pixel and an asteroid surface
178+
- `generate_image_temperature`: Generates a thermal image from intersection results and surface temperatures
179+
- `generate_image_radiance`: Generates a radiance image from intersection results, emissivities, and surface temperatures
180+
181+
## License
182+
183+
This package is released under the MIT License. See the LICENSE file for details.

0 commit comments

Comments
 (0)