Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ut-issl/s2e-core into feature/ad…
Browse files Browse the repository at this point in the history
…d_relative_velocity_direction_pointing
  • Loading branch information
Hiro-0110 committed Mar 19, 2024
2 parents fab7c25 + ccc3b96 commit a0d516c
Show file tree
Hide file tree
Showing 17 changed files with 726 additions and 337 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ cmake_minimum_required(VERSION 3.13)
project(S2E
LANGUAGES CXX
DESCRIPTION "S2E: Spacecraft Simulation Environment"
VERSION 7.2.4
VERSION 7.2.5
)

# build config
option(USE_HILS "Use HILS" OFF)
option(USE_C2A "Use C2A" OFF)
option(USE_C2A_COMMAND_SENDER "Use command sender to C2A" OFF)
option(BUILD_64BIT "Build 64bit" OFF)
option(GOOGLE_TEST "Execute GoogleTest" OFF)

Expand Down
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
19 changes: 19 additions & 0 deletions data/sample/initialize_files/components/orbit_observer.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[ORBIT_OBSERVER]
// Noise definition frame
// INERTIAL: Inertial frame
// RTN: RTN frame
noise_frame = INERTIAL

// Standard deviation of position and velocity noise [m, m/s]
// The frame definition can be selected above
noise_standard_deviation(0) = 1000 // Position-X
noise_standard_deviation(1) = 2000 // Position-Y
noise_standard_deviation(2) = 3000 // Position-Z
noise_standard_deviation(3) = 30 // Velocity-X
noise_standard_deviation(4) = 20 // Velocity-Y
noise_standard_deviation(5) = 10 // Velocity-Z


[COMPONENT_BASE]
// Prescaler with respect to the component update period
prescaler = 1
1 change: 1 addition & 0 deletions data/sample/initialize_files/sample_satellite.ini
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ force_generator_file = INI_FILE_DIR_FROM_EXE/components/force_generator.ini
torque_generator_file = INI_FILE_DIR_FROM_EXE/components/torque_generator.ini
angular_velocity_observer_file = INI_FILE_DIR_FROM_EXE/components/angular_velocity_observer.ini
attitude_observer_file = INI_FILE_DIR_FROM_EXE/components/attitude_observer.ini
orbit_observer_file = INI_FILE_DIR_FROM_EXE/components/orbit_observer.ini
antenna_file = INI_FILE_DIR_FROM_EXE/components/spacecraft_antenna.ini
component_interference_file = INI_FILE_DIR_FROM_EXE/components/component_interference.ini
telescope_file = INI_FILE_DIR_FROM_EXE/components/telescope.ini
2 changes: 1 addition & 1 deletion scripts/Plot/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ matplotlib = "==3.7.2"
numpy = "==1.24.3"
pandas = "==2.0.3"
numpy-stl = "==3.0.1"
numpy-quaternion = "==2023.0.2"
numpy-quaternion = "==2023.0.3"
python-utils = "==3.5.2"

[dev-packages]
Expand Down
208 changes: 108 additions & 100 deletions scripts/Plot/Pipfile.lock

Large diffs are not rendered by default.

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
126 changes: 126 additions & 0 deletions scripts/Plot/plot_orbit_observer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#
# Plot orbit observer
#
# arg[1] : read_file_tag : time tag for default CSV output log file. ex. 220627_142946
#

#
# Import
#
# plots
import matplotlib.pyplot as plt
# numpy
import numpy as np
# local function
from common import find_latest_log_tag
from common import add_log_file_arguments
from common import read_3d_vector_from_csv
from common import read_scalar_from_csv
# arguments
import argparse

# Arguments
aparser = argparse.ArgumentParser()
aparser = add_log_file_arguments(aparser)
aparser.add_argument('--no-gui', action='store_true')
args = aparser.parse_args()

#
# Read Arguments
#
# log file path
path_to_logs = args.logs_dir

read_file_tag = args.file_tag
if read_file_tag == None:
print("file tag does not found. use latest.")
read_file_tag = find_latest_log_tag(path_to_logs)

print("log: " + read_file_tag)

#
# CSV file name
#
read_file_name = path_to_logs + '/' + 'logs_' + read_file_tag + '/' + read_file_tag + '_default.csv'

#
# Data read and edit
#
# 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, 'orbit_observer_position_i', 'm')
true_position_eci_m = read_3d_vector_from_csv(read_file_name, 'spacecraft_position_i', 'm')

measured_velocity_eci_m_s = read_3d_vector_from_csv(read_file_name, 'orbit_observer_velocity_i', 'm/s')
true_velocity_eci_m_s = read_3d_vector_from_csv(read_file_name, 'spacecraft_velocity_i', 'm/s')

# Statistics
position_error_m = measured_position_eci_m[:, 1:] - true_position_eci_m[:, 1:]
position_average = [0.0, 0.0, 0.0]
position_standard_deviation = [0.0, 0.0, 0.0]
velocity_error_m = measured_velocity_eci_m_s[:, 1:] - true_velocity_eci_m_s[:, 1:]
velocity_average = [0.0, 0.0, 0.0]
velocity_standard_deviation = [0.0, 0.0, 0.0]
for i in range(3):
position_average[i] = position_error_m[i].mean()
position_standard_deviation[i] = position_error_m[i].std()
velocity_average[i] = velocity_error_m[i].mean()
velocity_standard_deviation[i] = velocity_error_m[i].std()

#
# Plot
#
unit = ' m'
fig, axis = plt.subplots(3, 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].text(0.01, 0.99, "Error average:" + format(position_average[0], '+.2e') + unit, verticalalignment = 'top', transform = axis[0, 0].transAxes)
axis[0, 0].text(0.01, 0.79, "Standard deviation:" + format(position_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].text(0.01, 0.99, "Error average:" + format(position_average[1], '+.2e') + unit, verticalalignment = 'top', transform = axis[1, 0].transAxes)
axis[1, 0].text(0.01, 0.79, "Standard deviation:" + format(position_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].text(0.01, 0.99, "Error average:" + format(position_average[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].text(0.01, 0.79, "Standard deviation:" + format(position_standard_deviation[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].legend(loc = 'upper right')

fig.suptitle("Orbit observer position results @ ECI")
fig.supylabel("Position [m]")
fig.supxlabel("Time [s]")

unit = ' m/s'
fig, axis = plt.subplots(3, 1, squeeze = False, tight_layout = True, sharex = True)
axis[0, 0].plot(time[0], measured_velocity_eci_m_s[0], marker=".", c="red", label="MEASURED-X")
axis[0, 0].plot(time[0], true_velocity_eci_m_s[0], marker=".", c="orange", label="TRUE-X")
axis[0, 0].text(0.01, 0.99, "Error average:" + format(velocity_average[0], '+.2e') + unit, verticalalignment = 'top', transform = axis[0, 0].transAxes)
axis[0, 0].text(0.01, 0.79, "Standard deviation:" + format(velocity_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_velocity_eci_m_s[1], marker=".", c="green", label="MEASURED-Y")
axis[1, 0].plot(time[0], true_velocity_eci_m_s[1], marker=".", c="yellow", label="TRUE-Y")
axis[1, 0].text(0.01, 0.99, "Error average:" + format(velocity_average[1], '+.2e') + unit, verticalalignment = 'top', transform = axis[1, 0].transAxes)
axis[1, 0].text(0.01, 0.79, "Standard deviation:" + format(velocity_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_velocity_eci_m_s[2], marker=".", c="blue", label="MEASURED-Z")
axis[2, 0].plot(time[0], true_velocity_eci_m_s[2], marker=".", c="purple", label="TRUE-Z")
axis[2, 0].text(0.01, 0.99, "Error average:" + format(velocity_average[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].text(0.01, 0.79, "Standard deviation:" + format(velocity_standard_deviation[2], '+.2e') + unit, verticalalignment = 'top', transform = axis[2, 0].transAxes)
axis[2, 0].legend(loc = 'upper right')

fig.suptitle("Orbit observer velocity results @ ECI")
fig.supylabel("Velocity [m/s]")
fig.supxlabel("Time [s]")

# Data save
if args.no_gui:
plt.savefig(read_file_tag + "_orbit_observer.png") # save last figure only
else:
plt.show()
9 changes: 8 additions & 1 deletion src/components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ real/cdh/on_board_computer_with_c2a.cpp
real/communication/antenna.cpp
real/communication/antenna_radiation_pattern.cpp
real/communication/ground_station_calculator.cpp
real/communication/wings_command_sender_to_c2a.cpp

examples/example_change_structure.cpp
examples/example_serial_communication_with_obc.cpp
Expand All @@ -37,6 +36,7 @@ ideal/force_generator.cpp
ideal/torque_generator.cpp
ideal/angular_velocity_observer.cpp
ideal/attitude_observer.cpp
ideal/orbit_observer.cpp

real/mission/telescope.cpp

Expand All @@ -62,6 +62,13 @@ if(USE_HILS)
)
endif()

if(USE_C2A_COMMAND_SENDER)
set(SOURCE_FILES
${SOURCE_FILES}
real/communication/wings_command_sender.cpp
)
endif()

add_library(${PROJECT_NAME} STATIC
${SOURCE_FILES}
)
Expand Down
Loading

0 comments on commit a0d516c

Please sign in to comment.