scenarioAttitudeConstrainedManeuver

Overview

This script sets up a 6-DOF spacecraft which is orbiting the Earth, in the presence of the Sun. The spacecraft is modelled according to the specifics of the Bevo-2 satellite, that has a sensitive star tracker aligned with the x body axis and two sun sensors aligned with the y and z body axes. In contrast with scenarioAttitudeConstraintViolation the goal of this scenario is to illustrate how to set up a Basilisk simulation using the C++ Module: constrainedAttitudeManeuver module to perform a slew maneuver while ensuring constraint compliance.

The script is found in the folder basilisk/examples and executed by using:

python3 scenarioAttitudeConstrainedManeuver.py

This simulation is set up identically to scenarioAttitudeConstraintViolation. The reader is referred to this scenario for a detailed description of the setup. The only difference in this scenario is that the constraint-naive C Module: inertial3D module for attitude pointing is replaced with the C++ Module: constrainedAttitudeManeuver module.

Illustration of Simulation Results

Each run of the script produces 6 figures. Figures 1-4 report, respectively, attitude error, RW motor torque, rate tracking error, and RW speed. These plots are only relevant to the spacecraft / RW dynamics. Figures 5 and 6 show the angle between the boresight vector of the star tracker and the Sun (fig. 5), and of the sun sensor(s) and the Sun (fig. 6). Each plot features a dashed line that represents an angular threshold for that specific instrument.

Each plot describes a slew maneuver performed from an initial inertial attitude \(\sigma_{\mathcal{B/N},i}\) to a final inertial attitude \(\sigma_{\mathcal{B/N},f}\). In scenarioAttitudeConstraintViolation, these sets of attitudes and constraints were chosen to highlight specific constraint violations. This scenario shows how, using C++ Module: constrainedAttitudeManeuver, the constraints are not violated.

show_plots = True, use2SunSensors = False, starTrackerFov = 20, sunSensorFov = 70, attitudeSetCase = 0

This case features the violation of the keep in constraint of the sun sensor only when C Module: inertial3D is used. Just for this case, only the sun sensor along the y body axis is considered. Now, the keep in constraint is not violated as the boresight angle never exceeds the 70 def field of view of the instrument.

../_images/scenarioAttitudeConstrainedManeuver5020700.svg ../_images/scenarioAttitudeConstrainedManeuver6020700.svg
show_plots = True, use2SunSensors = True, starTrackerFov = 20, sunSensorFov = 70, attitudeSetCase = 1

In this case, using C Module: inertial3D, both the sun sensor boresights exceed the respective thresholds. In this scenario, however, they do not.

../_images/scenarioAttitudeConstrainedManeuver5120701.svg ../_images/scenarioAttitudeConstrainedManeuver6120701.svg
show_plots = True, use2SunSensors = True, starTrackerFov = 20, sunSensorFov = 70, attitudeSetCase = 2

In this case, C Module: inertial3D violates the keep out constraint of the star tracker, alongside with the keep in constraints for both the sun sensors. The following simulation shows how all the constraints are respected.

../_images/scenarioAttitudeConstrainedManeuver5120702.svg ../_images/scenarioAttitudeConstrainedManeuver6120702.svg

Comparing Distance-Based Search Modes

An optional comparison uses attitude case 4, the alternate start from issue #1726, with one Sun sensor, a 20-degree star-tracker keep-out cone, and a 70-degree Sun-sensor keep-in cone:

figures, comparison = run(True, False, 20, 70, 4, compareSearchModes=True)

This case starts at \(\boldsymbol\sigma_{B/N} = [-3/7, -2/7, 0]\) and uses the same target as case 0. Both searches use costFcnType = 0 on an identical grid with refinement N = 8. The default distance heuristic runs first, followed by useShortestPath = True, which uses \(h = \theta/4\). The spacecraft and celestial-body states do not advance between the two plans. The subsequent dynamics simulation and figures 1–6 use the shortest-path reference. Those six figure names have a ShortestPath suffix, so saving both modes for the same attitude case preserves their separate results. Without compareSearchModes=True, the scenario retains its existing effort-based planning and returns only the figure dictionary.

The comparison adds an MRP waypoint overlay and a table of accumulated MRP edge distance and expanded nodes. The table evaluates the planner’s shadow-aware edge metric, rather than the length of the plotted polyline or pathCost (fitted control effort). For this case the grid distance decreases from approximately 1.19731 to 1.13077, a 5.6 percent reduction, with more search work.

../_images/scenarioAttitudeConstrainedManeuverSearchPaths020704.svg ../_images/scenarioAttitudeConstrainedManeuverSearchComparison020704.svg

The overlay maps waypoints into the unit MRP sphere. Lines across shadow switches are omitted, and square markers identify their endpoints; these coordinate jumps are not physical rotations through the sphere. The paths connect discrete grid waypoints and do not depict the fitted reference. Shortest-path optimality applies to accumulated grid edge distance, not control effort or continuous cone clearance. Use the existing boresight-angle plots to assess the simulated maneuver.

comparison contains default and shortest entries, each with the original waypoints, edgeDistance (dimensionless), and expandedNodeCount. The native module tests validate shortest-path costs against an independent Dijkstra search; the example illustrates the resulting path and search-work differences.

scenarioAttitudeConstrainedManeuver.plot_attitude_error(timeData, dataSigmaBR)[source]

Plot the attitude errors.

scenarioAttitudeConstrainedManeuver.plot_rate_error(timeData, dataOmegaBR)[source]

Plot the body angular velocity rate tracking errors.

scenarioAttitudeConstrainedManeuver.plot_rw_cmd_torque(timeData, dataUsReq, numRW)[source]

Plot the RW command torques.

scenarioAttitudeConstrainedManeuver.plot_rw_motor_torque(timeData, dataUsReq, dataRW, numRW)[source]

Plot the RW actual motor torques.

scenarioAttitudeConstrainedManeuver.plot_rw_speeds(timeData, dataOmegaRW, numRW)[source]

Plot the RW spin rates.

scenarioAttitudeConstrainedManeuver.plot_search_comparison(comparison, refinement)[source]

Tabulate actual grid distance and node expansions for the two searches.

scenarioAttitudeConstrainedManeuver.plot_search_paths(comparison)[source]

Overlay the grid paths inside the unit MRP sphere, omitting shadow-switch edges.

scenarioAttitudeConstrainedManeuver.plot_ss_miss_angle(timeData, dataMissAngle, Fov)[source]

Plot the miss angle between sun sensor(s) boresight and Sun.

scenarioAttitudeConstrainedManeuver.plot_st_miss_angle(timeData, dataMissAngle, Fov)[source]

Plot the miss angle between star tacker boresight and Sun.

scenarioAttitudeConstrainedManeuver.run(show_plots, use2SunSensors, starTrackerFov, sunSensorFov, attitudeSetCase, *, compareSearchModes=False)[source]

Simulate a constrained maneuver, optionally comparing distance-search modes.

Parameters:
  • show_plots – Whether to display the figures interactively.

  • use2SunSensors – Whether to include the second Sun sensor along body z.

  • starTrackerFov – Star-tracker keep-out half-angle in degrees.

  • sunSensorFov – Sun-sensor keep-in half-angle in degrees.

  • attitudeSetCase – Attitude pair index; case 4 is the alternate-start comparison.

  • compareSearchModes – Compare both distance searches, then simulate the shortest path.

Returns:

Figure dictionary, or (figures, comparison) when comparing search modes.