Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings in vs2022 #117

Merged
merged 15 commits into from
Apr 26, 2022
4 changes: 3 additions & 1 deletion ExtLibraries/nrlmsise00/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ endif()
add_library(${NRLMSISE_LIB} STATIC ${NRLMSISE_TMP_DIR}/nrlmsise-00.c ${NRLMSISE_TMP_DIR}/nrlmsise-00_data.c)

# build with 32bit
if(NOT MSVC)
if(MSVC)
target_compile_options(${NRLMSISE_LIB} PUBLIC "/MT")
else()
target_compile_options(${NRLMSISE_LIB} PUBLIC "-m32")
target_link_options(${NRLMSISE_LIB} PRIVATE "-m32")
endif()
Expand Down
1 change: 1 addition & 0 deletions common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# Compile option
if(MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "/W4")
target_compile_options(${PROJECT_NAME} PUBLIC "/MT")
target_compile_options(${PROJECT_NAME} PUBLIC "/source-charset:utf-8")
else()
target_compile_options(${PROJECT_NAME} PUBLIC "-Wall")
Expand Down
14 changes: 6 additions & 8 deletions src/Component/AOCS/InitSunSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
SunSensor InitSunSensor(ClockGenerator* clock_gen, int ss_id, std::string file_name, const SRPEnvironment* srp,
const LocalCelestialInformation* local_celes_info) {
IniAccess ss_conf(file_name);
const std::string st_ss_id = std::to_string(static_cast<long long>(ss_id));
const char* cs = st_ss_id.data();
char Section[30] = "SUNSENSOR";
strcat(Section, cs);
const char* sensor_name = "SUNSENSOR";
const std::string section_tmp = sensor_name + std::to_string(static_cast<long long>(ss_id));
const char* Section = section_tmp.c_str();

int prescaler = ss_conf.ReadInt(Section, "prescaler");
if (prescaler <= 1) prescaler = 1;
Expand Down Expand Up @@ -43,10 +42,9 @@ SunSensor InitSunSensor(ClockGenerator* clock_gen, int ss_id, std::string file_n
SunSensor InitSunSensor(ClockGenerator* clock_gen, PowerPort* power_port, int ss_id, std::string file_name, const SRPEnvironment* srp,
const LocalCelestialInformation* local_celes_info) {
IniAccess ss_conf(file_name);
const std::string st_ss_id = std::to_string(static_cast<long long>(ss_id));
const char* cs = st_ss_id.data();
char Section[30] = "SUNSENSOR";
strcat(Section, cs);
const char* sensor_name = "SUNSENSOR";
const std::string section_tmp = sensor_name + std::to_string(static_cast<long long>(ss_id));
const char* Section = section_tmp.c_str();

int prescaler = ss_conf.ReadInt(Section, "prescaler");
if (prescaler <= 1) prescaler = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/Component/AOCS/RWModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void RWModel::Initialize() {
output_torque_b_ = Vector<3>(0.0);
angular_momentum_b_ = Vector<3>(0.0);
target_accl_ = 0.0;
int len_buffer = floor(dead_time_ / dt_main_routine_) + 1;
int len_buffer = (int)floor(dead_time_ / dt_main_routine_) + 1;
delay_buffer_accl_.assign(len_buffer, 0.0);

angular_acceleration_ = 0.0;
Expand Down Expand Up @@ -126,7 +126,7 @@ Vector<3> RWModel::CalcTorque() {
delay_buffer_accl_.erase(delay_buffer_accl_.begin());
}
// Calc RW ODE
int itr_num = ceil(dt_main_routine_ / step_width_);
int itr_num = (int)ceil(dt_main_routine_ / step_width_);
for (int i = 0; i < itr_num; i++) {
++ode_angular_velocity_; // propagate()
}
Expand Down
10 changes: 10 additions & 0 deletions src/Dynamics/Attitude/InitAttitude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ Attitude* InitAttitude(std::string file_name, const Orbit* orbit, const LocalCel
attitude = new ControlledAttitude(main_mode, sub_mode, quaternion_i2b, pointing_t_b, pointing_sub_t_b, celes_info, orbit, mc_name);
} else {
std::cerr << "ERROR: attitude propagation mode: " << propagate_mode << " is not defined!" << std::endl;
std::cerr << "The attitude mode is automatically set as RK4" << std::endl;

Vector<3> omega_b;
ini_file.ReadVector(section_, "Omega_b", omega_b);
Quaternion quaternion_i2b;
ini_file.ReadQuaternion(section_, "Quaternion_i2b", quaternion_i2b);
Vector<3> torque_b;
ini_file.ReadVector(section_, "Torque_b", torque_b);

attitude = new AttitudeRK4(omega_b, quaternion_i2b, inertia_tensor, torque_b, step_sec, mc_name);
}

return attitude;
Expand Down
8 changes: 8 additions & 0 deletions src/Dynamics/Orbit/InitOrbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Orbit* InitOrbit(const CelestialInformation* celes_info, std::string ini_path, d
orbit = new EnckeOrbitPropagation(celes_info, gravity_constant, stepSec, current_jd, init_pos_m, init_vel_m_s, error_tolerance);
} else {
std::cerr << "ERROR: orbit propagation mode: " << propagate_mode << " is not defined!" << std::endl;
std::cerr << "The orbit mode is automatically set as RK4" << std::endl;

Vector<3> init_pos;
conf.ReadVector<3>(section_, "init_position", init_pos);
Vector<3> init_veloc;
conf.ReadVector<3>(section_, "init_velocity", init_veloc);

orbit = new Rk4OrbitPropagation(celes_info, gravity_constant, stepSec, init_pos, init_veloc);
}

orbit->SetIsCalcEnabled(conf.ReadEnable(section_, "calculation"));
Expand Down
2 changes: 1 addition & 1 deletion src/Environment/Global/ClockGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ class ClockGenerator {

private:
std::vector<ITickable*> components_;
unsigned long long timer_count_;
int timer_count_; // TODO consider size, unsigned
};
30 changes: 16 additions & 14 deletions src/Environment/Global/GnssSatellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ pair<double, double> GnssSat_position::Init(vector<vector<string>>& file, int in

// Get Header Info
for (int page = 0; page < (int)file.size(); ++page) {
int num_of_time_stamps, num_of_sat;

for (int line = 0; line < 3; ++line) {
int num_of_time_stamps = 0;
int num_of_sat = 0;
int line;
for (line = 0; line < 3; ++line) {
istringstream iss{file.at(page).at(line)};

if (line == 0) {
Expand All @@ -252,7 +253,7 @@ pair<double, double> GnssSat_position::Init(vector<vector<string>>& file, int in
}
}

int line = 3;
line = 3;
while (file.at(page).at(line).front() != '*') ++line;

int start_line, end_line;
Expand All @@ -266,9 +267,10 @@ pair<double, double> GnssSat_position::Init(vector<vector<string>>& file, int in
}

double unix_time = 0;
double cos_, sin_;
double cos_ = 0.0;
double sin_ = 0.0;
for (int i = 0; i < end_line - start_line; ++i) {
int line = i + start_line;
line = i + start_line;

istringstream iss{file.at(page).at(line)};
vector<string> s;
Expand Down Expand Up @@ -492,9 +494,10 @@ void GnssSat_clock::Init(vector<vector<string>>& file, string file_extension, in
if (file_extension == ".sp3") {
// Get Header Info
for (int page = 0; page < (int)file.size(); ++page) {
int num_of_time_stamps, num_of_sat;

for (int line = 0; line < 3; ++line) {
int num_of_time_stamps = 0;
int num_of_sat = 0;
int line;
for (line = 0; line < 3; ++line) {
istringstream iss{file.at(page).at(line)};

if (line == 0) {
Expand All @@ -521,7 +524,7 @@ void GnssSat_clock::Init(vector<vector<string>>& file, string file_extension, in
}
}

int line = 3;
line = 3;
while (file.at(page).at(line).front() != '*') ++line;

int start_line, end_line;
Expand All @@ -536,7 +539,7 @@ void GnssSat_clock::Init(vector<vector<string>>& file, string file_extension, in

double unix_time = 0;
for (int i = 0; i < end_line - start_line; ++i) {
int line = i + start_line;
line = i + start_line;

istringstream iss{file.at(page).at(line)};
vector<string> s;
Expand Down Expand Up @@ -785,11 +788,10 @@ void GnssSat_Info::Update(const double now_unix_time) {
}

int GnssSat_Info::GetNumOfSatellites() const {
if (position_.GetNumOfSatellites() == clock_.GetNumOfSatellites())
if (position_.GetNumOfSatellites() == clock_.GetNumOfSatellites()) {
return position_.GetNumOfSatellites();
else {
}else {
cout << "Num Of Gnss Satellites has something wrong" << endl;
exit(1);
return 0;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Environment/Global/GnssSatellites.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class GnssSat_coordinate {
std::vector<int> nearest_index_; // index list for update(in position,
// time_and_index_list_. in clock_bias, time_table_)

double step_sec_;
double time_interval_;
int interpolation_number_;
double step_sec_ = 0.0;
double time_interval_ = 0.0;
int interpolation_number_ = 0;
};

class GnssSat_position : public GnssSat_coordinate {
Expand Down
12 changes: 6 additions & 6 deletions src/Environment/Global/InitGnssSatellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void get_sp3_file_contents(std::string directory_path, std::string file_sort, st
} else if (file_sort.substr(0, 3) == "IGU" || file_sort.find("Ultra") != std::string::npos) { // URの場合
ur_flag = UR_UNKNOWN;
std::string file_header, file_footer;
int gps_week, day;
int hour;
int gps_week = 0, day = 0;
int hour = 0;
for (int i = 0; i < (int)first.size(); ++i) {
int n = first.at(i);
// Looking for the number of file name
Expand Down Expand Up @@ -138,7 +138,7 @@ void get_sp3_file_contents(std::string directory_path, std::string file_sort, st
}
} else {
std::string file_header, file_footer;
int gps_week, day;
int gps_week = 0, day = 0;
for (int i = 0; i < (int)first.size(); ++i) {
int n = first.at(i);
// Looking for the number of file name
Expand Down Expand Up @@ -177,8 +177,8 @@ void get_clk_file_contents(std::string directory_path, std::string extension, st

if (file_sort.find("Ultra") != std::string::npos) {
std::string file_header, file_footer;
int gps_week, day;
int hour;
int gps_week = 0, day = 0;
int hour = 0;
for (int i = 0; i < (int)first.size(); ++i) {
int n = first.at(i);
// Looking for the number of file name
Expand Down Expand Up @@ -217,7 +217,7 @@ void get_clk_file_contents(std::string directory_path, std::string extension, st
}
} else {
std::string file_header, file_footer;
int gps_week, day;
int gps_week = 0, day = 0;
for (int i = 0; i < (int)first.size(); ++i) {
int n = first.at(i);
// Looking for the number of file name
Expand Down
2 changes: 1 addition & 1 deletion src/Environment/Global/SimTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void SimTime::UpdateTime(void) {
}

if (disp_counter_ >= disp_period_) {
disp_counter_ -= disp_period_;
disp_counter_ -= (int)disp_period_;
state_.disp_output = true;
}

Expand Down
22 changes: 11 additions & 11 deletions src/Interface/InitInput/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## ini access
project(INI_ACC)
cmake_minimum_required(VERSION 3.13)

if(WIN32)
add_library(INI_ACC STATIC IniAccess.cpp)
add_library(${PROJECT_NAME} STATIC
IniAccess.cpp
)
else()
add_library(INI_ACC STATIC IniAccessUnix.cpp)
endif()
# Compile option
target_include_directories(INI_ACC PUBLIC ${S2E_DIR}/src)
if(MSVC)
target_compile_options(INI_ACC PUBLIC "/W4")
target_compile_options(INI_ACC PUBLIC "/source-charset:utf-8")
else()
target_compile_options(INI_ACC PUBLIC -Wall -g -m32 -rdynamic)
add_library(${PROJECT_NAME} STATIC
IniAccessUnix.cpp
)
endif()

include(../../../common.cmake)
12 changes: 6 additions & 6 deletions src/Interface/SpacecraftInOut/Ports/I2CPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ unsigned char I2CPort::ReadRegister(const unsigned char i2c_addr, const unsigned
return ret;
}

size_t I2CPort::WriteCommand(const unsigned char i2c_addr, const unsigned char* tx_data, const size_t length) {
unsigned char I2CPort::WriteCommand(const unsigned char i2c_addr, const unsigned char* tx_data, const unsigned char length) {
if (length > kDefaultCmdBufferSize) {
return -1;
return 0;
}
for (size_t i = 0; i < length; i++) {
for (unsigned char i = 0; i < length; i++) {
cmd_buffer_[std::make_pair(i2c_addr, i)] = tx_data[i];
}

Expand All @@ -80,11 +80,11 @@ size_t I2CPort::WriteCommand(const unsigned char i2c_addr, const unsigned char*
return length;
}

size_t I2CPort::ReadCommand(const unsigned char i2c_addr, unsigned char* rx_data, const size_t length) {
unsigned char I2CPort::ReadCommand(const unsigned char i2c_addr, unsigned char* rx_data, const unsigned char length) {
if (length > kDefaultCmdBufferSize) {
return -1;
return 0;
}
for (size_t i = 0; i < length; i++) {
for (unsigned char i = 0; i < length; i++) {
rx_data[i] = cmd_buffer_[std::make_pair(i2c_addr, i)];
}
return length;
Expand Down
5 changes: 2 additions & 3 deletions src/Interface/SpacecraftInOut/Ports/I2CPort.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <map>
#include <cstddef>

const int kDefaultCmdBufferSize = 0xff;

Expand All @@ -20,8 +19,8 @@ class I2CPort {
unsigned char ReadRegister(const unsigned char i2c_addr, const unsigned char reg_addr);

// OBC->Component Command emulation
size_t WriteCommand(const unsigned char i2c_addr, const unsigned char* tx_data, const size_t length);
size_t ReadCommand(const unsigned char i2c_addr, unsigned char* rx_data, const size_t length);
unsigned char WriteCommand(const unsigned char i2c_addr, const unsigned char* tx_data, const unsigned char length);
unsigned char ReadCommand(const unsigned char i2c_addr, unsigned char* rx_data, const unsigned char length);

private:
unsigned char max_register_number_ = 0xff;
Expand Down
8 changes: 3 additions & 5 deletions src/Library/igrf/igrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ void mfldc(double athe, double alon, double ar, double *ax, double *ay, double *
// GIGRFの計算(G,D,P-GRFの区別なく計算)
// WGS84モデルで計算
void gigrf(int gen, double year) {
int maxod, i, n, m, l, k, ncol, nlin;
double y1, y2, yr1, yr2;
double tzero, dmy[3], cb[MxELM], cv[MxELM];
int i, n, m, l, k, ncol, nlin;
double y1, y2, yr1 = 0.0, yr2 = 0.0;
double dmy[3], cb[MxELM], cv[MxELM];
//係数表指定
// char path[]="igrf10.coef";
// char file[]="igrf10.coef";
Expand Down Expand Up @@ -441,8 +441,6 @@ int TransMagaxisToECI(const double *mag, double *pos, double lonrad, double thet
void IgrfCalc(double decyear, double latrad, double lonrad, double alt, double side, double *mag) {
static bool first_flg = true;

double f;

if (first_flg == true) {
// gigrf(10,decyear); //ファイル読み込み
// gigrf(11, decyear);
Expand Down
4 changes: 2 additions & 2 deletions src/Library/inih/cpp/INIReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ double INIReader::GetReal(const string& section, const string& name, double defa
bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) const {
string valstr = Get(section, name, "");
// Convert to lower case to make string comparisons case-insensitive
std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower);
std::transform(valstr.begin(), valstr.end(), valstr.begin(), [](char c) { return std::tolower(c); });
if (valstr == "true" || valstr == "yes" || valstr == "on" || valstr == "1")
return true;
else if (valstr == "false" || valstr == "no" || valstr == "off" || valstr == "0")
Expand All @@ -85,7 +85,7 @@ bool INIReader::HasValue(const string& section, const string& name) const {
string INIReader::MakeKey(const string& section, const string& name) {
string key = section + "=" + name;
// Convert to lower case to make section/name lookups case-insensitive
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
std::transform(key.begin(), key.end(), key.begin(), [](char c) { return std::tolower(c); });
return key;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Library/math/MatVec_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Matrix<N, N>& ludcmp(Matrix<N, N>& a, unsigned int index[]) {
}

double biggest = 0.0;
size_t imax;
size_t imax = j;
for (size_t i = j; i < N; ++i) {
double sum = a[i][j];
for (size_t k = 0; k < j; ++k) {
Expand Down Expand Up @@ -111,7 +111,7 @@ template <std::size_t N>
Vector<N>& lubksb(const Matrix<N, N>& a, const unsigned int index[], Vector<N>& b) {
double sum;
bool non_zero = false;
unsigned int mark;
unsigned int mark = 0;
for (size_t i = 0; i < N; ++i) {
unsigned int ip = index[i];
sum = b[ip];
Expand Down
2 changes: 1 addition & 1 deletion src/Library/nrlmsise00/Wrapper_nrlmsise00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ double CalcNRLMSISE00(double decyear, double latrad, double lonrad, double alt,

ConvertDecyearToDate(decyear, date);

input.doy = (decyear - (int)decyear) * 365.25;
input.doy = (int)((decyear - (int)decyear) * 365.25);
input.year = 0; /* without effect */
input.sec = date[3] * 60.0 * 60.0 + date[4] * 60.0 + date[5];
input.alt = alt / 1000.0;
Expand Down
2 changes: 2 additions & 0 deletions src/Library/sgp4/sgp4unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,8 @@ int sgp4(gravconsttype whichconst, elsetrec& satrec, double tsince, double r[3],
eo1 = u;
tem5 = 9999.9;
ktr = 1;
sineo1 = sin(eo1);
coseo1 = cos(eo1);
// sgp4fix for kepler iteration
// the following iteration needs better limits on corrections
while ((fabs(tem5) >= 1.0e-12) && (ktr <= 10)) {
Expand Down
Loading