18
18
*/
19
19
20
20
#include " facetDragDynamicEffector.h"
21
- # include " architecture/utilities/linearAlgebra.h "
21
+
22
22
#include " architecture/utilities/astroConstants.h"
23
- #include " architecture/utilities/avsEigenSupport.h"
24
23
#include " architecture/utilities/avsEigenMRP.h"
24
+ #include " architecture/utilities/avsEigenSupport.h"
25
+ #include " architecture/utilities/linearAlgebra.h"
25
26
26
- FacetDragDynamicEffector::FacetDragDynamicEffector ()
27
- {
27
+ FacetDragDynamicEffector::FacetDragDynamicEffector () {
28
28
this ->forceExternal_B .fill (0.0 );
29
29
this ->torqueExternalPntB_B .fill (0.0 );
30
30
this ->v_B .fill (0.0 );
31
31
this ->v_hat_B .fill (0.0 );
32
- this ->numFacets = 0 ;
33
- return ;
34
32
}
35
33
36
- void FacetDragDynamicEffector::reset (uint64_t currentSimNanos)
37
- {
38
- // check if input message has not been included
39
- if (!this ->atmoDensInMsg .isLinked ()) {
40
- bskLogger.bskLog (BSK_ERROR, " facetDragDynamicEffector.atmoDensInMsg was not linked." );
41
- }
42
-
43
- return ;
34
+ void FacetDragDynamicEffector::reset (uint64_t currentSimNanos) {
35
+ // check if input message has not been included
36
+ if (!this ->atmoDensInMsg .isLinked ()) {
37
+ bskLogger.bskLog (BSK_ERROR, " facetDragDynamicEffector.atmoDensInMsg was not linked." );
38
+ }
44
39
}
45
- }
46
-
47
40
48
41
/* ! This method is used to read the incoming density message and update the internal density/
49
42
atmospheric data.
50
43
@return void
51
44
*/
52
- bool FacetDragDynamicEffector::readInputs ()
53
- {
45
+ bool FacetDragDynamicEffector::readInputs () {
54
46
bool dataGood;
55
47
this ->atmoInData = this ->atmoDensInMsg ();
56
48
dataGood = this ->atmoDensInMsg .isWritten ();
57
- return ( dataGood) ;
49
+ return dataGood;
58
50
}
59
51
60
52
/* !
@@ -64,12 +56,15 @@ bool FacetDragDynamicEffector::readInputs()
64
56
@param B_normal_hat
65
57
@param B_location
66
58
*/
67
- void FacetDragDynamicEffector::addFacet (double area, double dragCoeff, Eigen::Vector3d B_normal_hat, Eigen::Vector3d B_location){
68
- this ->scGeometry .facetAreas .push_back (area);
69
- this ->scGeometry .facetCoeffs .push_back (dragCoeff);
70
- this ->scGeometry .facetNormals_B .push_back (B_normal_hat);
71
- this ->scGeometry .facetLocations_B .push_back (B_location);
72
- this ->numFacets = this ->numFacets + 1 ;
59
+ void FacetDragDynamicEffector::addFacet (double area,
60
+ double dragCoeff,
61
+ Eigen::Vector3d B_normal_hat,
62
+ Eigen::Vector3d B_location) {
63
+ this ->scGeometry .facetAreas .push_back (area);
64
+ this ->scGeometry .facetCoeffs .push_back (dragCoeff);
65
+ this ->scGeometry .facetNormals_B .push_back (B_normal_hat);
66
+ this ->scGeometry .facetLocations_B .push_back (B_location);
67
+ this ->numFacets = this ->numFacets + 1 ;
73
68
}
74
69
75
70
/* ! This method is used to link the dragEffector to the hub attitude and velocity,
@@ -78,72 +73,67 @@ which are required for calculating drag forces and torques.
78
73
@param states dynamic parameter states
79
74
*/
80
75
81
- void FacetDragDynamicEffector::linkInStates (DynParamManager& states){
82
- this ->hubSigma = states.getStateObject (" hubSigma" );
83
- this ->hubVelocity = states.getStateObject (" hubVelocity" );
76
+ void FacetDragDynamicEffector::linkInStates (DynParamManager& states) {
77
+ this ->hubSigma = states.getStateObject (" hubSigma" );
78
+ this ->hubVelocity = states.getStateObject (" hubVelocity" );
84
79
}
85
80
86
81
/* ! This method updates the internal drag direction based on the spacecraft velocity vector.
87
- */
88
- void FacetDragDynamicEffector::updateDragDir (){
82
+ */
83
+ void FacetDragDynamicEffector::updateDragDir () {
89
84
Eigen::MRPd sigmaBN;
90
85
sigmaBN = (Eigen::Vector3d)this ->hubSigma ->getState ();
91
86
Eigen::Matrix3d dcm_BN = sigmaBN.toRotationMatrix ().transpose ();
92
87
93
- this ->v_B = dcm_BN* this ->hubVelocity ->getState (); // [m/s] sc velocity
88
+ this ->v_B = dcm_BN * this ->hubVelocity ->getState (); // [m/s] sc velocity
94
89
this ->v_hat_B = this ->v_B / this ->v_B .norm ();
95
-
96
- return ;
97
90
}
98
91
99
92
/* ! This method WILL implement a more complex flat-plate aerodynamics model with attitude
100
93
dependence and lift forces.
101
94
*/
102
- void FacetDragDynamicEffector::plateDrag (){
103
- Eigen::Vector3d facetDragForce, facetDragTorque;
104
- Eigen::Vector3d totalDragForce, totalDragTorque;
95
+ void FacetDragDynamicEffector::plateDrag () {
96
+ Eigen::Vector3d facetDragForce;
97
+ Eigen::Vector3d facetDragTorque;
98
+ Eigen::Vector3d totalDragForce;
99
+ Eigen::Vector3d totalDragTorque;
105
100
106
- // ! - Zero out the structure force/torque for the drag set
101
+ // ! - Zero out the structure force/torque for the drag set
107
102
double projectedArea = 0.0 ;
108
103
double projectionTerm = 0.0 ;
109
- totalDragForce.setZero ();
110
- totalDragTorque.setZero ();
104
+ totalDragForce.setZero ();
105
+ totalDragTorque.setZero ();
111
106
this ->forceExternal_B .setZero ();
112
107
this ->torqueExternalPntB_B .setZero ();
113
108
114
- for (size_t i = 0 ; i < this ->numFacets ; i++){
115
- projectionTerm = this ->scGeometry .facetNormals_B [i].dot (this ->v_hat_B );
116
- projectedArea = this ->scGeometry .facetAreas [i] * projectionTerm;
117
- if (projectedArea > 0.0 ){
118
- facetDragForce = 0.5 * pow (this ->v_B .norm (), 2.0 ) * this ->scGeometry .facetCoeffs [i] * projectedArea * this ->atmoInData .neutralDensity * (-1.0 )*this ->v_hat_B ;
119
- facetDragTorque = (-1 )*facetDragForce.cross (this ->scGeometry .facetLocations_B [i]);
120
- totalDragForce = totalDragForce + facetDragForce;
121
- totalDragTorque = totalDragTorque + facetDragTorque;
122
- }
123
- }
124
- this ->forceExternal_B = totalDragForce;
125
- this ->torqueExternalPntB_B = totalDragTorque;
126
-
127
- return ;
128
- }
109
+ for (size_t i = 0 ; i < this ->numFacets ; i++) {
110
+ projectionTerm = this ->scGeometry .facetNormals_B [i].dot (this ->v_hat_B );
111
+ projectedArea = this ->scGeometry .facetAreas [i] * projectionTerm;
112
+ if (projectedArea > 0.0 ) {
113
+ facetDragForce = 0.5 * pow (this ->v_B .norm (), 2.0 ) * this ->scGeometry .facetCoeffs [i] * projectedArea *
114
+ this ->atmoInData .neutralDensity * (-1.0 ) * this ->v_hat_B ;
115
+ facetDragTorque = (-1 ) * facetDragForce.cross (this ->scGeometry .facetLocations_B [i]);
116
+ totalDragForce = totalDragForce + facetDragForce;
117
+ totalDragTorque = totalDragTorque + facetDragTorque;
118
+ }
119
+ }
120
+ this ->forceExternal_B = totalDragForce;
121
+ this ->torqueExternalPntB_B = totalDragTorque;
129
122
123
+ return ;
124
+ }
130
125
131
126
/* ! This method computes the body forces and torques for the dragEffector in a simulation loop,
132
127
selecting the model type based on the settable attribute "modelType."
133
128
*/
134
- void FacetDragDynamicEffector::computeForceTorque (double integTime, double timeStep){
135
- return ;
136
- this ->updateDragDir ();
137
- this ->plateDrag ();
129
+ void FacetDragDynamicEffector::computeForceTorque (double integTime, double timeStep) {
130
+ this ->updateDragDir ();
131
+ this ->plateDrag ();
138
132
}
139
133
140
134
/* ! This method is called to update the local atmospheric conditions at each timestep.
141
135
Naturally, this means that conditions are held piecewise-constant over an integration step.
142
136
@return void
143
137
@param currentSimNanos The current simulation time in nanoseconds
144
138
*/
145
- void FacetDragDynamicEffector::updateState (uint64_t currentSimNanos)
146
- {
147
- return ;
148
- this ->readInputs ();
149
- }
139
+ void FacetDragDynamicEffector::updateState (uint64_t currentSimNanos) { this ->readInputs (); }
0 commit comments