コンテンツにスキップ

SunSensor

このコンテンツはまだ日本語訳がありません。

Defined in: sun_sensor.rs:45

pub struct SunSensor

Sun sensor that measures the sun direction in the body frame.

Computes the satellite→Sun unit vector and rotates it into the body frame via the attitude quaternion:

d_eci = normalize(sun_pos_eci - sc_pos_eci)
d_body = noise(R_bi · d_eci)

When any body can block the Sun (occulters is not empty), the sensor also computes the illumination fraction. During total eclipse (illumination = 0), direction is None.

fn new() -> Self

Create an ideal sun sensor (no noise, no eclipse) for Earth orbit.

The Sun direction is geocentric. Use for_body(Self::for_body) for any other central body: from Mars in 2026 the geocentric direction is up to 176° away from where Mars sees the Sun.


fn for_earth() -> Self

Create a sun sensor for Earth orbit with conical shadow model.


fn for_body(body: KnownBody) -> [Result<Self, SunPositionError>](https://doc.rust-lang.org/std/result/enum.Result.html)

Create a sun sensor for orbit about body, with that body’s shadow.

Orbiting the Sun puts it at the origin, so the direction is -r_sat and nothing eclipses it. Fails for a central body with no Sun ephemeris (Uranus, Neptune).


fn with_noise(self, noise: impl NoiseModel + ‘static) -> Self

Add a noise model. Multiple calls chain in order.


fn without_shadow(self) -> Self

Drop the shadow, keeping the Sun direction this sensor was built with (builder pattern).

The same builder the two SRP models have: for_body(body)? carries that body’s conical shadow, and this asks for an unshadowed reading without going back to the geocentric Sun that new() reads.


fn with_shadow_body(self, radius: f64) -> Self

Set the shadow body radius for eclipse computation.

Panics unless the radius is finite and positive, as OccultingBody::central(crate::eclipse::OccultingBody::central) does: a body of no radius would silently stop casting a shadow.


fn with_shadow_model(self, model: ShadowModel) -> Self

Set the shadow model. Set the shadow geometry of the central body.

A distant occulter keeps its own: the Earth seen from a lunar orbit has to stay conical, where a cylindrical shadow would call 6.83 hours a year dark against the true 3.67.


fn with_occulter(self, occulter: OccultingBody) -> Self

Add a body that can block the Sun, beside those already there.


fn measure(&mut self, t: f64, state: &SpacecraftState, epoch: &Epoch) -> SunSensorOutput

Measure the sun direction in the body frame (fine sun sensor).

Returns SunSensorOutput::Fine with:

  • direction: Some(...), a unit vector, when the sun is visible (illumination > 0) and the noisy vector still has a direction
  • direction: None when in total eclipse (illumination = 0), when the spacecraft is at the Sun’s centre, or when noise left a zero or non-finite vector
  • illumination in [0, 1]: actual eclipse-aware illumination fraction, reported whether or not a direction came out

t is the sim time of the sample [s], which the noise models are keyed on.


fn measure_in_frame<F: EphemerisFrameBridge>(&mut self, t: f64, state: &SpacecraftState<F>, epoch: &Epoch) -> SunSensorOutput

Measure the sun direction in the body frame for a state propagated in an arbitrary inertial frame F.

The analytic Sun ephemeris is expressed in Gcrs, so it is rotated into F via EphemerisFrameBridge before being differenced with the spacecraft position — identity for SimpleEci/Gcrs (preserving the historical behavior exactly), the precession/nutation rotation for an of-date frame such as Cirs. A frame without that impl is a compile error rather than a silent GCRS-alignment assumption.