@@ -35,9 +35,7 @@ ConstraintDynamicEffector::~ConstraintDynamicEffector()
35
35
36
36
}
37
37
38
- /* ! This method is used to reset the module.
39
-
40
- */
38
+ /* ! This method is used to reset the module */
41
39
void ConstraintDynamicEffector::Reset (uint64_t CurrentSimNanos)
42
40
{
43
41
// check if any individual gains are not specified
@@ -123,8 +121,73 @@ void ConstraintDynamicEffector::setC_a(double c_a) {
123
121
}
124
122
}
125
123
126
- /* ! This method allows the user to set the cut-off frequency of the low pass filter which is then used to calculate the coefficients for numerical low pass filtering based on a second-order low pass filter design.
124
+ void ConstraintDynamicEffector::setStateNameOfPosition (std::string value) {
125
+ if (!value.empty ()) {
126
+ this ->stateNameOfPosition .push_back (value);
127
+ } else {
128
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: stateNameOfPosition variable must be a non-empty string" );
129
+ }
130
+ }
131
+
132
+ void ConstraintDynamicEffector::setStateNameOfVelocity (std::string value) {
133
+ if (!value.empty ()) {
134
+ this ->stateNameOfVelocity .push_back (value);
135
+ } else {
136
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: stateNameOfVelocity variable must be a non-empty string" );
137
+ }
138
+ }
139
+
140
+ void ConstraintDynamicEffector::setStateNameOfSigma (std::string value) {
141
+ if (!value.empty ()) {
142
+ this ->stateNameOfSigma .push_back (value);
143
+ } else {
144
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: stateNameOfSigma variable must be a non-empty string" );
145
+ }
146
+ }
147
+
148
+ void ConstraintDynamicEffector::setStateNameOfOmega (std::string value) {
149
+ if (!value.empty ()) {
150
+ this ->stateNameOfOmega .push_back (value);
151
+ } else {
152
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: stateNameOfOmega variable must be a non-empty string" );
153
+ }
154
+ }
155
+
156
+ void ConstraintDynamicEffector::setPropName_inertialPosition (std::string value) {
157
+ if (!value.empty ()) {
158
+ this ->propName_inertialPosition .push_back (value);
159
+ } else {
160
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: propName_inertialPosition variable must be a non-empty string" );
161
+ }
162
+ }
163
+
164
+ void ConstraintDynamicEffector::setPropName_inertialVelocity (std::string value) {
165
+ if (!value.empty ()) {
166
+ this ->propName_inertialVelocity .push_back (value);
167
+ } else {
168
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: propName_inertialVelocity variable must be a non-empty string" );
169
+ }
170
+ }
171
+
172
+ void ConstraintDynamicEffector::setPropName_inertialAttitude (std::string value) {
173
+ if (!value.empty ()) {
174
+ this ->propName_inertialAttitude .push_back (value);
175
+ } else {
176
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: propName_inertialAttitude variable must be a non-empty string" );
177
+ }
178
+ }
179
+
180
+ void ConstraintDynamicEffector::setPropName_inertialAngVelocity (std::string value) {
181
+ if (!value.empty ()) {
182
+ this ->propName_inertialAngVelocity .push_back (value);
183
+ } else {
184
+ bskLogger.bskLog (BSK_ERROR, " ConstraintDynamicEffector: propName_inertialAngVelocity variable must be a non-empty string" );
185
+ }
186
+ }
127
187
188
+ /* ! This method allows the user to set the cut-off frequency of the low pass filter which is then
189
+ used to calculate the coefficients for numerical low pass filtering based on a second-order low
190
+ pass filter design.
128
191
@param wc The cut-off frequency of the low pass filter.
129
192
@param h The constant digital time step.
130
193
@param k The damping coefficient
@@ -144,9 +207,7 @@ void ConstraintDynamicEffector::setFilter_Data(double wc, double h, double k){
144
207
}
145
208
}
146
209
147
- /* ! This method allows the user to set the status of the constraint dynamic effector
148
-
149
- */
210
+ /* ! This method allows the user to set the status of the constraint dynamic effector */
150
211
void ConstraintDynamicEffector::readInputMessage (){
151
212
if (this ->effectorStatusInMsg .isLinked ()){
152
213
DeviceStatusMsgPayload statusMsg;
@@ -159,25 +220,68 @@ void ConstraintDynamicEffector::readInputMessage(){
159
220
}
160
221
161
222
/* ! This method allows the constraint effector to have access to the parent states
162
-
163
223
@param states The states to link
164
224
*/
165
225
void ConstraintDynamicEffector::linkInStates (DynParamManager& states)
166
226
{
167
227
if (this ->scInitCounter > 1 ) {
168
- bskLogger.bskLog (BSK_ERROR, " constraintDynamicEffector: tried to attach more than 2 spacecraft " );
228
+ bskLogger.bskLog (BSK_ERROR, " constraintDynamicEffector: tried to attach more than 2 parents " );
169
229
}
170
230
171
- this ->hubSigma .push_back (states.getStateObject (" hubSigma" ));
172
- this ->hubOmega .push_back (states.getStateObject (" hubOmega" ));
173
- this ->hubPosition .push_back (states.getStateObject (" hubPosition" ));
174
- this ->hubVelocity .push_back (states.getStateObject (" hubVelocity" ));
231
+ this ->hubSigma .push_back (states.getStateObject (this ->stateNameOfSigma [scInitCounter]));
232
+ this ->hubOmega .push_back (states.getStateObject (this ->stateNameOfOmega [scInitCounter]));
233
+ this ->hubPosition .push_back (states.getStateObject (this ->stateNameOfPosition [scInitCounter]));
234
+ this ->hubVelocity .push_back (states.getStateObject (this ->stateNameOfVelocity [scInitCounter]));
235
+
236
+ if (this ->scInitCounter == 0 ) {
237
+ this ->parent1 .parentType = " hub" ;
238
+ this ->parent1 .idx = 0 ;
239
+ this ->hubCounter = 1 ;
240
+ }
241
+ else if (this ->scInitCounter == 1 ) {
242
+ this ->parent2 .parentType = " hub" ;
243
+ if (this ->hubCounter == 0 ) {
244
+ this ->parent2 .idx = 0 ;
245
+ } else if (this ->hubCounter == 1 ) {
246
+ this ->parent2 .idx = 1 ;
247
+ }
248
+ }
175
249
176
250
this ->scInitCounter ++;
177
251
}
178
252
179
- /* ! This method computes the forces on torques on each spacecraft body.
253
+ /* ! This method is used to link properties to the constraint effector.
254
+ @return void
255
+ @param properties The parameter manager to collect from
256
+ */
257
+ void ConstraintDynamicEffector::linkInProperties (DynParamManager& properties){
258
+ if (this ->scInitCounter > 1 ) {
259
+ bskLogger.bskLog (BSK_ERROR, " constraintDynamicEffector: tried to attach more than 2 parents" );
260
+ }
261
+
262
+ this ->inertialAttitudeProperty .push_back (properties.getPropertyReference (this ->propName_inertialAttitude [scInitCounter]));
263
+ this ->inertialAngVelocityProperty .push_back (properties.getPropertyReference (this ->propName_inertialAngVelocity [scInitCounter]));
264
+ this ->inertialPositionProperty .push_back (properties.getPropertyReference (this ->propName_inertialPosition [scInitCounter]));
265
+ this ->inertialVelocityProperty .push_back (properties.getPropertyReference (this ->propName_inertialVelocity [scInitCounter]));
180
266
267
+ if (this ->scInitCounter == 0 ) {
268
+ this ->parent1 .parentType = " effector" ;
269
+ this ->parent1 .idx = 0 ;
270
+ this ->effectorCounter = 1 ;
271
+ }
272
+ else if (this ->scInitCounter == 1 ) {
273
+ this ->parent2 .parentType = " effector" ;
274
+ if (this ->effectorCounter == 0 ) {
275
+ this ->parent2 .idx = 0 ;
276
+ } else if (this ->effectorCounter == 1 ) {
277
+ this ->parent2 .idx = 1 ;
278
+ }
279
+ }
280
+
281
+ this ->scInitCounter ++;
282
+ }
283
+
284
+ /* ! This method computes the forces on torques on each spacecraft body.
181
285
@param integTime Integration time
182
286
@param timeStep Current integration time step used
183
287
*/
@@ -186,17 +290,38 @@ void ConstraintDynamicEffector::computeForceTorque(double integTime, double time
186
290
if (this ->scInitCounter == 2 ) { // only proceed once both spacecraft are added
187
291
// alternate assigning the constraint force and torque
188
292
if (this ->scID == 0 ) { // compute all forces and torques once, assign to spacecraft 1 and store for spacecraft 2
189
- // - Collect states from both spacecraft
190
- Eigen::Vector3d r_B1N_N = this ->hubPosition [0 ]->getState ();
191
- Eigen::Vector3d rDot_B1N_N = this ->hubVelocity [0 ]->getState ();
192
- Eigen::Vector3d omega_B1N_B1 = this ->hubOmega [0 ]->getState ();
293
+ Eigen::Vector3d r_B1N_N;
294
+ Eigen::Vector3d rDot_B1N_N;
295
+ Eigen::Vector3d omega_B1N_B1;
193
296
Eigen::MRPd sigma_B1N;
194
- sigma_B1N = (Eigen::Vector3d)this ->hubSigma [0 ]->getState ();
195
- Eigen::Vector3d r_B2N_N = this ->hubPosition [1 ]->getState ();
196
- Eigen::Vector3d rDot_B2N_N = this ->hubVelocity [1 ]->getState ();
197
- Eigen::Vector3d omega_B2N_B2 = this ->hubOmega [1 ]->getState ();
297
+ Eigen::Vector3d r_B2N_N;
298
+ Eigen::Vector3d rDot_B2N_N;
299
+ Eigen::Vector3d omega_B2N_B2;
198
300
Eigen::MRPd sigma_B2N;
199
- sigma_B2N = (Eigen::Vector3d)this ->hubSigma [1 ]->getState ();
301
+ if (this ->parent1 .parentType == " hub" ) {
302
+ // - Collect states from parent spacecraft hub
303
+ r_B1N_N = this ->hubPosition [parent1.idx ]->getState ();
304
+ rDot_B1N_N = this ->hubVelocity [parent1.idx ]->getState ();
305
+ omega_B1N_B1 = this ->hubOmega [parent1.idx ]->getState ();
306
+ sigma_B1N = (Eigen::Vector3d)this ->hubSigma [parent1.idx ]->getState ();
307
+ } else if (this ->parent2 .parentType == " effector" ) {
308
+ // - Collect properties from parent effector
309
+ r_B1N_N = *this ->inertialPositionProperty [parent1.idx ];
310
+ rDot_B1N_N = *this ->inertialVelocityProperty [parent1.idx ];
311
+ omega_B1N_B1 = *this ->inertialAngVelocityProperty [parent1.idx ];
312
+ sigma_B1N = (Eigen::Vector3d)*this ->inertialAttitudeProperty [parent1.idx ];
313
+ }
314
+ if (this ->parent2 .parentType == " hub" ) {
315
+ r_B2N_N = this ->hubPosition [parent2.idx ]->getState ();
316
+ rDot_B2N_N = this ->hubVelocity [parent2.idx ]->getState ();
317
+ omega_B2N_B2 = this ->hubOmega [parent2.idx ]->getState ();
318
+ sigma_B2N = (Eigen::Vector3d)this ->hubSigma [parent2.idx ]->getState ();
319
+ } else if (this ->parent2 .parentType == " effector" ) {
320
+ r_B2N_N = *this ->inertialPositionProperty [parent2.idx ];
321
+ rDot_B2N_N = *this ->inertialVelocityProperty [parent2.idx ];
322
+ omega_B2N_B2 = *this ->inertialAngVelocityProperty [parent2.idx ];
323
+ sigma_B2N = (Eigen::Vector3d)*this ->inertialAttitudeProperty [parent2.idx ];
324
+ }
200
325
201
326
// computing direction constraint psi in the N frame
202
327
Eigen::Matrix3d dcm_B1N = (sigma_B1N.toRotationMatrix ()).transpose ();
@@ -252,9 +377,8 @@ void ConstraintDynamicEffector::computeForceTorque(double integTime, double time
252
377
}
253
378
}
254
379
255
- /* ! This method takes the computed constraint force and torque states and outputs them to the m
380
+ /* ! This method takes the computed constraint force and torque states and outputs them to the
256
381
messaging system.
257
-
258
382
@param CurrentClock The current simulation time (used for time stamping)
259
383
*/
260
384
void ConstraintDynamicEffector::writeOutputStateMessage (uint64_t CurrentClock)
@@ -272,7 +396,6 @@ void ConstraintDynamicEffector::writeOutputStateMessage(uint64_t CurrentClock)
272
396
}
273
397
274
398
/* ! Update state method
275
-
276
399
@param CurrentSimNanos The current simulation time
277
400
*/
278
401
void ConstraintDynamicEffector::UpdateState (uint64_t CurrentSimNanos)
@@ -286,7 +409,6 @@ void ConstraintDynamicEffector::UpdateState(uint64_t CurrentSimNanos)
286
409
}
287
410
288
411
/* ! Filtering method to calculate filtered Constraint Force
289
-
290
412
@param CurrentClock The current simulation time (used for time stamping)
291
413
*/
292
414
void ConstraintDynamicEffector::computeFilteredForce (uint64_t CurrentClock)
@@ -305,7 +427,6 @@ void ConstraintDynamicEffector::computeFilteredForce(uint64_t CurrentClock)
305
427
}
306
428
307
429
/* ! Filtering method to calculate filtered Constraint Torque
308
-
309
430
@param CurrentClock The current simulation time (used for time stamping)
310
431
*/
311
432
void ConstraintDynamicEffector::computeFilteredTorque (uint64_t CurrentClock)
0 commit comments