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

Spacecraft_quaternion_i2b の値が怪しい #86

Closed
2 tasks
TomokiMochizuki opened this issue Jan 19, 2024 · 12 comments
Closed
2 tasks

Spacecraft_quaternion_i2b の値が怪しい #86

TomokiMochizuki opened this issue Jan 19, 2024 · 12 comments
Labels
bug Something isn't working priority::high priorityg high S2E

Comments

@TomokiMochizuki
Copy link
Member

TomokiMochizuki commented Jan 19, 2024

概要

spacecraft_quaternion_i2b の値が怪しい

詳細

詳細症状

  • S2E-FFにてATTITUDEのpropagate_modeRK4する場合や、propagate_modeCONTROLLED (main_mode = INERTIAL_STABILIZE)にしてinitial_quaternion_i2bを設定する場合などにおいて、2サイクル目(0.1秒後)の値が変な値になっている.
    • 加えて,CONTROLLED (main_mode = INERTIAL_STABILIZE)の時でもquaternionの値が変動している.

発生条件

propagate_mode = RK4のとき

image

CONTROLLED (main_mode = INERTIAL_STABILIZE)のとき

なぜか3軸固定されていない

image

追加資料

あればリンクなどを貼る

必要な作業

  • あれして
  • これする

影響範囲

tool類が全部死ぬ... みたいな

補足

何かれば

注意

  • 関連する Projects が存在する場合,それの紐付けを行うこと
  • 可能ならば priority ラベルを付けること
  • 可能ならば Assignees を設定すること
  • close するときは結論を明記すること
@TomokiMochizuki TomokiMochizuki added bug Something isn't working priority::high priorityg high S2E labels Jan 19, 2024
@TomokiMochizuki
Copy link
Member Author

@200km
こちら,原因の究明をお願いできますでしょうか?

@200km
Copy link
Member

200km commented Jan 19, 2024

姿勢の初期化モードはどのような設定ですか?

@200km
Copy link
Member

200km commented Jan 19, 2024

relative_attitude_controllerを使ったりはしていないですか?

@200km 200km changed the title [Hotfix] spacecraft_quaternion_i2b の値が怪しい Spacecraft_quaternion_i2b の値が怪しい Jan 19, 2024
@200km
Copy link
Member

200km commented Jan 19, 2024

(明記していないですが、s2e-coreでは[HOTFIX]というのはPRの時に使っていて、issueではあまり使っていないのでタイトル変更しました。)

@TomokiMochizuki
Copy link
Member Author

姿勢の初期化モードはどのような設定ですか?

現在,以下のようにしています.

[ATTITUDE]
// Attitude propagation mode
// RK4 : Attitude Propagation with RK4 including disturbances and control torque
// CONTROLLED : Attitude Calculation with Controlled Attitude mode. All disturbances and control torque are ignored.
propagate_mode = CONTROLLED

// Initialize Attitude mode
// MANUAL : Initialize Quaternion_i2b manually below 
// CONTROLLED : Initialize attitude with given condition. Valid only when Attitude propagation mode is RK4.
initialize_mode = CONTROLLED

// Initial angular velocity at body frame [rad/s]
initial_angular_velocity_b_rad_s(0) = 0.0
initial_angular_velocity_b_rad_s(1) = 0.0
initial_angular_velocity_b_rad_s(2) = 0.0

// Initial quaternion inertial frame to body frame (real part, imaginary part)
// This value also used in INERTIAL_STABILIZE mode of ControlledAttitude
initial_quaternion_i2b(0) = 0.476462
initial_quaternion_i2b(1) = 0.0902572
initial_quaternion_i2b(2) = -0.466688
initial_quaternion_i2b(3) = 0.739621

// Initial torque at body frame [Nm]
// Note: The initial torque added just for the first propagation step
initial_torque_b_Nm(0) = +0.000
initial_torque_b_Nm(1) = -0.000
initial_torque_b_Nm(2) =  0.000

[CONTROLLED_ATTITUDE]
// Mode definitions
// INERTIAL_STABILIZE
// SUN_POINTING
// EARTH_CENTER_POINTING
// VELOCITY_DIRECTION_POINTING
// ORBIT_NORMAL_POINTING
main_mode = INERTIAL_STABILIZE
sub_mode = ORBIT_NORMAL_POINTING

// Pointing direction @ body frame for main pointing mode
main_pointing_direction_b(0) = 1.0
main_pointing_direction_b(1) = 0.0
main_pointing_direction_b(2) = 0.0

// Pointing direction @ body frame for sub pointing mode
// main_pointing_direction_b and sub_pointing_direction_b should separate larger than 30 degrees.
sub_pointing_direction_b(0) = 0.0
sub_pointing_direction_b(1) = 1.0
sub_pointing_direction_b(2) = 0.0

[ORBIT]
calculation = ENABLE
logging = ENABLE

// Orbit propagation mode
// RK4      : RK4 propagation with disturbances and thruster maneuver
// SGP4     : SGP4 propagation using TLE without thruster maneuver
// RELATIVE : Relative dynamics (for formation flying simulation)
// KEPLER   : Kepler orbit propagation without disturbances and thruster maneuver
// ENCKE    : Encke orbit propagation with disturbances and thruster maneuver
propagate_mode = SGP4

// Orbit initialize mode for RK4, KEPLER, and ENCKE
// DEFAULT             : Use default initialize method (RK4 and ENCKE use pos/vel, KEPLER uses init_mode_kepler)
// POSITION_VELOCITY_I : Initialize with position and velocity in the inertial frame
// ORBITAL_ELEMENTS    : Initialize with orbital elements
initialize_mode = POSITION_VELOCITY_I

// Initial value definition for POSITION_VELOCITY_I initialize mode ////////
initial_position_i_m(0) = -2111769.7723711144
initial_position_i_m(1) = -5360353.2254375768
initial_position_i_m(2) = 3596181.6497774957

initial_velocity_i_m_s(0) = 4200.4344740455268
initial_velocity_i_m_s(1) = -4637.540129059361
initial_velocity_i_m_s(2) = -4429.2361258448807
///////////////////////////////////////////////////////////////////////////

// Initial value definition for ORBITAL_ELEMENTS initialize mode ////////
semi_major_axis_m = 6794500.0
eccentricity = 0.0015
inclination_rad = 0.9012
raan_rad = 0.1411
argument_of_perigee_rad = 1.7952
epoch_jday = 2.458940966402607e6
///////////////////////////////////////////////////////////////////////////////


// Settings for SGP4 ///////////////////////////////////////////////
// TLE
// Example: ISS
tle1=1 25544U 98067A   20076.51604214  .00016717  00000-0  10270-3 0  9005
tle2=2 25544  51.6412  86.9962 0006063  30.9353 329.2153 15.49228202 17647
// World Geodetic System
wgs = 2 // 0: wgs72old, 1: wgs72, 2: wgs84
//////////////////////////////////////////////////////////////////////////

// Settings for relative orbit propagation ////////////////////////////
// Relative Orbit Update Method (0 means RK4, 1 means STM)
relative_orbit_update_method = 0
// RK4 Relative Dynamics model type (only valid for RK4 update)
// 0: Hill
relative_dynamics_model_type = 0
// STM Relative Dynamics model type (only valid for STM update)
// 0: HCW
stm_model_type = 0
// Initial satellite position relative to the reference satellite in LVLH frame[m]
// * The coordinate system is defined at [PLANET_SELECTION] in SampleSimBase.ini
initial_relative_position_lvlh_m(0) = 0.0
initial_relative_position_lvlh_m(1) = 100.0
initial_relative_position_lvlh_m(2) = 0.0
// initial satellite velocity relative to the reference satellite in LVLH frame[m/s]
initial_relative_velocity_lvlh_m_s(0) = 0.0
initial_relative_velocity_lvlh_m_s(1) = 0.0
initial_relative_velocity_lvlh_m_s(2) = 0.0
// information of reference satellite
reference_satellite_id = 1
///////////////////////////////////////////////////////////////////////////////

// Settings for Encke mode ///////////
error_tolerance = 0.0001
///////////////////////////////////////////////////////////////////////////////


[THERMAL]
calculation = DISABLE
debug = 0

[SETTING_FILES]
local_environment_file = ../../data/initialize_files/ff_satellite_local_environment.ini
disturbance_file  = ../../data/initialize_files/ff_satellite_disturbance.ini
structure_file = ../../data/initialize_files/ff_satellite_structure.ini

[COMPONENT_FILES]
// Users can add the path for component initialize files here.
relative_distance_sensor_file = ../../data/initialize_files/components/relative_distance_sensor.ini
relative_position_sensor_file = ../../data/initialize_files/components/relative_position_sensor.ini
relative_attitude_sensor_file = ../../data/initialize_files/components/relative_attitude_sensor.ini
relative_velocity_sensor_file = ../../data/initialize_files/components/relative_velocity_sensor.ini
laser_distance_meter_file = ../../data/initialize_files/components/laser_distance_meter.ini
qpd_positioning_sensor_file = ../../data/initialize_files/components/qpd_positioning_sensor.ini
force_generator_file = ../../data/initialize_files/components/force_generator.ini
relative_attitude_controller_file = ../../data/initialize_files/components/relative_attitude_controller.ini

@TomokiMochizuki
Copy link
Member Author

relative_attitude_controllerを使ったりはしていないですか?

ff_components.cppに

  const std::string relative_attitude_controller_file = sat_file.ReadString(section_name.c_str(), "relative_attitude_controller_file");
  relative_attitude_controller_ = new RelativeAttitudeController(InitializeRelativeAttitudeController(
      clock_gen, relative_attitude_controller_file, *rel_info_, local_env_->GetCelestialInformation(), *dynamics_, sat_id));

があると勝手に制御されてしまう感じでしょうか?

@TomokiMochizuki
Copy link
Member Author

TomokiMochizuki commented Jan 19, 2024

main_modeにNO_CONTROLがあったほうがいいかもしれませんね.
enumにはあるので

RelativeAttitudeControlMode ConvertStringToRelativeAttitudeControlMode(const std::string mode_name) {
if (mode_name == "TARGET_SATELLITE_POINTING") {
return RelativeAttitudeControlMode::TARGET_SATELLITE_POINTING;
} else if (mode_name == "SUN_POINTING") {
return RelativeAttitudeControlMode::SUN_POINTING;
} else if (mode_name == "EARTH_CENTER_POINTING") {
return RelativeAttitudeControlMode::EARTH_CENTER_POINTING;
} else if (mode_name == "VELOCITY_DIRECTION_POINTING") {
return RelativeAttitudeControlMode::VELOCITY_DIRECTION_POINTING;
} else if (mode_name == "ORBIT_NORMAL_POINTING") {
return RelativeAttitudeControlMode::ORBIT_NORMAL_POINTING;
} else {
// Error
std::cerr << "RelativeAttitudeControlMode error!" << std::endl;
return RelativeAttitudeControlMode::TARGET_SATELLITE_POINTING;
}
}

enum class RelativeAttitudeControlMode {
TARGET_SATELLITE_POINTING, //!< Satellite pointing
SUN_POINTING, //!< Sun pointing
EARTH_CENTER_POINTING, //!< Earth center pointing
VELOCITY_DIRECTION_POINTING, //!< Velocity direction pointing
ORBIT_NORMAL_POINTING, //!< Orbital normal pointing
NO_CONTROL, //!< No control
};

@TomokiMochizuki
Copy link
Member Author

relative_attitude_controllerはff_satellite.iniとかにある[CONTROLLED_ATTITUDE]を上書きしているという感じでしょうか?

@200km
Copy link
Member

200km commented Jan 19, 2024

relative_attitude_controllerが悪さをしている気がします。

  • ff_components.cppでインスタンスかされていると、そのコンポーネントは動く
  • 姿勢制御するコンポーネントとCONTROLLED_ATTITUDEを同時に動かすことは想定しておらず、変な挙動が起きる
    • お互い上書きし合い、ログ出力のタイミングでどちらの値が表示されるか変わる
    • 内部の外乱計算などどちらの姿勢が適用されるか微妙で予想と違うことが起きえる
    • なので、ここのようにCONTROLLED_ATTITUDEで解析するレポジトリではrelative_attitude_controllerをコメントアウトしている
  • コメントアウト面倒なので、NO_CONTROLDISABLE機能を入れた方が良いというのはその通り

という感じです。望月くんの用途の場合、最終的に姿勢制御アルゴリズムも自分で作るのではないかなと思うので、relative_attitude_controllerは使わない(ff_components.cppでインスタンスかしない)方が良いと思います。

@TomokiMochizuki
Copy link
Member Author

relative_attitude_controllerが悪さをしている気がします。

  • ff_components.cppでインスタンスかされていると、そのコンポーネントは動く

  • 姿勢制御するコンポーネントとCONTROLLED_ATTITUDEを同時に動かすことは想定しておらず、変な挙動が起きる

    • お互い上書きし合い、ログ出力のタイミングでどちらの値が表示されるか変わる
    • 内部の外乱計算などどちらの姿勢が適用されるか微妙で予想と違うことが起きえる
    • なので、ここのようにCONTROLLED_ATTITUDEで解析するレポジトリではrelative_attitude_controllerをコメントアウトしている
  • コメントアウト面倒なので、NO_CONTROLDISABLE機能を入れた方が良いというのはその通り

という感じです。望月くんの用途の場合、最終的に姿勢制御アルゴリズムも自分で作るのではないかなと思うので、relative_attitude_controllerは使わない(ff_components.cppでインスタンスかしない)方が良いと思います。

relative_attitude_controllerを除いたところ,問題なさそうでした.ありがとうございます.

@200km
Copy link
Member

200km commented Jan 19, 2024

よかったです。relative_attitude_controllerの改修はおいおい必要ですね。

@200km
Copy link
Member

200km commented Jan 19, 2024

#87

適切なissueを立てたのでこれはCLOSEします。

@200km 200km closed this as completed Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority::high priorityg high S2E
Projects
None yet
Development

No branches or pull requests

2 participants