Skip to content

Commit 44bbc65

Browse files
Merge pull request #28 from open-space-collective/users/lucas/flight-profile
Flight profile angular velocity support
2 parents fd61c5d + 0b1593d commit 44bbc65

File tree

6 files changed

+702
-146
lines changed

6 files changed

+702
-146
lines changed

src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,17 @@ State Profile::getStateAt (
9090
throw ostk::core::error::runtime::Undefined("Profile") ;
9191
}
9292

93-
const Transform transform = transformProvider_.getTransformAt(anInstant) ;
93+
const Transform T_REF_B = transformProvider_.getTransformAt(anInstant) ;
94+
95+
const Quaternion q_REF_B = T_REF_B.getOrientation() ;
96+
const Vector3d w_REF_B_in_REF = T_REF_B.getAngularVelocity() ;
9497

95-
const Vector3d position = transform.applyToPosition({ 0.0, 0.0, 0.0 }) ;
96-
const Vector3d velocity = transform.applyToVelocity({ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }) ;
97-
const Quaternion attitude = transform.getOrientation().toConjugate() ;
98-
const Vector3d angularVelocity = transform.getAngularVelocity() ; // [TBC]
98+
const Vector3d x_REF = T_REF_B.applyToPosition({ 0.0, 0.0, 0.0 }) ;
99+
const Vector3d v_REF_in_REF = T_REF_B.applyToVelocity({ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }) ;
100+
const Quaternion q_B_REF = q_REF_B.toConjugate() ;
101+
const Vector3d w_B_REF_in_B = q_B_REF * (w_REF_B_in_REF * -1.0) ;
99102

100-
return { anInstant, position, velocity, attitude, angularVelocity, frameSPtr_ } ;
103+
return { anInstant, x_REF, v_REF_in_REF, q_B_REF, w_B_REF_in_B, frameSPtr_ } ;
101104

102105
}
103106

src/OpenSpaceToolkit/Astrodynamics/Flight/Profile/State.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,34 @@ State State::inFrame (
207207
throw ostk::core::error::runtime::Undefined("State") ;
208208
}
209209

210+
const Vector3d& x_OLD = position_ ;
211+
const Vector3d& v_OLD_in_OLD = velocity_ ;
212+
const Quaternion& q_B_OLD = attitude_ ;
213+
const Vector3d& w_B_OLD_in_B = angularVelocity_ ;
214+
210215
const Transform transform_NEW_OLD = frameSPtr_->getTransformTo(aFrameSPtr, instant_) ;
211216

212-
const Vector3d position = transform_NEW_OLD.applyToPosition(position_) ;
213-
const Vector3d velocity = transform_NEW_OLD.applyToVelocity(position_, velocity_) ;
214-
const Quaternion attitude = attitude_ * transform_NEW_OLD.getOrientation().toConjugate() ;
215-
const Vector3d angularVelocity = { 0.0, 0.0, 0.0 } ; // transform_NEW_OLD.getAngularVelocity() [TBI] ;
217+
const Quaternion q_NEW_OLD = transform_NEW_OLD.getOrientation() ;
218+
const Vector3d w_NEW_OLD_in_NEW = transform_NEW_OLD.getAngularVelocity() ;
219+
220+
// x_NEW = T_NEW_OLD(x_OLD)
221+
222+
const Vector3d x_NEW = transform_NEW_OLD.applyToPosition(x_OLD) ;
223+
224+
// v_NEW = T_NEW_OLD(v_OLD)
225+
226+
const Vector3d v_NEW_in_NEW = transform_NEW_OLD.applyToVelocity(x_OLD, v_OLD_in_OLD) ;
227+
228+
// q_B_NEW = q_B_OLD * q_OLD_NEW
229+
230+
const Quaternion q_B_NEW = q_B_OLD * q_NEW_OLD.toConjugate() ;
231+
232+
// w_B_NEW_in_B = w_B_OLD_in_B + w_OLD_NEW_in_B
233+
// = w_B_OLD_in_B - q_B_NEW * w_NEW_OLD_in_NEW
234+
235+
const Vector3d w_B_NEW_in_B = w_B_OLD_in_B - q_B_NEW * w_NEW_OLD_in_NEW ;
216236

217-
return { instant_, position, velocity, attitude, angularVelocity, aFrameSPtr } ;
237+
return { instant_, x_NEW, v_NEW_in_NEW, q_B_NEW, w_B_NEW_in_B, aFrameSPtr } ;
218238

219239
}
220240

0 commit comments

Comments
 (0)