Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set _use_math_macro in compiler for windows #679

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/Support/bskReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Version |release|
- Uncaught exceptions raised in Python modules are now printed to ``stderr`` before the program is terminated.
- Added a new N-axis spinning effector :ref:`spinningBodyNDOFStateEffector`. This is an expansion of :ref:`spinningBodyOneDOFStateEffector`
and :ref:`spinningBodyTwoDOFStateEffector` to any number of degrees of freedom.
- Update the Windows build to automatically include the Math library defines. This avoids having
to include them in BSK source code files individually.


Version 2.3.0 (April 5, 2024)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ endif()
if(MSVC)
set(CMAKE_CXX_STANDARD 17)
add_definitions(/MP)
add_definitions(/D _USE_MATH_DEFINES)
add_definitions(/D _CRT_SECURE_NO_WARNINGS)
add_definitions(/D _WINSOCK_DEPRECATED_NO_WARNINGS)
add_definitions(/D _WIN32_WINNT=0x0501) # Targets Windows xp
Expand Down
3 changes: 0 additions & 3 deletions src/architecture/utilities/astroConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#ifndef _ASTRO_CONSTANTS_H_
#define _ASTRO_CONSTANTS_H_

#ifdef _WIN32
#define _USE_MATH_DEFINES
#endif
#include <math.h>

#ifndef G_UNIVERSIAL
Expand Down
4 changes: 0 additions & 4 deletions src/architecture/utilities/geodeticConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef _GEODETIC_CONV_H_
#define _GEODETIC_CONV_H_

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif

#include <math.h>
#include <Eigen/Dense>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
#include <string.h>

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif

#include <math.h>
#include "fswAlgorithms/attGuidance/celestialTwoBodyPoint/celestialTwoBodyPoint.h"
Expand All @@ -40,7 +37,7 @@ void SelfInit_celestialTwoBodyPoint(celestialTwoBodyPointConfig *configData,
{
AttRefMsg_C_init(&configData->attRefOutMsg);
return;

}


Expand Down Expand Up @@ -94,7 +91,7 @@ void parseInputMessages(celestialTwoBodyPointConfig *configData, int64_t moduleI

double R_P1B_N_hat[3]; /* Unit vector in the direction of r_P1 */
double R_P2B_N_hat[3]; /* Unit vector in the direction of r_P2 */

double platAngDiff; /* Angle between r_P1 and r_P2 */
double dotProduct; /* Temporary scalar variable */

Expand All @@ -105,7 +102,7 @@ void parseInputMessages(celestialTwoBodyPointConfig *configData, int64_t moduleI

v3Subtract(primPlanet.r_BdyZero_N, navData.r_BN_N, configData->R_P1B_N);
v3Subtract(primPlanet.v_BdyZero_N, navData.v_BN_N, configData->v_P1B_N);

v3SetZero(configData->a_P1B_N); /* accelerations of s/c relative to planets set to zero*/
v3SetZero(configData->a_P2B_N);

Expand All @@ -121,7 +118,7 @@ void parseInputMessages(celestialTwoBodyPointConfig *configData, int64_t moduleI
dotProduct = v3Dot(R_P2B_N_hat, R_P1B_N_hat);
platAngDiff = safeAcos(dotProduct);
}

/*! - Cross the P1 states to get R_P2, v_p2 and a_P2 */
if(!configData->secCelBodyIsLinked ||
fabs(platAngDiff) < configData->singularityThresh ||
Expand Down Expand Up @@ -152,34 +149,34 @@ void computeCelestialTwoBodyPoint(celestialTwoBodyPointConfig *configData, uint6
double temp33[3][3]; /* Temporary 3x3 matrix */
double temp33_1[3][3]; /* Temporary 3x3 matrix 1 */
double temp33_2[3][3]; /* Temporary 3x3 matrix 2 */

double R_N[3]; /* Normal vector of the plane defined by R_P1 and R_P2 */
double v_N[3]; /* First time-derivative of R_n */
double a_N[3]; /* Second time-derivative of R_n */

double dcm_RN[3][3]; /* DCM that maps from Reference frame to the inertial */
double r1_hat[3]; /* 1st row vector of RN */
double r2_hat[3]; /* 2nd row vector of RN */
double r3_hat[3]; /* 3rd row vector of RN */

double dr1_hat[3]; /* r1_hat first time-derivative */
double dr2_hat[3]; /* r2_hat first time-derivative */
double dr3_hat[3]; /* r3_hat first time-derivative */
double I_33[3][3]; /* Identity 3x3 matrix */
double C1[3][3]; /* DCM used in the computation of rates and acceleration */
double C3[3][3]; /* DCM used in the computation of rates and acceleration */

double omega_RN_R[3]; /* Angular rate of the reference frame
wrt the inertial in ref R-frame components */
double domega_RN_R[3]; /* Angular acceleration of the reference frame
wrt the inertial in ref R-frame components */

double ddr1_hat[3]; /* r1_hat second time-derivative */
double ddr2_hat[3]; /* r2_hat second time-derivative */
double ddr3_hat[3]; /* r3_hat second time-derivative */

configData->attRefOut = AttRefMsg_C_zeroMsgPayload();

/* - Initial computations: R_n, v_n, a_n */
v3Cross(configData->R_P1B_N, configData->R_P2B_N, R_N);
v3Cross(configData->v_P1B_N, configData->R_P2B_N, temp3_1);
Expand All @@ -191,7 +188,7 @@ void computeCelestialTwoBodyPoint(celestialTwoBodyPointConfig *configData, uint6
v3Cross(configData->v_P1B_N, configData->v_P2B_N, temp3);
v3Scale(2.0, temp3, temp3);
v3Add(temp3, temp3_3, a_N); /*Eq 5*/

/* - Reference Frame computation */
v3Normalize(configData->R_P1B_N, r1_hat); /* Eq 9a*/
v3Normalize(R_N, r3_hat); /* Eq 9c */
Expand All @@ -201,30 +198,30 @@ void computeCelestialTwoBodyPoint(celestialTwoBodyPointConfig *configData, uint6
v3Copy(r2_hat, dcm_RN[1]);
v3Copy(r3_hat, dcm_RN[2]);
C2MRP(dcm_RN, configData->attRefOut.sigma_RN);

/* - Reference base-vectors first time-derivative */
m33SetIdentity(I_33);

v3OuterProduct(r1_hat, r1_hat, temp33);
m33Subtract(I_33, temp33, C1);
m33MultV3(C1, configData->v_P1B_N, temp3);
v3Scale(1.0 / v3Norm(configData->R_P1B_N), temp3, dr1_hat); /* Eq 11a*/

v3OuterProduct(r3_hat, r3_hat, temp33);
m33Subtract(I_33, temp33, C3);
m33MultV3(C3, v_N, temp3);
v3Scale(1.0 / v3Norm(R_N), temp3, dr3_hat); /* Eq 11b*/

v3Cross(dr3_hat, r1_hat, temp3_1);
v3Cross(r3_hat, dr1_hat, temp3_2);
v3Add(temp3_1, temp3_2, dr2_hat); /* Eq 11c*/

/* - Angular velocity computation */
omega_RN_R[0] = v3Dot(r3_hat, dr2_hat);
omega_RN_R[1]= v3Dot(r1_hat, dr3_hat);
omega_RN_R[2] = v3Dot(r2_hat, dr1_hat);
m33tMultV3(dcm_RN, omega_RN_R, configData->attRefOut.omega_RN_N);

/* - Reference base-vectors second time-derivative */
m33MultV3(C1, configData->a_P1B_N, temp3_1);
v3OuterProduct(dr1_hat, r1_hat, temp33_1);
Expand All @@ -234,7 +231,7 @@ void computeCelestialTwoBodyPoint(celestialTwoBodyPointConfig *configData, uint6
m33MultV3(temp33, configData->v_P1B_N, temp3_2);
v3Subtract(temp3_1, temp3_2, temp3);
v3Scale(1.0 / v3Norm(configData->R_P1B_N), temp3, ddr1_hat); /* Eq 13a*/

m33MultV3(C3, a_N, temp3_1);
v3OuterProduct(dr3_hat, r3_hat, temp33_1);
m33Scale(2.0, temp33_1, temp33_1);
Expand All @@ -243,20 +240,19 @@ void computeCelestialTwoBodyPoint(celestialTwoBodyPointConfig *configData, uint6
m33MultV3(temp33, v_N, temp3_2);
v3Subtract(temp3_1, temp3_2, temp3);
v3Scale(1.0 / v3Norm(R_N), temp3, ddr3_hat); /* Eq 13b*/

v3Cross(ddr3_hat, r1_hat, temp3_1);
v3Cross(r3_hat, ddr1_hat, temp3_2);
v3Add(temp3_1, temp3_2, temp3_3);
v3Cross(dr3_hat, dr1_hat, temp3);
v3Scale(2.0, temp3, temp3);
v3Add(temp3, temp3_3, ddr2_hat); /* Eq 13c*/

/* - Angular acceleration computation */
domega_RN_R[0] = v3Dot(dr3_hat, dr2_hat) + v3Dot(r3_hat, ddr2_hat) - v3Dot(omega_RN_R, dr1_hat);
domega_RN_R[1] = v3Dot(dr1_hat, dr3_hat) + v3Dot(r1_hat, ddr3_hat) - v3Dot(omega_RN_R, dr2_hat);
domega_RN_R[2] = v3Dot(dr2_hat, dr1_hat) + v3Dot(r2_hat, ddr1_hat) - v3Dot(omega_RN_R, dr3_hat);
m33tMultV3(dcm_RN, domega_RN_R, configData->attRefOut.domega_RN_N);

return;
}

5 changes: 0 additions & 5 deletions src/simulation/dynamics/FuelTank/fuelTank.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif

#ifndef FUEL_TANK_H
#define FUEL_TANK_H

Expand Down
Loading
Loading