|
50 | 50 | from Basilisk.architecture import messaging |
51 | 51 | from Basilisk.simulation import coarseSunSensor |
52 | 52 | from Basilisk.simulation import mujoco |
53 | | -from Basilisk.simulation import NBodyGravity |
54 | | -from Basilisk.simulation import pointMassGravityModel |
55 | 53 | from Basilisk.simulation import spacecraft |
56 | 54 | from Basilisk.simulation import StatefulSysModel |
57 | 55 | from Basilisk.simulation import svIntegrators |
@@ -197,29 +195,6 @@ def setStowed(scene, panelIds, bodyPrefix): |
197 | 195 | ).setPosition(JOINT_START_END[i - 1][0]) |
198 | 196 |
|
199 | 197 |
|
200 | | -def addOrbitalGravity(scene, mu, modelCache): |
201 | | - """Apply central-body point-mass gravity to every body in ``scene``. |
202 | | -
|
203 | | - Uses :ref:`NBodyGravity` with one gravity target per body (hub plus each |
204 | | - deployable panel), so the field is evaluated and applied at each body's true |
205 | | - center of mass. The whole structure is then in physical orbital freefall — |
206 | | - the appendages are weightless — while the gravity gradient across it is |
207 | | - captured. |
208 | | - """ |
209 | | - gravity = NBodyGravity.NBodyGravity() |
210 | | - gravity.ModelTag = f"{scene.ModelTag}_gravity" |
211 | | - scene.AddModelToDynamicsTask(gravity) |
212 | | - |
213 | | - gravityModel = pointMassGravityModel.PointMassGravityModel() |
214 | | - gravityModel.muBody = mu |
215 | | - gravity.addGravitySource("earth", gravityModel, True) |
216 | | - for name in scene.getBodyNames(): |
217 | | - gravity.addGravityTarget(name, scene.getBody(name)) |
218 | | - |
219 | | - modelCache.extend([gravity, gravityModel]) |
220 | | - return gravity |
221 | | - |
222 | | - |
223 | 198 | # Main scenario |
224 | 199 | def run(showPlots: bool = False): |
225 | 200 | scSim = SimulationBaseClass.SimBaseClass() |
@@ -264,11 +239,16 @@ def run(showPlots: bool = False): |
264 | 239 | epochInMsg=True, |
265 | 240 | ) |
266 | 241 | spiceObject.zeroBase = "Earth" |
267 | | - scSim.AddModelToTask("simTask", spiceObject) |
268 | 242 |
|
269 | | - # vizSupport dedupes planets by name across scenes. |
270 | | - primaryScene._vizGravBodies = gravFactory.gravBodies |
271 | | - companionScene._vizGravBodies = gravFactory.gravBodies |
| 243 | + # MuJoCo gravity is evaluated at every integrator substep. Run SPICE after |
| 244 | + # the scene's high-priority forward kinematics and before gravity (default |
| 245 | + # priority -1), so every gravity evaluation reads current ephemerides. |
| 246 | + spiceDynamicsPriority = 75 |
| 247 | + primaryScene.AddModelToDynamicsTask(spiceObject, spiceDynamicsPriority) |
| 248 | + companionScene.AddModelToDynamicsTask(spiceObject, spiceDynamicsPriority) |
| 249 | + |
| 250 | + # The regular spacecraft below also needs SPICE at the top-level task rate. |
| 251 | + scSim.AddModelToTask("simTask", spiceObject) |
272 | 252 |
|
273 | 253 | # Trailer is a regular Basilisk Spacecraft, behind the primary along-track. |
274 | 254 | # Uses ``gravFactory.addBodiesTo`` for the standard gravField wiring. |
@@ -301,13 +281,13 @@ def run(showPlots: bool = False): |
301 | 281 | addDeployment(companionScene, companionPanels, "companion_panel", models) |
302 | 282 |
|
303 | 283 | # Gravity setup. Each MJScene gets its own NBodyGravity model that applies |
304 | | - # central-body gravity as a force at every body's center of mass (hub plus |
305 | | - # each panel), preserving the gravity gradient across the structure. |
| 284 | + # the factory's Earth, Moon, and Sun gravity sources at every body's center |
| 285 | + # of mass, preserving the gravity gradient across each structure. |
306 | 286 | hubBody = primaryScene.getBody("hub") |
307 | 287 | companionBody = companionScene.getBody("companion_hub") |
308 | 288 |
|
309 | | - addOrbitalGravity(primaryScene, mu, models) |
310 | | - addOrbitalGravity(companionScene, mu, models) |
| 289 | + gravFactory.addBodiesTo(primaryScene) |
| 290 | + gravFactory.addBodiesTo(companionScene) |
311 | 291 |
|
312 | 292 | # CSS sensors mounted on the primary hub. The MJScene body's origin state |
313 | 293 | # message subscribes the same way a regular Spacecraft body state message |
|
0 commit comments