Skip to content

Commit 99c1040

Browse files
Merge pull request #1105 from AVSLab/feature/add-relative-attitude-constraint-effector
Add relative attitude to the constraint effector
2 parents 70731e9 + 70d40d5 commit 99c1040

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

docs/source/Support/bskReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Version |release|
3636
Users need to use ``ClassicalElements()`` defined in ``orbitalMotion``.
3737
- Fixed bug with recording message payload entries that are 2D arrays. This bug was introduced with the faster recording
3838
strategy added in version 2.78.0.
39+
- Add a desired relative attitude between spacecraft in :ref:`constraintDynamicEffector`.
3940

4041

4142
Version 2.78.0 (August 30, 2025)

src/simulation/dynamics/constraintEffector/constraintDynamicEffector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void ConstraintDynamicEffector::setR_P2B2_B2(Eigen::Vector3d r_P2B2_B2) {
7575
this->r_P2B2_B2 = r_P2B2_B2;
7676
}
7777

78+
void ConstraintDynamicEffector::setSigma_B2B1Init(Eigen::MRPd sigma_B2B1Init) {
79+
this->dcm_B2B1Init = sigma_B2B1Init.toRotationMatrix().transpose();
80+
}
81+
7882
void ConstraintDynamicEffector::setAlpha(double alpha) {
7983
if (alpha > 0.0)
8084
this->alpha = alpha;
@@ -218,7 +222,7 @@ void ConstraintDynamicEffector::computeForceTorque(double integTime, double time
218222
this->psiPrime_N = rDot_P2P1_N - omega_B1N_N.cross(r_P2P1_N);
219223

220224
// calculate the attitude constraint violations
221-
this->sigma_B2B1 = eigenC2MRP(dcm_B2N * dcm_B1N.transpose()); // calculate the difference in attitude
225+
this->phi = eigenC2MRP(dcm_B2N * dcm_B1N.transpose() * this->dcm_B2B1Init.transpose()); // calculate the difference in attitude
222226
Eigen::Vector3d omega_B1N_B2 = dcm_B2N * dcm_B1N.transpose() * omega_B1N_B1;
223227
this->omega_B2B1_B2 = omega_B2N_B2 - omega_B1N_B2; // difference in angular rate
224228

@@ -234,7 +238,7 @@ void ConstraintDynamicEffector::computeForceTorque(double integTime, double time
234238

235239
// calculate the constraint torque imparted on each spacecraft from the attitude constraint
236240
Eigen::Matrix3d dcm_B1B2 = dcm_B1N * dcm_B2N.transpose();
237-
Eigen::Vector3d L_B2_att = -this->k_a * eigenMRPd2Vector3d(sigma_B2B1) - this->c_a * 0.25 * sigma_B2B1.Bmat() * omega_B2B1_B2;
241+
Eigen::Vector3d L_B2_att = -this->k_a * eigenMRPd2Vector3d(this->phi) - this->c_a * 0.25 * this->phi.Bmat() * omega_B2B1_B2;
238242
Eigen::Vector3d L_B1_att = - dcm_B1B2 * L_B2_att;
239243
this->T_B2 = L_B2_len + L_B2_att; // store the constraint torque for spacecraft 2
240244

src/simulation/dynamics/constraintEffector/constraintDynamicEffector.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class ConstraintDynamicEffector: public SysModel, public DynamicEffector {
5353
void setR_P1B1_B1(Eigen::Vector3d r_P1B1_B1);
5454
/** setter for `r_P2B2_B2` connection point position on spacecraft 2 */
5555
void setR_P2B2_B2(Eigen::Vector3d r_P2B2_B2);
56+
/** setter for `sigma_B2B1_Init` initial spacecraft relative attitude */
57+
void setSigma_B2B1Init(Eigen::MRPd sigma_B2B1Init);
5658
/** setter for `alpha` gain tuning parameter */
5759
void setAlpha(double alpha);
5860
/** setter for `beta` gain tuning parameter */
@@ -100,7 +102,10 @@ class ConstraintDynamicEffector: public SysModel, public DynamicEffector {
100102
// Constraint length and direction
101103
Eigen::Vector3d r_P1B1_B1 = Eigen::Vector3d::Zero(); //!< [m] position vector from spacecraft 1 hub to its connection point P1
102104
Eigen::Vector3d r_P2B2_B2 = Eigen::Vector3d::Zero(); //!< [m] position vector from spacecraft 2 hub to its connection point P2
103-
Eigen::Vector3d r_P2P1_B1Init = Eigen::Vector3d::Zero(); //!< [m] precribed position vector from spacecraft 1 connection point to spacecraft 2 connection point
105+
Eigen::Vector3d r_P2P1_B1Init = Eigen::Vector3d::Zero(); //!< [m] prescribed position vector from spacecraft 1 connection point to spacecraft 2 connection point
106+
107+
// Constraint attitude
108+
Eigen::Matrix3d dcm_B2B1Init = Eigen::Matrix3d::Identity(); //!< attitude constraint violation
104109

105110
// Gains for PD controller
106111
double alpha = 0.0; //!< Baumgarte stabilization gain tuning variable
@@ -145,7 +150,7 @@ class ConstraintDynamicEffector: public SysModel, public DynamicEffector {
145150
// Constraint violations
146151
Eigen::Vector3d psi_N = Eigen::Vector3d::Zero(); //!< [m] direction constraint violation in inertial frame
147152
Eigen::Vector3d psiPrime_N = Eigen::Vector3d::Zero(); //!< [m/s] direction rate constraint violation in inertial frame
148-
Eigen::MRPd sigma_B2B1 = Eigen::MRPd::Identity(); //!< attitude constraint violation
153+
Eigen::MRPd phi = Eigen::MRPd::Identity(); //!< attitude constraint violation
149154
Eigen::Vector3d omega_B2B1_B2 = Eigen::Vector3d::Zero(); //!< [rad/s] angular velocity constraint violation in spacecraft 2 body frame
150155

151156
// Force and torque quantities stored to be assigned on the alternating call of computeForceTorque

0 commit comments

Comments
 (0)