Real-time satellite position tracker.
A GenServer that continuously propagates a satellite's position and broadcasts updates to subscribers. Multiple trackers can run concurrently for different satellites.
Examples
# Start tracking ISS
{:ok, [tle]} = Orbis.CelesTrak.fetch_tle(25544)
{:ok, tracker} = Orbis.Tracker.start_link(tle, interval_ms: 1000)
# Get current position
state = Orbis.Tracker.get_state(tracker)
state.position #=> {x, y, z} in km
state.geodetic #=> %{latitude: ..., longitude: ..., altitude_km: ...}
# Subscribe to updates
Orbis.Tracker.subscribe(tracker)
receive do
{:orbis_tracker, ^tracker, state} ->
IO.puts("ISS at #{state.geodetic.latitude}, #{state.geodetic.longitude}")
end
# Stop tracking
Orbis.Tracker.stop(tracker)
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the current tracking state.
Start tracking a satellite.
Stop tracking.
Subscribe the calling process to position updates.
Unsubscribe the calling process from position updates.
Update the TLE for a tracked satellite (e.g., after fetching a newer one).
Types
@type state() :: %Orbis.Tracker{ catalog_number: String.t(), geodetic: map() | nil, interval_ms: pos_integer(), last_update: DateTime.t() | nil, monitors: term(), position: {float(), float(), float()} | nil, pubsub: term(), subscribers: MapSet.t(), timer_ref: reference() | nil, tle: Orbis.Elements.t(), velocity: {float(), float(), float()} | nil }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_state(GenServer.server()) :: map()
Get the current tracking state.
Returns a map with position, velocity, geodetic coordinates, and timestamp.
@spec start_link( Orbis.Elements.t(), keyword() ) :: GenServer.on_start()
Start tracking a satellite.
Options
:interval_ms- update interval in milliseconds (default: 1000):name- optional registered name for the process:pubsub-{module, pubsub_name, topic}to broadcast via Phoenix.PubSub (or any module implementingbroadcast/3). Messages are sent as{:orbis_tracker, tracker_pid, state_map}, the same shape as direct subscriber messages.
Examples
{:ok, tracker} = Orbis.Tracker.start_link(tle)
{:ok, tracker} = Orbis.Tracker.start_link(tle, interval_ms: 5000)
# With Phoenix PubSub
{:ok, tracker} = Orbis.Tracker.start_link(tle,
pubsub: {Phoenix.PubSub, MyApp.PubSub, "satellite:25544"})
@spec stop(GenServer.server()) :: :ok
Stop tracking.
@spec subscribe(GenServer.server()) :: :ok
Subscribe the calling process to position updates.
Updates are sent as {:orbis_tracker, tracker_pid, state_map}.
@spec unsubscribe(GenServer.server()) :: :ok
Unsubscribe the calling process from position updates.
@spec update_tle(GenServer.server(), Orbis.Elements.t()) :: :ok
Update the TLE for a tracked satellite (e.g., after fetching a newer one).