Skip to content

Commit 26697fd

Browse files
committed
Add pre-commit formatting changes
1 parent 457942f commit 26697fd

File tree

2 files changed

+73
-86
lines changed

2 files changed

+73
-86
lines changed

src/simulation/dynamics/facetDragEffector/facetDragDynamicEffector.cpp

+53-63
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,35 @@
1818
*/
1919

2020
#include "facetDragDynamicEffector.h"
21-
#include "architecture/utilities/linearAlgebra.h"
21+
2222
#include "architecture/utilities/astroConstants.h"
23-
#include "architecture/utilities/avsEigenSupport.h"
2423
#include "architecture/utilities/avsEigenMRP.h"
24+
#include "architecture/utilities/avsEigenSupport.h"
25+
#include "architecture/utilities/linearAlgebra.h"
2526

26-
FacetDragDynamicEffector::FacetDragDynamicEffector()
27-
{
27+
FacetDragDynamicEffector::FacetDragDynamicEffector() {
2828
this->forceExternal_B.fill(0.0);
2929
this->torqueExternalPntB_B.fill(0.0);
3030
this->v_B.fill(0.0);
3131
this->v_hat_B.fill(0.0);
32-
this->numFacets = 0;
33-
return;
3432
}
3533

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+
}
4439
}
45-
}
46-
4740

4841
/*! This method is used to read the incoming density message and update the internal density/
4942
atmospheric data.
5043
@return void
5144
*/
52-
bool FacetDragDynamicEffector::readInputs()
53-
{
45+
bool FacetDragDynamicEffector::readInputs() {
5446
bool dataGood;
5547
this->atmoInData = this->atmoDensInMsg();
5648
dataGood = this->atmoDensInMsg.isWritten();
57-
return(dataGood);
49+
return dataGood;
5850
}
5951

6052
/*!
@@ -64,12 +56,15 @@ bool FacetDragDynamicEffector::readInputs()
6456
@param B_normal_hat
6557
@param B_location
6658
*/
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;
7368
}
7469

7570
/*! 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.
7873
@param states dynamic parameter states
7974
*/
8075

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");
8479
}
8580

8681
/*! This method updates the internal drag direction based on the spacecraft velocity vector.
87-
*/
88-
void FacetDragDynamicEffector::updateDragDir(){
82+
*/
83+
void FacetDragDynamicEffector::updateDragDir() {
8984
Eigen::MRPd sigmaBN;
9085
sigmaBN = (Eigen::Vector3d)this->hubSigma->getState();
9186
Eigen::Matrix3d dcm_BN = sigmaBN.toRotationMatrix().transpose();
9287

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
9489
this->v_hat_B = this->v_B / this->v_B.norm();
95-
96-
return;
9790
}
9891

9992
/*! This method WILL implement a more complex flat-plate aerodynamics model with attitude
10093
dependence and lift forces.
10194
*/
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;
105100

106-
//! - Zero out the structure force/torque for the drag set
101+
//! - Zero out the structure force/torque for the drag set
107102
double projectedArea = 0.0;
108103
double projectionTerm = 0.0;
109-
totalDragForce.setZero();
110-
totalDragTorque.setZero();
104+
totalDragForce.setZero();
105+
totalDragTorque.setZero();
111106
this->forceExternal_B.setZero();
112107
this->torqueExternalPntB_B.setZero();
113108

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;
129122

123+
return;
124+
}
130125

131126
/*! This method computes the body forces and torques for the dragEffector in a simulation loop,
132127
selecting the model type based on the settable attribute "modelType."
133128
*/
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();
138132
}
139133

140134
/*! This method is called to update the local atmospheric conditions at each timestep.
141135
Naturally, this means that conditions are held piecewise-constant over an integration step.
142136
@return void
143137
@param currentSimNanos The current simulation time in nanoseconds
144138
*/
145-
void FacetDragDynamicEffector::updateState(uint64_t currentSimNanos)
146-
{
147-
return;
148-
this->readInputs();
149-
}
139+
void FacetDragDynamicEffector::updateState(uint64_t currentSimNanos) { this->readInputs(); }

src/simulation/dynamics/facetDragEffector/facetDragDynamicEffector.h

+20-23
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,52 @@
1717
1818
*/
1919

20-
2120
#ifndef FACET_DRAG_DYNAMIC_EFFECTOR_H
2221
#define FACET_DRAG_DYNAMIC_EFFECTOR_H
2322

2423
#include <Eigen/Dense>
2524
#include <vector>
26-
#include "simulation/dynamics/_GeneralModuleFiles/dynamicEffector.h"
27-
#include "simulation/dynamics/_GeneralModuleFiles/stateData.h"
28-
#include "architecture/_GeneralModuleFiles/sys_model.h"
2925

30-
#include "architecture/msgPayloadDefC/AtmoPropsMsgPayload.h"
26+
#include "architecture/_GeneralModuleFiles/sys_model.h"
3127
#include "architecture/messaging/messaging.h"
32-
33-
#include "architecture/utilities/rigidBodyKinematics.h"
28+
#include "architecture/msgPayloadDefC/AtmoPropsMsgPayload.h"
3429
#include "architecture/utilities/bskLogging.h"
30+
#include "architecture/utilities/rigidBodyKinematics.h"
31+
#include "simulation/dynamics/_GeneralModuleFiles/dynamicEffector.h"
32+
#include "simulation/dynamics/_GeneralModuleFiles/stateData.h"
3533

3634
/*! @brief spacecraft geometry data */
3735
typedef struct {
38-
std::vector<double> facetAreas; //!< vector of facet areas
39-
std::vector<double> facetCoeffs; //!< vector of facet coefficients
40-
std::vector<Eigen::Vector3d> facetNormals_B; //!< vector of facet normals
41-
std::vector<Eigen::Vector3d> facetLocations_B; //!< vector of facet locations
42-
}SpacecraftGeometryData;
43-
36+
std::vector<double> facetAreas; //!< vector of facet areas
37+
std::vector<double> facetCoeffs; //!< vector of facet coefficients
38+
std::vector<Eigen::Vector3d> facetNormals_B; //!< vector of facet normals
39+
std::vector<Eigen::Vector3d> facetLocations_B; //!< vector of facet locations
40+
} SpacecraftGeometryData;
4441

4542
/*! @brief faceted atmospheric drag dynamic effector */
46-
class FacetDragDynamicEffector: public SysModel, public DynamicEffector {
47-
public:
43+
class FacetDragDynamicEffector : public SysModel, public DynamicEffector {
44+
public:
4845
FacetDragDynamicEffector();
4946
void linkInStates(DynParamManager& states) override;
5047
void computeForceTorque(double integTime, double timeStep) override;
5148
void reset(uint64_t currentSimNanos) override;
5249
void updateState(uint64_t currentSimNanos) override;
5350
void addFacet(double area, double dragCoeff, Eigen::Vector3d B_normal_hat, Eigen::Vector3d B_location);
5451

55-
uint64_t numFacets=0; //!< number of facets
56-
ReadFunctor<AtmoPropsMsgPayload> atmoDensInMsg; //!< atmospheric density input message
57-
StateData *hubSigma; //!< -- Hub/Inertial attitude represented by MRP
58-
StateData *hubVelocity; //!< m/s Hub inertial velocity vector
59-
Eigen::Vector3d v_B; //!< m/s local variable to hold the inertial velocity
60-
Eigen::Vector3d v_hat_B; //!< class variable
52+
uint64_t numFacets = 0; //!< number of facets
53+
ReadFunctor<AtmoPropsMsgPayload> atmoDensInMsg; //!< atmospheric density input message
54+
StateData* hubSigma; //!< -- Hub/Inertial attitude represented by MRP
55+
StateData* hubVelocity; //!< m/s Hub inertial velocity vector
56+
Eigen::Vector3d v_B; //!< m/s local variable to hold the inertial velocity
57+
Eigen::Vector3d v_hat_B; //!< class variable
6158

62-
private:
59+
private:
6360
bool readInputs();
6461
void plateDrag();
6562
void updateDragDir();
6663

6764
AtmoPropsMsgPayload atmoInData;
68-
SpacecraftGeometryData scGeometry; //!< -- Struct to hold spacecraft facet data
65+
SpacecraftGeometryData scGeometry; //!< -- Struct to hold spacecraft facet data
6966
};
7067

7168
#endif

0 commit comments

Comments
 (0)