Skip to content

Commit

Permalink
Update for v8
Browse files Browse the repository at this point in the history
  • Loading branch information
200km committed Oct 5, 2024
1 parent 460b2c9 commit a04cef5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ This repository provides the following samples.

## How to use this branch

- This branch is a sample code for [How To Make New Simulation Scenario](https://github.com/ut-issl/s2e-documents/blob/develop/Tutorials/HowToMakeNewSimulationScenario.md) in the `s2e-documents`.
- This branch is a sample code for [How To Add Components](https://github.com/ut-issl/s2e-documents/blob/develop/Tutorials/HowToAddComponents.md) in the `s2e-documents`.
- Please follow the tutorial to learn how to use the sample code.
1 change: 1 addition & 0 deletions settings/user_satellite/satellite.ini
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ structure_file = SETTINGS_DIR_FROM_EXE/user_satellite/structure.ini

[COMPONENT_FILES]
// Users can add the path for component initialize files here.
gyro_file = SETTINGS_DIR_FROM_EXE/user_satellite/components/gyro_sensor_xxx.ini
26 changes: 15 additions & 11 deletions src/simulation/spacecraft/user_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,34 @@
#include <utilities/macros.hpp>

UserComponents::UserComponents(const s2e::dynamics::Dynamics *dynamics, s2e::spacecraft::Structure *structure,
const s2e::environment::LocalEnvironment *local_environment, const s2e::environment::GlobalEnvironment *global_environment,
const s2e::simulation::SimulationConfiguration *configuration, s2e::environment::ClockGenerator *clock_generator,
const unsigned int spacecraft_id)
const s2e::environment::LocalEnvironment *local_environment,
const s2e::environment::GlobalEnvironment *global_environment,
const s2e::simulation::SimulationConfiguration *configuration, s2e::environment::ClockGenerator *clock_generator,
const unsigned int spacecraft_id)
: configuration_(configuration),
dynamics_(dynamics),
structure_(structure),
local_environment_(local_environment),
global_environment_(global_environment) {
// These variables are unused because this is a sample code.
UNUSED(spacecraft_id);
UNUSED(configuration_);
UNUSED(dynamics_);
UNUSED(structure_);
UNUSED(local_environment_);
UNUSED(global_environment_);

// Component instances
obc_ = new s2e::components::OnBoardComputer(clock_generator);

// Common
s2e::setting_file_reader::IniAccess iniAccess = s2e::setting_file_reader::IniAccess(configuration_->spacecraft_file_list_[spacecraft_id]);
const double compo_step_sec = global_environment_->GetSimulationTime().GetComponentStepTime_s();

// Initialize of GYRO class
std::string file_name = iniAccess.ReadString("COMPONENT_FILES", "gyro_file");
configuration_->main_logger_->CopyFileToLogDirectory(file_name);
gyro_sensor_ = new s2e::components::GyroSensor(s2e::components::InitGyroSensor(clock_generator, 1, file_name, compo_step_sec, dynamics_));
}

UserComponents::~UserComponents() {
delete gyro_sensor_;
// OBC must be deleted the last since it has com ports
delete obc_;
}
Expand All @@ -46,7 +53,4 @@ s2e::math::Vector<3> UserComponents::GenerateTorque_b_Nm() {
return torque_b_Nm;
}

void UserComponents::LogSetup(s2e::logger::Logger &logger) {
// Users can set log output when they need component log
UNUSED(logger);
}
void UserComponents::LogSetup(s2e::logger::Logger &logger) { logger.AddLogList(gyro_sensor_); }
3 changes: 2 additions & 1 deletion src/simulation/spacecraft/user_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <simulation/spacecraft/installed_components.hpp>

// include for components
#include <components/real/aocs/gyro_sensor.hpp>
#include <components/real/cdh/on_board_computer.hpp>

class UserComponents : public s2e::spacecraft::InstalledComponents {
Expand All @@ -29,7 +30,7 @@ class UserComponents : public s2e::spacecraft::InstalledComponents {
private:
// Components
s2e::components::OnBoardComputer *obc_; //!< Onboard Computer

s2e::components::GyroSensor *gyro_sensor_; //!< Gyro sensor
// States
const s2e::simulation::SimulationConfiguration *configuration_; //!< Simulation settings
const s2e::dynamics::Dynamics *dynamics_; //!< Dynamics information of the spacecraft
Expand Down

0 comments on commit a04cef5

Please sign in to comment.