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