Skip to content

Commit

Permalink
Merge pull request #688 from AVSLab/feature/unused_includes
Browse files Browse the repository at this point in the history
Feature/unused includes
  • Loading branch information
schaubh authored May 16, 2024
2 parents e41a131 + f4a14ba commit e2f1e39
Show file tree
Hide file tree
Showing 116 changed files with 806 additions and 1,057 deletions.
13 changes: 6 additions & 7 deletions src/architecture/messaging/messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
*/
#ifndef MESSAGING_H
#define MESSAGING_H
#include <memory>
#include "architecture/_GeneralModuleFiles/sys_model.h"
#include <vector>
#include "architecture/messaging/msgHeader.h"
Expand All @@ -39,7 +38,7 @@ class ReadFunctor{
messageType* payloadPointer; //!< -- pointer to the incoming msg data
MsgHeader *headerPointer; //!< -- pointer to the incoming msg header
bool initialized; //!< -- flag indicating if the input message is connect to another message

public:
//!< -- BSK Logging
BSKLogger bskLogger; //!< -- bsk logging instance
Expand Down Expand Up @@ -126,17 +125,17 @@ class ReadFunctor{

//! Check if self has been subscribed to a C message
uint8_t isSubscribedToC(void *source){

int8_t firstCheck = (this->headerPointer == (MsgHeader*) source);
MsgHeader* pt = this->headerPointer;
int8_t secondCheck = (this->payloadPointer == (messageType *) (++pt));

return (this->initialized && firstCheck && secondCheck);

};
//! Check if self has been subscribed to a Cpp message
uint8_t isSubscribedTo(Message<messageType> *source){

MsgHeader *dummyMsgPtr;
int8_t firstCheck = (this->payloadPointer == source->getMsgPointers(&(dummyMsgPtr)));
int8_t secondCheck = (this->headerPointer == dummyMsgPtr);
Expand Down Expand Up @@ -197,7 +196,7 @@ class Message{

//! Recorder object
Recorder<messageType> recorder(uint64_t timeDiff = 0){return Recorder<messageType>(this, timeDiff);}

messageType zeroMsgPayload = {}; //!< zero'd copy of the message payload structure

//! check if this msg has been connected to
Expand Down Expand Up @@ -296,7 +295,7 @@ class Recorder : public SysModel{
std::vector<uint64_t>& timesWritten(){return this->msgWrittenTimes;}
//! record method
std::vector<messageType>& record(){return this->msgRecord;};

//! determine message name
std::string findMsgName(std::string msgName) {
size_t locMsg = msgName.find("Payload");
Expand Down
31 changes: 15 additions & 16 deletions src/architecture/utilities/BSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "BSpline.h"
#include <architecture/utilities/avsEigenSupport.h>
#include <iostream>
#include <cstring>
#include <math.h>

/*! This constructor initializes an Input structure for BSpline interpolation */
Expand Down Expand Up @@ -233,12 +232,12 @@ double OutputDataSet::getStates(double T, int derivative, int index)

/*! This function takes the Input structure, performs the BSpline interpolation and outputs the result into Output structure */
void interpolate(InputDataSet Input, int Num, int P, OutputDataSet *Output)
{
{
Output->P = P;

// N = number of waypoints - 1
// N = number of waypoints - 1
int N = (int) Input.X1.size() - 1;

// T = time tags; if not specified, it is computed from a cartesian distance assuming a constant velocity norm on average
Eigen::VectorXd T(N+1);
double S = 0;
Expand Down Expand Up @@ -272,7 +271,7 @@ void interpolate(InputDataSet Input, int Num, int P, OutputDataSet *Output)
if (Input.XDot_N_flag == true) {K += 1;}
if (Input.XDDot_0_flag == true) {K += 1;}
if (Input.XDDot_N_flag == true) {K += 1;}

// The maximum polynomial order is N + K. If a higher order is requested, print a BSK_ERROR
if (P > N + K) {
std::cout << "Error in BSpline.interpolate: \n the desired polynomial order P is too high. Mass matrix A will be singular. \n" ;
Expand Down Expand Up @@ -390,7 +389,7 @@ void interpolate(InputDataSet Input, int Num, int P, OutputDataSet *Output)
Output->XD2.resize(Num);
Output->XD3.resize(Num);
Output->XDD1.resize(Num);
Output->XDD2.resize(Num);
Output->XDD2.resize(Num);
Output->XDD3.resize(Num);
for (int i = 0; i < Num; i++) {
basisFunction(t, U, N+K+1, P, &NN[0], &NN1[0], &NN2[0]);
Expand All @@ -412,12 +411,12 @@ void interpolate(InputDataSet Input, int Num, int P, OutputDataSet *Output)

/*! This function takes the Input structure, performs the BSpline LS approximation and outputs the result into Output structure */
void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Output)
{
{
Output->P = P;

// N = number of waypoints - 1
// N = number of waypoints - 1
int N = (int) Input.X1.size() - 1;

// T = time tags; if not specified, it is computed from a cartesian distance assuming a constant velocity norm on average
Eigen::VectorXd T(N+1);
double S = 0;
Expand All @@ -444,7 +443,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
for (int n = 0; n < N+1; n++) {
uk[n] = T[n] / Ttot;
}

// The maximum polynomial order is N + K. If a higher order is requested, print a BSK_ERROR
if (P > Q) {
std::cout << "Error in BSpline.approximate: \n the desired polynomial order P can't be higher than the number of control points Q. \n" ;
Expand Down Expand Up @@ -505,7 +504,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
n += 1;
MD(n,0) = NN2[0];
MD(n,1) = NN2[1];
MD(n,2) = NN2[2];
MD(n,2) = NN2[2];
T1[n] = Input.XDDot_0[0] * pow(Ttot,2);
T2[n] = Input.XDDot_0[1] * pow(Ttot,2);
T3[n] = Input.XDDot_0[2] * pow(Ttot,2);
Expand All @@ -516,7 +515,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
n += 1;
MD(n,K-1) = NN2[Q-2];
MD(n,K) = NN2[Q-1];
MD(n,K+1) = NN2[Q];
MD(n,K+1) = NN2[Q];
T1[K-1] = Input.XDDot_N[0] * pow(Ttot,2);
T2[K] = Input.XDDot_N[1] * pow(Ttot,2);
T3[K+1] = Input.XDDot_N[2] * pow(Ttot,2);
Expand Down Expand Up @@ -570,7 +569,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
Rk3[n-1] -= NN[Q-1]*C3_1[K];
}
}

// populate LS matrix ND
Eigen::MatrixXd ND(N-1,Q-K-1);
for (int n = 0; n < N-1; n++) {
Expand Down Expand Up @@ -614,7 +613,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
Eigen::VectorXd C1_2 = NWN_inv * R1;
Eigen::VectorXd C2_2 = NWN_inv * R2;
Eigen::VectorXd C3_2 = NWN_inv * R3;

// build control point vectors C
Eigen::VectorXd C1(Q+1), C2(Q+1), C3(Q+1);
n = 0;
Expand Down Expand Up @@ -657,7 +656,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu
Output->XD2.resize(Num);
Output->XD3.resize(Num);
Output->XDD1.resize(Num);
Output->XDD2.resize(Num);
Output->XDD2.resize(Num);
Output->XDD3.resize(Num);
for (int i = 0; i < Num; i++) {
basisFunction(t, U, Q+1, P, &NN[0], &NN1[0], &NN2[0]);
Expand All @@ -679,7 +678,7 @@ void approximate(InputDataSet Input, int Num, int Q, int P, OutputDataSet *Outpu

/*! This function calculates the basis functions NN of order P, and derivatives NN1, NN2, for a given time t and knot vector U */
void basisFunction(double t, Eigen::VectorXd U, int I, int P, double *NN, double *NN1, double *NN2)
{
{
Eigen::MatrixXd N(I, P+1);
Eigen::MatrixXd N1(I, P+1);
Eigen::MatrixXd N2(I, P+1);
Expand Down
15 changes: 5 additions & 10 deletions src/architecture/utilities/discretize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
*/

#include "discretize.h"
#include <iostream>
#include <string>
#include <math.h>
#include "linearAlgebra.h"

/*! The constructor initialies the random number generator used for the walks*/
Discretize::Discretize()
Expand Down Expand Up @@ -54,7 +51,7 @@ Discretize::~Discretize()
@param direction
@return void*/
void Discretize::setRoundDirection(roundDirection_t direction){

this->roundDirection = direction;

return;
Expand All @@ -65,15 +62,15 @@ void Discretize::setRoundDirection(roundDirection_t direction){
@param undiscretizedVector
@return vector of discretized values*/
Eigen::VectorXd Discretize::discretize(Eigen::VectorXd undiscretizedVector){

if (this->carryError){
undiscretizedVector += this->discErrors;
}

//discretize the data
Eigen::VectorXd workingVector = undiscretizedVector.cwiseQuotient(this->LSB);
workingVector = workingVector.cwiseAbs();

if (this->roundDirection == TO_ZERO){
for (uint8_t i = 0; i < this->numStates; i++){
workingVector[i] = floor(workingVector[i]);
Expand All @@ -93,8 +90,6 @@ Eigen::VectorXd Discretize::discretize(Eigen::VectorXd undiscretizedVector){
workingVector[i] = copysign(workingVector[i], undiscretizedVector[i]);
}
this->discErrors = undiscretizedVector - workingVector;

return workingVector;
}


16 changes: 7 additions & 9 deletions src/architecture/utilities/gauss_markov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include <iostream>
#include <math.h>
#include "gauss_markov.h"
#include "linearAlgebra.h"
Expand Down Expand Up @@ -50,9 +49,9 @@ GaussMarkov::~GaussMarkov()
{
}

/*! This method performs almost all of the work for the Gauss Markov random
walk. It uses the current random walk configuration, propagates the current
state, and then applies appropriate errors to the states to set the current
/*! This method performs almost all of the work for the Gauss Markov random
walk. It uses the current random walk configuration, propagates the current
state, and then applies appropriate errors to the states to set the current
error level.
@return void
*/
Expand All @@ -61,7 +60,7 @@ void GaussMarkov::computeNextState()
Eigen::VectorXd errorVector;
Eigen::VectorXd ranNums;
size_t i;

//! - Check for consistent sizes on all of the user-settable matrices. Quit if they don't match.
if((this->propMatrix.size() != this->noiseMatrix.size()) ||
((uint64_t) this->propMatrix.size() != this->numStates*this->numStates))
Expand All @@ -78,17 +77,17 @@ void GaussMarkov::computeNextState()
//! - Propagate the state forward in time using the propMatrix and the currentState
errorVector = this->currentState;
this->currentState = this->propMatrix * errorVector;

//! - Compute the random numbers used for each state. Note that the same generator is used for all
ranNums.resize((int64_t) this->numStates);

for(i = 0; i<this->numStates; i++)
{
ranNums[i] = this->rNum(rGen);
if (this->stateBounds[i] > 0.0){

double stateCalc = fabs(this->currentState[i]) > this->stateBounds[i]*1E-10 ? fabs(this->currentState[i]) : this->stateBounds[i];

double boundCheck = (this->stateBounds[i]*2.0 - stateCalc)/stateCalc;
boundCheck = boundCheck > this->stateBounds[i]*1E-10 ? boundCheck : this->stateBounds[i]*1E-10;
boundCheck = 1.0/exp(boundCheck*boundCheck*boundCheck);
Expand All @@ -104,4 +103,3 @@ void GaussMarkov::computeNextState()
this->currentState += errorVector;

}

8 changes: 3 additions & 5 deletions src/architecture/utilities/linearAlgebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "architecture/utilities/bsk_Print.h"

#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

Expand Down Expand Up @@ -836,7 +835,7 @@ void mLeastSquaresInverse(void *mx, size_t dim1, size_t dim2, void *result)
double mxTranspose[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];
double mxGrammian[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];
double mxGrammianInverse[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];

mTranspose(mx, dim1, dim2, mxTranspose);
mMultM(mxTranspose, dim2, dim1, mx, dim1, dim2, mxGrammian);
mInverse(mxGrammian, dim2, mxGrammianInverse);
Expand All @@ -854,7 +853,7 @@ void mMinimumNormInverse(void *mx, size_t dim1, size_t dim2, void *result)
double mxTranspose[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];
double mxMxTranspose[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];
double mxMxTransposeInverse[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];

mTranspose(m_mx, dim1, dim2, mxTranspose);
mMultM(m_mx, dim1, dim2, mxTranspose, dim2, dim1, mxMxTranspose);
mInverse(mxMxTranspose, dim1, mxMxTransposeInverse);
Expand Down Expand Up @@ -1287,7 +1286,7 @@ int mInverse(void *mx, size_t dim, void *result)
{
BSK_PRINT(MSG_ERROR,"Linear Algegra library array dimension input is too large.");
}

if(fabs(det) > DB0_EPS) {
/* Find adjoint matrix */
double m_adjoint[LINEAR_ALGEBRA_MAX_ARRAY_SIZE];
Expand Down Expand Up @@ -2699,4 +2698,3 @@ double safeSqrt(double x) {
return 0.0;
return sqrt(x);
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
#include "moduleIdGenerator.h"
#include <cstring>
#include <stdio.h>

/*!
Expand Down
3 changes: 1 addition & 2 deletions src/architecture/utilities/orbitalMotion.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "linearAlgebra.h"
#include "astroConstants.h"
#include "architecture/utilities/bsk_Print.h"
#include "rigidBodyKinematics.h"


/*!
Expand Down Expand Up @@ -134,7 +133,7 @@ void rv2hill(double *rc_N, double *vc_N, double *rd_N, double *vd_N, double *
m33MultV3(HN, rhoDot_N, rhoDot_H);
v3Cross(omega_HN_H, rho_H, rhoPrime_H);
v3Subtract(rhoDot_H, rhoPrime_H, rhoPrime_H);

return;
}

Expand Down
5 changes: 1 addition & 4 deletions src/architecture/utilities/signalCondition.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

#include "architecture/utilities/signalCondition.h"

#include <math.h>
#include <stdio.h>
#include <stdarg.h>

/*! This method applies the low-pass filter configuration to the newMeas that
/*! This method applies the low-pass filter configuration to the newMeas that
is passed in. The state is maintained in the LowPassFilterData structure
@return void
@param lpData The configuration data and history of the LP filter
Expand Down
Loading

0 comments on commit e2f1e39

Please sign in to comment.