Skip to content

Commit

Permalink
Merge pull request #599 from ut-issl/feature/refactor-gnss-receiver
Browse files Browse the repository at this point in the history
Refactor GNSS receiver
  • Loading branch information
200km committed Mar 12, 2024
2 parents 21b793d + 0e9eafc commit ccc3b96
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 234 deletions.
35 changes: 15 additions & 20 deletions data/sample/initialize_files/components/gnss_receiver.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,32 @@ antenna_position_b_m(0) = 0.0125
antenna_position_b_m(1) = 0.0000
antenna_position_b_m(2) = 0.1815

// Quaternion from body frame to component frame
// Quaternion from body frame to component frame of the antenna
// Note: The antenna boresight direction is +Z direction at the component frame
quaternion_b2c(0) = 0.0
quaternion_b2c(1) = 0.0
quaternion_b2c(2) = 0.0
quaternion_b2c(3) = 1.0

// Antenna model
// 0... simple model : GNSS sats are visible when antenna directs anti-earth direction
// 1... cone model : GNSS sats visible when a sat is in a cone
antenna_model = 0
// SIMPLE: We assume that GNSS satellites are visible when antenna directs anti-earth direction
// CONE: We calculate the number of GNSS satellites in the antenna,
// and the position is observable when more than 4 satellites are in the antenna.
// Note : We need to enable the GNSS satellite calculation when we use this mode.
// All satellites managed in the GnssSatellite class are used in this model.
antenna_model = SIMPLE

// Antenna half width [deg]
antenna_half_width_deg = 60

// Number of channels
maximum_channel = 8
// Random noise for simple position observation
white_noise_standard_deviation_position_ecef_m(0) = 2000.0
white_noise_standard_deviation_position_ecef_m(1) = 1000.0
white_noise_standard_deviation_position_ecef_m(2) = 1500.0

// GNSS ID
// G...GPS
// R...GLONASS
// E...Galileo
// C...Beidou
// J...QZSS
// if your receiver is compatible with all kind of gnss satellites : GRECJ
// if your receiver is compatible with GPS and QZSS : GJ
gnss_id = G

//Random noise [m]
white_noise_standard_deviation_eci_m(0) = 10000.0
white_noise_standard_deviation_eci_m(1) = 1000.0
white_noise_standard_deviation_eci_m(2) = 1000.0
white_noise_standard_deviation_velocity_ecef_m_s(0) = 1.0
white_noise_standard_deviation_velocity_ecef_m_s(1) = 1.5
white_noise_standard_deviation_velocity_ecef_m_s(2) = 2.0

[POWER_PORT]
minimum_voltage_V = 3.3
Expand Down
20 changes: 10 additions & 10 deletions scripts/Plot/plot_gnss_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
# Read S2E CSV
time = read_scalar_from_csv(read_file_name, 'elapsed_time[s]')

measured_position_eci_m = read_3d_vector_from_csv(read_file_name, 'gnss_receiver1_measured_position_eci', 'm')
true_position_eci_m = read_3d_vector_from_csv(read_file_name, 'spacecraft_position_i', 'm')
measured_position_ecef_m = read_3d_vector_from_csv(read_file_name, 'gnss_receiver1_measured_position_ecef', 'm')
true_position_ecef_m = read_3d_vector_from_csv(read_file_name, 'spacecraft_position_ecef', 'm')

number_of_visible_satellites = read_scalar_from_csv(read_file_name, 'gnss_receiver1_number_of_visible_satellites')
satellite_visible_flag = read_scalar_from_csv(read_file_name, 'gnss_receiver1_satellite_visible_flag')

# Statistics
error_m = measured_position_eci_m[:, 1:] - true_position_eci_m[:, 1:]
error_m = measured_position_ecef_m[:, 1:] - true_position_ecef_m[:, 1:]
average = [0.0, 0.0, 0.0]
standard_deviation = [0.0, 0.0, 0.0]
for i in range(3):
Expand All @@ -68,20 +68,20 @@
#
unit = ' m'
fig, axis = plt.subplots(5, 1, squeeze = False, tight_layout = True, sharex = True)
axis[0, 0].plot(time[0], measured_position_eci_m[0], marker=".", c="red", label="MEASURED-X")
axis[0, 0].plot(time[0], true_position_eci_m[0], marker=".", c="orange", label="TRUE-X")
axis[0, 0].plot(time[0], measured_position_ecef_m[0], marker=".", c="red", label="MEASURED-X")
axis[0, 0].plot(time[0], true_position_ecef_m[0], marker=".", c="orange", label="TRUE-X")
axis[0, 0].text(0.01, 0.99, "Error average:" + format(average[0], '+.2e') + unit, verticalalignment = 'top', transform = axis[0, 0].transAxes)
axis[0, 0].text(0.01, 0.79, "Standard deviation:" + format(standard_deviation[0], '+.2e') + unit, verticalalignment = 'top', transform = axis[0, 0].transAxes)
axis[0, 0].legend(loc = 'upper right')

axis[1, 0].plot(time[0], measured_position_eci_m[1], marker=".", c="green", label="MEASURED-Y")
axis[1, 0].plot(time[0], true_position_eci_m[1], marker=".", c="yellow", label="TRUE-Y")
axis[1, 0].plot(time[0], measured_position_ecef_m[1], marker=".", c="green", label="MEASURED-Y")
axis[1, 0].plot(time[0], true_position_ecef_m[1], marker=".", c="yellow", label="TRUE-Y")
axis[1, 0].text(0.01, 0.99, "Error average:" + format(average[1], '+.2e') + unit, verticalalignment = 'top', transform = axis[1, 0].transAxes)
axis[1, 0].text(0.01, 0.79, "Standard deviation:" + format(standard_deviation[1], '+.2e') + unit, verticalalignment = 'top', transform = axis[1, 0].transAxes)
axis[1, 0].legend(loc = 'upper right')

axis[2, 0].plot(time[0], measured_position_eci_m[2], marker=".", c="blue", label="MEASURED-Z")
axis[2, 0].plot(time[0], true_position_eci_m[2], marker=".", c="purple", label="TRUE-Z")
axis[2, 0].plot(time[0], measured_position_ecef_m[2], marker=".", c="blue", label="MEASURED-Z")
axis[2, 0].plot(time[0], true_position_ecef_m[2], marker=".", c="purple", label="TRUE-Z")
axis[2, 0].text(0.01, 0.99, "Error average:" + format(average[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].text(0.01, 0.79, "Standard deviation:" + format(standard_deviation[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].legend(loc = 'upper right')
Expand All @@ -94,7 +94,7 @@
axis[4, 0].legend(loc = 'upper right')
axis[4, 0].set_ylim(0, max(number_of_visible_satellites[0]) + 2)

fig.suptitle("GNSS Receiver Spacecraft position @ ECI")
fig.suptitle("GNSS Receiver Spacecraft position @ ECEF")
fig.supylabel("Position [m]")
fig.supxlabel("Time [s]")

Expand Down
Loading

0 comments on commit ccc3b96

Please sign in to comment.