Skip to content

Commit

Permalink
Merge pull request #505 from ut-issl/feature/remove-warnings
Browse files Browse the repository at this point in the history
Remove warnings
  • Loading branch information
200km authored Oct 5, 2023
2 parents 9c21a16 + 584a2d8 commit 3f2edb9
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 92 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.13)

project(S2E
LANGUAGES CXX
DESCRIPTION "S2E: Spacecraft Simulation Environment"
VERSION 6.4.0
)

cmake_minimum_required(VERSION 3.13)

# build config
option(USE_HILS "Use HILS" OFF)
option(USE_C2A "Use C2A" OFF)
Expand Down
63 changes: 29 additions & 34 deletions src/components/real/communication/antenna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "antenna.hpp"

#define _CRT_SECURE_NO_WARNINGS
#include <string.h>

#include <cmath>
Expand Down Expand Up @@ -109,35 +108,31 @@ AntennaGainModel SetAntennaGainModel(const std::string gain_model_name) {
Antenna InitAntenna(const int antenna_id, const std::string file_name) {
IniAccess antenna_conf(file_name);

const std::string st_antenna_id = std::to_string(static_cast<long long>(antenna_id));
const char* cs = st_antenna_id.data();

char Section[30] = "ANTENNA_";
strcat(Section, cs);
const std::string section_name = "ANTENNA_" + std::to_string(static_cast<long long>(antenna_id));

Quaternion quaternion_b2c;
antenna_conf.ReadQuaternion(Section, "quaternion_b2c", quaternion_b2c);
antenna_conf.ReadQuaternion(section_name.c_str(), "quaternion_b2c", quaternion_b2c);

bool is_transmitter = antenna_conf.ReadBoolean(Section, "is_transmitter");
bool is_receiver = antenna_conf.ReadBoolean(Section, "is_receiver");
double frequency_MHz = antenna_conf.ReadDouble(Section, "frequency_MHz");
bool is_transmitter = antenna_conf.ReadBoolean(section_name.c_str(), "is_transmitter");
bool is_receiver = antenna_conf.ReadBoolean(section_name.c_str(), "is_receiver");
double frequency_MHz = antenna_conf.ReadDouble(section_name.c_str(), "frequency_MHz");

double tx_bitrate_bps = antenna_conf.ReadDouble(Section, "tx_bitrate_bps");
double tx_output_power_W = antenna_conf.ReadDouble(Section, "tx_output_W");
double rx_system_noise_temperature_K = antenna_conf.ReadDouble(Section, "rx_system_noise_temperature_K");
double tx_bitrate_bps = antenna_conf.ReadDouble(section_name.c_str(), "tx_bitrate_bps");
double tx_output_power_W = antenna_conf.ReadDouble(section_name.c_str(), "tx_output_W");
double rx_system_noise_temperature_K = antenna_conf.ReadDouble(section_name.c_str(), "rx_system_noise_temperature_K");

AntennaParameters tx_parameters;
if (is_transmitter) {
tx_parameters.gain_dBi_ = antenna_conf.ReadDouble(Section, "tx_gain_dBi");
tx_parameters.loss_feeder_dB_ = antenna_conf.ReadDouble(Section, "tx_loss_feeder_dB");
tx_parameters.loss_pointing_dB_ = antenna_conf.ReadDouble(Section, "tx_loss_pointing_dB");
tx_parameters.antenna_gain_model = SetAntennaGainModel(antenna_conf.ReadString(Section, "tx_antenna_gain_model"));
size_t length_theta = antenna_conf.ReadInt(Section, "tx_length_theta");
size_t length_phi = antenna_conf.ReadInt(Section, "tx_length_phi");
double theta_max_rad = antenna_conf.ReadDouble(Section, "tx_theta_max_rad");
double phi_max_rad = antenna_conf.ReadDouble(Section, "tx_phi_max_rad");
tx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(Section, "tx_antenna_radiation_pattern_file"), length_theta,
length_phi, theta_max_rad, phi_max_rad);
tx_parameters.gain_dBi_ = antenna_conf.ReadDouble(section_name.c_str(), "tx_gain_dBi");
tx_parameters.loss_feeder_dB_ = antenna_conf.ReadDouble(section_name.c_str(), "tx_loss_feeder_dB");
tx_parameters.loss_pointing_dB_ = antenna_conf.ReadDouble(section_name.c_str(), "tx_loss_pointing_dB");
tx_parameters.antenna_gain_model = SetAntennaGainModel(antenna_conf.ReadString(section_name.c_str(), "tx_antenna_gain_model"));
size_t length_theta = antenna_conf.ReadInt(section_name.c_str(), "tx_length_theta");
size_t length_phi = antenna_conf.ReadInt(section_name.c_str(), "tx_length_phi");
double theta_max_rad = antenna_conf.ReadDouble(section_name.c_str(), "tx_theta_max_rad");
double phi_max_rad = antenna_conf.ReadDouble(section_name.c_str(), "tx_phi_max_rad");
tx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(section_name.c_str(), "tx_antenna_radiation_pattern_file"),
length_theta, length_phi, theta_max_rad, phi_max_rad);
} else {
tx_parameters.gain_dBi_ = 0.0;
tx_parameters.loss_feeder_dB_ = 0.0;
Expand All @@ -147,17 +142,17 @@ Antenna InitAntenna(const int antenna_id, const std::string file_name) {

AntennaParameters rx_parameters;
if (is_receiver) {
rx_parameters.gain_dBi_ = antenna_conf.ReadDouble(Section, "rx_gain_dBi");
rx_parameters.loss_feeder_dB_ = antenna_conf.ReadDouble(Section, "rx_loss_feeder_dB");
rx_parameters.loss_pointing_dB_ = antenna_conf.ReadDouble(Section, "rx_loss_pointing_dB");
rx_parameters.antenna_gain_model = SetAntennaGainModel(antenna_conf.ReadString(Section, "rx_antenna_gain_model"));
rx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(Section, "rx_antenna_radiation_pattern_file"));
size_t length_theta = antenna_conf.ReadInt(Section, "rx_length_theta");
size_t length_phi = antenna_conf.ReadInt(Section, "rx_length_phi");
double theta_max_rad = antenna_conf.ReadDouble(Section, "rx_theta_max_rad");
double phi_max_rad = antenna_conf.ReadDouble(Section, "rx_phi_max_rad");
rx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(Section, "rx_antenna_radiation_pattern_file"), length_theta,
length_phi, theta_max_rad, phi_max_rad);
rx_parameters.gain_dBi_ = antenna_conf.ReadDouble(section_name.c_str(), "rx_gain_dBi");
rx_parameters.loss_feeder_dB_ = antenna_conf.ReadDouble(section_name.c_str(), "rx_loss_feeder_dB");
rx_parameters.loss_pointing_dB_ = antenna_conf.ReadDouble(section_name.c_str(), "rx_loss_pointing_dB");
rx_parameters.antenna_gain_model = SetAntennaGainModel(antenna_conf.ReadString(section_name.c_str(), "rx_antenna_gain_model"));
rx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(section_name.c_str(), "rx_antenna_radiation_pattern_file"));
size_t length_theta = antenna_conf.ReadInt(section_name.c_str(), "rx_length_theta");
size_t length_phi = antenna_conf.ReadInt(section_name.c_str(), "rx_length_phi");
double theta_max_rad = antenna_conf.ReadDouble(section_name.c_str(), "rx_theta_max_rad");
double phi_max_rad = antenna_conf.ReadDouble(section_name.c_str(), "rx_phi_max_rad");
rx_parameters.radiation_pattern = AntennaRadiationPattern(antenna_conf.ReadString(section_name.c_str(), "rx_antenna_radiation_pattern_file"),
length_theta, length_phi, theta_max_rad, phi_max_rad);
} else {
rx_parameters.gain_dBi_ = 0.0;
rx_parameters.loss_feeder_dB_ = 0.0;
Expand Down
30 changes: 13 additions & 17 deletions src/components/real/power/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ void Battery::MainRoutine(const int time_count) {
}

void Battery::UpdateBatVoltage() {
double cell_discharge_capasity = depth_of_discharge_percent_ / 100.0 * cell_capacity_Ah_;
double cell_discharge_capacity = depth_of_discharge_percent_ / 100.0 * cell_capacity_Ah_;
double temp = 0.0;
int index = 0;
for (auto coeff : cell_discharge_curve_coefficients_) {
temp += coeff * std::pow(cell_discharge_capasity, index);
temp += coeff * std::pow(cell_discharge_capacity, index);
++index;
}
battery_voltage_V_ = temp * number_of_series_;
Expand All @@ -90,44 +90,40 @@ void Battery::UpdateBatVoltage() {
Battery InitBAT(ClockGenerator* clock_generator, int bat_id, const std::string file_name, double component_step_time_s) {
IniAccess bat_conf(file_name);

const std::string st_bat_id = std::to_string(bat_id);
const char* cs = st_bat_id.data();
const std::string section_name = "BATTERY_" + std::to_string(static_cast<long long>(bat_id));

char Section[30] = "BATTERY_";
strcat(Section, cs);

int prescaler = bat_conf.ReadInt(Section, "prescaler");
int prescaler = bat_conf.ReadInt(section_name.c_str(), "prescaler");
if (prescaler <= 1) prescaler = 1;

int number_of_series;
number_of_series = bat_conf.ReadInt(Section, "number_of_series");
number_of_series = bat_conf.ReadInt(section_name.c_str(), "number_of_series");

int number_of_parallel;
number_of_parallel = bat_conf.ReadInt(Section, "number_of_parallel");
number_of_parallel = bat_conf.ReadInt(section_name.c_str(), "number_of_parallel");

double cell_capacity_Ah;
cell_capacity_Ah = bat_conf.ReadDouble(Section, "cell_capacity_Ah");
cell_capacity_Ah = bat_conf.ReadDouble(section_name.c_str(), "cell_capacity_Ah");

int approx_order;
approx_order = bat_conf.ReadInt(Section, "approximation_order");
approx_order = bat_conf.ReadInt(section_name.c_str(), "approximation_order");

std::vector<double> cell_discharge_curve_coefficients;
for (int i = 0; i <= approx_order; ++i) {
cell_discharge_curve_coefficients.push_back(
bat_conf.ReadDouble(Section, ("cell_discharge_curve_coefficients(" + std::to_string(i) + ")").c_str()));
bat_conf.ReadDouble(section_name.c_str(), ("cell_discharge_curve_coefficients(" + std::to_string(i) + ")").c_str()));
}

double initial_dod;
initial_dod = bat_conf.ReadDouble(Section, "initial_dod");
initial_dod = bat_conf.ReadDouble(section_name.c_str(), "initial_dod");

double cc_charge_c_rate;
cc_charge_c_rate = bat_conf.ReadDouble(Section, "constant_charge_current_A_rate_C");
cc_charge_c_rate = bat_conf.ReadDouble(section_name.c_str(), "constant_charge_current_A_rate_C");

double cv_charge_voltage_V;
cv_charge_voltage_V = bat_conf.ReadDouble(Section, "constant_voltage_charge_voltage_V");
cv_charge_voltage_V = bat_conf.ReadDouble(section_name.c_str(), "constant_voltage_charge_voltage_V");

double battery_resistance_Ohm;
battery_resistance_Ohm = bat_conf.ReadDouble(Section, "battery_resistance_Ohm");
battery_resistance_Ohm = bat_conf.ReadDouble(section_name.c_str(), "battery_resistance_Ohm");

Battery battery(prescaler, clock_generator, number_of_series, number_of_parallel, cell_capacity_Ah, cell_discharge_curve_coefficients, initial_dod,
cc_charge_c_rate, cv_charge_voltage_V, battery_resistance_Ohm, component_step_time_s);
Expand Down
8 changes: 2 additions & 6 deletions src/components/real/power/pcu_initial_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ PcuInitialStudy InitPCU_InitialStudy(ClockGenerator* clock_generator, int pcu_id
const std::vector<SolarArrayPanel*> saps, Battery* battery, double component_step_time_s) {
IniAccess pcu_conf(file_name);

const std::string st_pcu_id = std::to_string(pcu_id);
const char* cs = st_pcu_id.data();
const std::string section_name = "PCU_INITIAL_STUDY_" + std::to_string(static_cast<long long>(pcu_id));

char Section[30] = "PCU_INITIAL_STUDY_";
strcat(Section, cs);

int prescaler = pcu_conf.ReadInt(Section, "prescaler");
int prescaler = pcu_conf.ReadInt(section_name.c_str(), "prescaler");
if (prescaler <= 1) prescaler = 1;

PcuInitialStudy pcu(prescaler, clock_generator, saps, battery, component_step_time_s);
Expand Down
40 changes: 16 additions & 24 deletions src/components/real/power/solar_array_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,28 @@ SolarArrayPanel InitSAP(ClockGenerator* clock_generator, int sap_id, const std::
double component_step_time_s) {
IniAccess sap_conf(file_name);

const std::string st_sap_id = std::to_string(sap_id);
const char* cs = st_sap_id.data();
const std::string section_name = "SOLAR_ARRAY_PANEL_" + std::to_string(static_cast<long long>(sap_id));

char Section[30] = "SOLAR_ARRAY_PANEL_";
strcat(Section, cs);

int prescaler = sap_conf.ReadInt(Section, "prescaler");
int prescaler = sap_conf.ReadInt(section_name.c_str(), "prescaler");
if (prescaler <= 1) prescaler = 1;

int number_of_series;
number_of_series = sap_conf.ReadInt(Section, "number_of_series");
number_of_series = sap_conf.ReadInt(section_name.c_str(), "number_of_series");

int number_of_parallel;
number_of_parallel = sap_conf.ReadInt(Section, "number_of_parallel");
number_of_parallel = sap_conf.ReadInt(section_name.c_str(), "number_of_parallel");

double cell_area_m2;
cell_area_m2 = sap_conf.ReadDouble(Section, "cell_area_m2");
cell_area_m2 = sap_conf.ReadDouble(section_name.c_str(), "cell_area_m2");

libra::Vector<3> normal_vector;
sap_conf.ReadVector(Section, "normal_vector_b", normal_vector);
sap_conf.ReadVector(section_name.c_str(), "normal_vector_b", normal_vector);

double cell_efficiency;
cell_efficiency = sap_conf.ReadDouble(Section, "cell_efficiency");
cell_efficiency = sap_conf.ReadDouble(section_name.c_str(), "cell_efficiency");

double transmission_efficiency;
transmission_efficiency = sap_conf.ReadDouble(Section, "transmission_efficiency");
transmission_efficiency = sap_conf.ReadDouble(section_name.c_str(), "transmission_efficiency");

SolarArrayPanel sap(prescaler, clock_generator, sap_id, number_of_series, number_of_parallel, cell_area_m2, normal_vector, cell_efficiency,
transmission_efficiency, srp_environment, local_celestial_information, component_step_time_s);
Expand All @@ -156,32 +152,28 @@ SolarArrayPanel InitSAP(ClockGenerator* clock_generator, int sap_id, const std::
const SolarRadiationPressureEnvironment* srp_environment, double component_step_time_s) {
IniAccess sap_conf(file_name);

const std::string st_sap_id = std::to_string(sap_id);
const char* cs = st_sap_id.data();

char Section[30] = "SOLAR_ARRAY_PANEL_";
strcat(Section, cs);
const std::string section_name = "SOLAR_ARRAY_PANEL_" + std::to_string(static_cast<long long>(sap_id));

int prescaler = sap_conf.ReadInt(Section, "prescaler");
int prescaler = sap_conf.ReadInt(section_name.c_str(), "prescaler");
if (prescaler <= 1) prescaler = 1;

int number_of_series;
number_of_series = sap_conf.ReadInt(Section, "number_of_series");
number_of_series = sap_conf.ReadInt(section_name.c_str(), "number_of_series");

int number_of_parallel;
number_of_parallel = sap_conf.ReadInt(Section, "number_of_parallel");
number_of_parallel = sap_conf.ReadInt(section_name.c_str(), "number_of_parallel");

double cell_area_m2;
cell_area_m2 = sap_conf.ReadDouble(Section, "cell_area_m2");
cell_area_m2 = sap_conf.ReadDouble(section_name.c_str(), "cell_area_m2");

libra::Vector<3> normal_vector;
sap_conf.ReadVector(Section, "normal_vector_b", normal_vector);
sap_conf.ReadVector(section_name.c_str(), "normal_vector_b", normal_vector);

double cell_efficiency;
cell_efficiency = sap_conf.ReadDouble(Section, "cell_efficiency");
cell_efficiency = sap_conf.ReadDouble(section_name.c_str(), "cell_efficiency");

double transmission_efficiency;
transmission_efficiency = sap_conf.ReadDouble(Section, "transmission_efficiency");
transmission_efficiency = sap_conf.ReadDouble(section_name.c_str(), "transmission_efficiency");

SolarArrayPanel sap(prescaler, clock_generator, sap_id, number_of_series, number_of_parallel, cell_area_m2, normal_vector, cell_efficiency,
transmission_efficiency, srp_environment, component_step_time_s);
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/thermal/heater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace std;

Heater::Heater(const unsigned int heater_id, const double power_rating_W) : heater_id_(heater_id), power_rating_W_(power_rating_W) {
Heater::Heater(const size_t heater_id, const double power_rating_W) : heater_id_(heater_id), power_rating_W_(power_rating_W) {
AssertHeaterParams();
heater_status_ = HeaterStatus::kOff;
power_output_W_ = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/dynamics/thermal/heater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Heater {
* @param [in] heater_id
* @param [in] power_rating_W: Power Rating (100% Duty Output) of Heater [W]
*/
Heater(const unsigned int heater_id, const double power_rating_W);
Heater(const size_t heater_id, const double power_rating_W);
/**
* @fn ~Heater
* @brief Destroy the Heater object
Expand All @@ -46,7 +46,7 @@ class Heater {
* @fn GetHeaterID
* @brief Return Heater Id
*/
inline int GetHeaterId(void) const { return heater_id_; }
inline size_t GetHeaterId(void) const { return heater_id_; }
/**
* @fn GetPowerRating_W
* @brief Return power rating [W]
Expand Down Expand Up @@ -78,8 +78,8 @@ class Heater {
void PrintParam(void);

protected:
unsigned int heater_id_; // heater id (Use values over 1)
double power_rating_W_; // Power Rating (100% Duty) [W]
size_t heater_id_; // heater id (Use values over 1)
double power_rating_W_; // Power Rating (100% Duty) [W]

HeaterStatus heater_status_; // Power Status of Heater
double power_output_W_; // Power Output of Heater [W]
Expand Down
8 changes: 4 additions & 4 deletions src/environment/global/gnss_satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ void GnssSat_position::SetUp(const double start_unix_time, const double step_sec
continue;
}

int index = lower_bound(unixtime_vector_.at(gnss_satellite_id).begin(), unixtime_vector_.at(gnss_satellite_id).end(), start_unix_time) -
unixtime_vector_.at(gnss_satellite_id).begin();
int index = (int)(lower_bound(unixtime_vector_.at(gnss_satellite_id).begin(), unixtime_vector_.at(gnss_satellite_id).end(), start_unix_time) -
unixtime_vector_.at(gnss_satellite_id).begin());
if (index == (int)unixtime_vector_.at(gnss_satellite_id).size()) {
nearest_index_.at(gnss_satellite_id) = index;
validate_.at(gnss_satellite_id) = false;
Expand Down Expand Up @@ -673,8 +673,8 @@ void GnssSat_clock::SetUp(const double start_unix_time, const double step_sec) {
continue;
}

int index = lower_bound(unixtime_vector_.at(gnss_satellite_id).begin(), unixtime_vector_.at(gnss_satellite_id).end(), start_unix_time) -
unixtime_vector_.at(gnss_satellite_id).begin();
int index = (int)(lower_bound(unixtime_vector_.at(gnss_satellite_id).begin(), unixtime_vector_.at(gnss_satellite_id).end(), start_unix_time) -
unixtime_vector_.at(gnss_satellite_id).begin());
if (index == (int)unixtime_vector_.at(gnss_satellite_id).size()) {
validate_.at(gnss_satellite_id) = false;
nearest_index_.at(gnss_satellite_id) = index;
Expand Down

0 comments on commit 3f2edb9

Please sign in to comment.