Simulating a dynamic satellite constellation network using SatelliteToolbox.jl

Hi everyone,

I am trying to simulate a dynamic satellite constellation network using SatelliteToolbox. The goal is to use this network and integrate it with the QuNet package for benchmarking and performance analysis as a function of various parameter such as the satellite mesh density, ground node separation, number of users etc. The input to QuNet will be a graph, representing the simulated network at given point in time.

I am completely new to Julia so kind of stuck at the first phase still, trying to simulate the network to go with. This is what I have done so far, using TLE data of Starlink from this link,

https://celestrak.org/NORAD/elements/gp.php?GROUP=starlink&FORMAT=tle

using SatelliteToolbox
using Dates

# Load TLE data from a file
filename = "starlink.txt"
tles = read_tle(filename)

# Initialize an SGP4 propagator for each satellite
propagators = [init_orbit_propagator(Val(:sgp4), tle) for tle in tles]

# Define the time period for the simulation
start_time = DateTime(2023, 4, 26, 0, 0, 0)
end_time = DateTime(2023, 4, 26, 1, 0, 0)
time_step = Minute(180)

# Initialize the time array
time_array = collect(start_time:time_step:end_time)

# Initialize position and velocity arrays for each satellite
num_satellites = length(propagators)
sat_positions_eci = zeros(num_satellites, 3, length(time_array))
sat_positions_ecef = zeros(num_satellites, 3, length(time_array))
sat_positions_geodetic = zeros(num_satellites, 3, length(time_array))
sat_velocities = zeros(num_satellites, 3, length(time_array))

# Propagate the orbits for the entire simulation period using propagate_to_epoch!
for (i, t) in enumerate(time_array)
    for (j, propagator) in enumerate(propagators)
        tle = tles[j] # Access the TLE object for the current satellite
        JD_t = Dates.datetime2julian(t)
        r_eci, v_eci = propagate_to_epoch!(propagator, JD_t) # Using propagate_to_epoch! function

        # Store ECI position and velocity data
        sat_positions_eci[j, :, i] = r_eci
        sat_velocities[j, :, i] = v_eci

        # Convert ECI to ECEF
        r_ecef = r_eci_to_ecef(r_eci, JD_t)
        sat_positions_ecef[j, :, i] = r_ecef

        # Convert ECEF to geodetic coordinates
        lat, lon, alt = ecef_to_geodetic(r_ecef)
        sat_positions_geodetic[j, :, i] = [lat, lon, alt]
    end
end

# Now `sat_positions_eci`, `sat_positions_ecef`, and `sat_positions_geodetic` hold the position data for each satellite in ECI, ECEF, and geodetic coordinates, respectively

I am getting the following error from the code above,

MethodError: no method matching r_eci_to_ecef(::SVector{3, Float64}, ::Float64)

Can someone please correct my mistakes and possibly guide me to achieve what I am trying to do?
Thanks in advance!

Hi! I’m not familiar with that package, but this error usually means you’re calling your function with arguments of the wrong type. One way to investigate is to ask your REPL for the documentation of the function, by typing a ? and then the name of the function:

help?> r_eci_to_ecef

If the docstring is insufficient, you might take a look at the list of methods (concrete implementations) for that function:

methods(r_eci_to_ecef)
1 Like