Skip to content

Commit

Permalink
[squash] update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-g-bonilla committed Sep 8, 2023
1 parent a85d94c commit cba2952
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 34 deletions.
1 change: 0 additions & 1 deletion examples/scenarioLagrangePointOrbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def run(lagrangePoint, nOrbits, timestep, showPlots=True):
gravFactory = simIncludeGravBody.gravBodyFactory()
gravBodies = gravFactory.createBodies(['moon', 'earth'])
gravBodies['earth'].isCentralBody = True
# Necessary to specify useSphericalHarmParams for Earth or Moon, and then load parameters from file?

# Add gravity bodies to the spacecraft dynamics
scObject.gravField.gravBodies = spacecraft.GravBodyVector(list(gravFactory.gravBodies.values()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def massDepletionTest(show_plots, thrusterType):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down Expand Up @@ -292,7 +291,6 @@ def axisChangeHelper(r_BcB_B):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def hingedRigidBodyGravity(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False
scObject.primaryCentralSpacecraft.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

# Log the spacecraft state message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def fuelSloshTest(show_plots,useFlag,testCase):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])
scObject.hub.r_CN_NInit = [[-4020338.690396649], [7490566.741852513], [5248299.211589362]]
scObject.hub.v_CN_NInit = [[-5199.77710904224], [-3436.681645356935], [1041.576797498721]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def nHingedRigidBody(show_plots, testCase):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])
scObject.hub.r_CN_NInit = [[-4020338.690396649], [7490566.741852513], [5248299.211589362]]
scObject.hub.v_CN_NInit = [[-5199.77710904224], [-3436.681645356935], [1041.576797498721]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def thrusterIntegratedTest(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def VSCMGIntegratedTest(show_plots,useFlag,testCase):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Each gravity body data object can be created using::
earth.mu = 0.3986004415E+15 # meters^3/s^2
earth.radEquator = 6378136.6 # meters
earth.isCentralBody = False
earth.useSphericalHarmParams = False

Note that the ``simIncludeGradBody.py`` helper file contains a gravity body factor class to facilitate
setting up gravity bodies.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def dualHingedRigidBodyTest(show_plots, useFlag, testCase):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])
scObject.hub.r_CN_NInit = [[-4020338.690396649], [7490566.741852513], [5248299.211589362]]
scObject.hub.v_CN_NInit = [[-5199.77710904224], [-3436.681645356935], [1041.576797498721]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def extForceBodyAndTorque():
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down Expand Up @@ -165,7 +164,6 @@ def extForceInertialAndTorque():
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ def singleGravityBody(show_plots):
gravBody1 = gravityEffector.GravBodyData()
gravBody1.planetName = "earth_planet_data"
gravBody1.isCentralBody = False
gravBody1.useSphericalHarmParams = True
gravityEffector.loadGravFromFile(path + '/GGM03S.txt', gravBody1.spherHarm, 60)
gravBody1.useSphericalHarmonicsGravityModel(path + '/GGM03S.txt', 60)
gravBody1.planetBodyInMsg.subscribeTo(SpiceObject.planetStateOutMsgs[0])

# Use the python spice utility to load in spacecraft SPICE ephemeris data
Expand Down Expand Up @@ -481,7 +480,6 @@ def multiBodyGravity(show_plots):
gravBody1.mu = 1000000.
gravBody1.radEquator = 6500.
gravBody1.isCentralBody = False
gravBody1.useSphericalHarmParams = False
gravBody1.localPlanet = localPlanetEditor

#This is the gravityEffector which will actually compute the gravitational acceleration
Expand All @@ -505,7 +503,6 @@ def multiBodyGravity(show_plots):
gravBody2.mu = gravBody1.mu/2.
gravBody2.radEquator = 6500.
gravBody2.isCentralBody = False
gravBody2.useSphericalHarmParams = False
gravBody2.localPlanet = localPlanetEditor

#This is the gravityEffector which will actually compute the gravitational acceleration
Expand All @@ -525,7 +522,6 @@ def multiBodyGravity(show_plots):
gravBody3.mu = gravBody2.mu
gravBody3.radEquator = 6500.
gravBody3.isCentralBody = False
gravBody3.useSphericalHarmParams = False
gravBody3.localPlanet = localPlanetEditor

#This is the gravityEffector which will actually compute the gravitational acceleration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def singleGravityBody(show_plots):
gravFactory = simIncludeGravBody.gravBodyFactory()
gravBodies = gravFactory.createBodies(['earth', 'sun', 'moon', 'jupiter barycenter'])
gravBodies['earth'].isCentralBody = True
gravBodies['earth'].useSphericalHarmParams = True
simIncludeGravBody.loadGravFromFile(path + '/../_UnitTest/GGM03S.txt'
, gravBodies['earth'].spherHarm
gravBodies['earth'].useSphericalHarmonicsGravityModel(path + '/../_UnitTest/GGM03S.txt'
, 40
)
stringCurrent = "2016 MAY 1 00:32:30.0"
Expand Down Expand Up @@ -369,8 +367,7 @@ def polyGravityBody(show_plots):
gravFactory = simIncludeGravBody.gravBodyFactory()
polyBody = gravFactory.createCustomGravObject('eros', mu=mu)
polyBody.isCentralBody = True
polyBody.usePolyhedral = True
simIncludeGravBody.loadPolyFromFile(path + '/../_UnitTest/EROS856Vert1708Fac.txt', polyBody.poly)
polyBody.usePolyhedralGravityModel(path + '/../_UnitTest/EROS856Vert1708Fac.txt')
polyBody.planetBodyInMsg.subscribeTo(polyBodyEphem.planetOutMsgs[0])

# create an ephemeris converter
Expand Down
22 changes: 22 additions & 0 deletions src/simulation/dynamics/gravityEffector/gravityEffector.i
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ from Basilisk.simulation.pointMassGravityModel import PointMassGravityModel
from Basilisk.simulation.polyhedralGravityModel import PolyhedralGravityModel
from Basilisk.simulation.sphericalHarmonicsGravityModel import SphericalHarmonicsGravityModel

from Basilisk.utilities import deprecated

Polyhedral = PolyhedralGravityModel
SphericalHarmonics = SphericalHarmonicsGravityModel

Expand Down Expand Up @@ -101,6 +103,16 @@ struct SpicePlanetStateMsg_C;

@useSphericalHarmParams.setter
def useSphericalHarmParams(self, value: bool):
deprecated.deprecationWarn(
GravBodyData.useSphericalHarmParams.__qualname__,
"2024/09/07",
"Using 'useSphericalHarmParams = True/False' to turn on/off the spherical harmonics"
" is deprecated. Prefer the following syntax:\n"
"\tplanet.useSphericalHarmonicsGravityModel('GGM2BData.txt', 100)\n"
"Over:\n"
"\tplanet.useSphericalHarmParams = True\n"
"\tsimIncludeGravBody.loadGravFromFile('GGM2BData.txt', planet.spherHarm, 100)"
)
if self.useSphericalHarmParams and not value:
self.gravityModel = PointMassGravityModel()
elif not self.useSphericalHarmParams and value:
Expand All @@ -112,6 +124,16 @@ struct SpicePlanetStateMsg_C;

@usePolyhedral.setter
def usePolyhedral(self, value: bool):
deprecated.deprecationWarn(
GravBodyData.usePolyhedral.__qualname__,
"2024/09/07",
"Using 'usePolyhedral = True/False' to turn on/off the polyhedral model"
" is deprecated. Prefer the following syntax:\n"
"\tplanet.usePolyhedralGravityModel('eros.txt')\n"
"Over:\n"
"\tplanet.usePolyhedral = True\n"
"\tsimIncludeGravBody.loadPolyFromFile('eros.txt', planet.poly)"
)
if self.usePolyhedral and not value:
self.gravityModel = PointMassGravityModel()
elif not self.usePolyhedral and value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def PrescribedMotionTestFunction(show_plots, rotTest, thetaInit, theta_Ref, posI
earthGravBody.planetName = "earth_planet_data"
earthGravBody.mu = 0.3986004415E+15
earthGravBody.isCentralBody = True
earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([earthGravBody])

# Add energy and momentum variables to log
Expand Down Expand Up @@ -442,7 +441,6 @@ def PrescribedMotionTestFunction(show_plots, rotTest, thetaInit, theta_Ref, posI
earthGravBody.planetName = "earth_planet_data"
earthGravBody.mu = 0.3986004415E+15
earthGravBody.isCentralBody = True
earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([earthGravBody])

# Add energy and momentum variables to log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def reactionWheelIntegratedTest(show_plots,useFlag,testCase):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def SCTranslation(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down Expand Up @@ -230,7 +229,6 @@ def SCTransAndRotation(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scObject.gravField.gravBodies = spacecraft.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def SCConnected(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scSystem.primaryCentralSpacecraft.gravField.gravBodies = spacecraftSystem.GravBodyVector([unitTestSim.earthGravBody])

Expand Down Expand Up @@ -389,7 +388,6 @@ def SCConnectedAndUnconnected(show_plots):
unitTestSim.earthGravBody.planetName = "earth_planet_data"
unitTestSim.earthGravBody.mu = 0.3986004415E+15 # meters!
unitTestSim.earthGravBody.isCentralBody = True
unitTestSim.earthGravBody.useSphericalHarmParams = False

scSystem.primaryCentralSpacecraft.gravField.gravBodies = spacecraftSystem.GravBodyVector([unitTestSim.earthGravBody])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def spinningBody(show_plots, cmdTorque, lock):
earthGravBody.planetName = "earth_planet_data"
earthGravBody.mu = 0.3986004415E+15 # meters!
earthGravBody.isCentralBody = True
earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([earthGravBody])

# Log the spacecraft state message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def spinningBody(show_plots, cmdTorque1, lock1, cmdTorque2, lock2):
earthGravBody.planetName = "earth_planet_data"
earthGravBody.mu = 0.3986004415E+15 # meters!
earthGravBody.isCentralBody = True
earthGravBody.useSphericalHarmParams = False
scObject.gravField.gravBodies = spacecraft.GravBodyVector([earthGravBody])

# Log the spacecraft state message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def myCreationFunction():
gravFactory = simIncludeGravBody.gravBodyFactory()
planet = gravFactory.createEarth()
planet.isCentralBody = True
planet.useSphericalHarmParams = True
simIncludeGravBody.loadGravFromFile(bskPath + '/supportData/LocalGravData/GGM03S-J2-only.txt'
, planet.spherHarm
planet.useSphericalHarmonicsGravityModel(bskPath + '/supportData/LocalGravData/GGM03S-J2-only.txt'
, 2
)
scObject.gravField.gravBodies = spacecraft.GravBodyVector([planet])
Expand Down

0 comments on commit cba2952

Please sign in to comment.