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

Vizard 2.2.1 Support #894

Merged
merged 19 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def requirements(self):
self.requires("opencv/4.5.5")

if self.options.get_safe("vizInterface") or self.options.get_safe("opNav"):
self.requires("protobuf/3.21.12")
self.requires("protobuf/3.21.12") # For compatibility with openCV
self.requires("cppzmq/4.5.0")

def configure(self):
Expand Down
2 changes: 2 additions & 0 deletions docs/source/Support/bskReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Version |release|
- Name change warning added to module documentation for the ``imuSensor`` ``walkBounds`` attribute to ``errorBounds``
and a note on specifying sensor properties in :ref:`scenarioGaussMarkovRandomWalk`.
- Update :ref:`makingModules-2` on how to make messages available to Basilisk modules
- Support for Vizard release 2.2.1, including rotating frame settings and documentation for support of ``.glb`` shape files
- ``vizProtobuffer`` upgraded to use latest C++ compiler, ``protobuf`` Python/C++ library upgraded


Version 2.5.0 (Sept. 30, 2024)
Expand Down
6 changes: 6 additions & 0 deletions docs/source/Vizard/VizardDownload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ Download the platform specific bundles file, unzip it, and move the contents to
- :download:`macOS<https://hanspeterschaub.info/bskFiles/Assets/martianmoons_macOS.zip>`
- :download:`Linux<https://hanspeterschaub.info/bskFiles/Assets/martianmoons_Linux.zip>`
- :download:`Windows<https://hanspeterschaub.info/bskFiles/Assets/martianmoons_Windows.zip>`
* - :ref:`assetIceSat2_Kepler`
- Package including models for spacecraft IceSat2 and Kepler
- :download:`macOS<https://hanspeterschaub.info/bskFiles/Assets/IceSat2_Kepler_macOS.zip>`
- :download:`Linux<https://hanspeterschaub.info/bskFiles/Assets/IceSat2_Kepler_Linux.zip>`
- :download:`Windows<https://hanspeterschaub.info/bskFiles/Assets/IceSat2_Kepler_Windows.zip>`

.. toctree::
:hidden:

assetAsteroids
assetMartianMoons
assetIceSat2_Kepler
59 changes: 48 additions & 11 deletions docs/source/Vizard/VizardGUI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,56 @@ inside a sub-folder ``VizardData`` inside the user's home directory.

``View`` Menu Item
------------------
The ``View`` menu tab contains a range of Vizard options. A range of coordinate frames can be toggled on or off.
The ``View`` menu tab contains a range of Vizard options.

Coordinate Frames
^^^^^^^^^^^^^^^^^
A range of coordinate frames can be toggled on or off, including ``Camera Target CS``, ``All Spacecraft CS``, ``All Effector CS``, ``All Planet/Moon CS``, ``Hill Frame`` and ``Velocity Frame``.

.. image:: ../_images/static/vizard-imgAxes.jpg
:align: center
:width: 90 %

Orbit Lines
^^^^^^^^^^^
Both ``Osculating Orbit Lines`` and ``True Trajectory Lines`` can be shown in a variety of frames as described below. Example scenarios highlight different orbit line view settings.

Osculating Orbit Lines
~~~~~~~~~~~~~~~~~~~~~~
The osculating orbit is the instantaneous Keplerian orbit disregarding perturbations. These lines can be shown in the following modes:

- ``Celestial Body Relative Inertial`` (default). The relative celestial body is the parent by default, but can be changed through the ``Set Celestial Body (Relative Inertial)`` menu item.
- ``Spacecraft Relative``. This mode is available in scenarios with multiple spacecraft. The relative orbit chief is selected based on the camera target, but can be changed manually through the ``Set Spacecraft Relative Orbit Chief`` menu item.

True Trajectory Lines
~~~~~~~~~~~~~~~~~~~~~
The true trajectory lines can be shown in the following modes:

- Un-corrected Inertial (default). Inertial trajectories shown with respect to the solar system origin.
- ``Celestial Body Relative Inertial``. The relative celestial body is the parent by default, but can be changed through the ``Set Celestial Body (Relative Inertial)`` menu item. This view mode is highlighted in :ref:`scenarioOrbitManeuver` as shown below.

.. image:: ../_images/static/vizard-bodyInertialFrame.jpg
:align: center
:width: 50 %

- ``Spacecraft Relative``. This mode is available in scenarios with multiple spacecraft. The relative orbit chief is selected based on the camera target, but can be changed manually through the ``Set Spacecraft Relative Orbit Chief`` menu item. These can be expressed in the Hill frame, velocity frame, or inertial frame of the chief. This view mode is highlighted in :ref:`scenarioDataToViz` as shown below.

.. image:: ../_images/static/vizard-scRelative.jpg
:align: center
:width: 50 %

- ``Two-Body Rotating Frame``. In scenarios with two celestial bodies, the primary is selected to be the larger of the two, per 3-body problem convention. In scenarios with more than two celestial bodies, the bodies must be manually selected using through the ``Set Rotating Frame Celestial Bodies`` menu item. This view mode is highlighted in :ref:`scenarioHaloOrbit` as shown below.

.. image:: ../_images/static/vizard-rotatingFrame.jpg
:align: center
:width: 50 %

- ``Body-Fixed Frame``. The primary celestial body is default, but can be changed through the ``Set Body-Fixed Frame Body`` menu item. This view mode is highlighted in :ref:`scenarioAsteroidArrival` as shown below.

.. image:: ../_images/static/vizard-fixedFrame.jpg
:align: center
:width: 50 %


Edit Pointing Vector
^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -259,20 +303,14 @@ as a PNG image within the user's home directory.

Import a Custom Shape Model
---------------------------
When Vizard starts up it represents the spacecraft using a default CAD model called ``bsk-Sat``. The following section illustrates how this default spacecraft model can be replaced with with a custom CAD model in an ``.obj`` file format, or by using a built-in shape primitive.

.. image:: ../_images/static/vizard-ImgCAD-1.jpg
:align: center
:width: 90 %

Vizard starts up showing a default spacecraft shape. To select a different shape, a custom CAD model can be imported using the OBJ file format. Go to the ``File`` menu and select ``Import OBJ Model``:
When Vizard starts up it represents the spacecraft using a default CAD model called ``bsk-Sat``. This default spacecraft model can be replaced with with a custom CAD model in an ``.obj`` or ``.glb`` file format, or by using a built-in shape primitive. Go to the ``File`` menu and select ``Import Model``:


.. image:: ../_images/static/vizard-ImgCAD-2.jpg
:align: center
:width: 90 %

Next, select the OBJ file that is to be imported into Vizard.
Next, select the file that is to be imported into Vizard.


.. image:: ../_images/static/vizard-ImgCAD-3.jpg
Expand All @@ -293,8 +331,7 @@ configured to script this OBJ import process as illustrated in :ref:`vizardSetti

At this point a panel appears that allows you select the object for which you want to apply a new
shape, and what shape you want to apply. When ready, press `Apply Models to Selected Objects` to
apply the custom space object shape. Note that instead of an OBJ file a custom shape can also be
selected such as a sphere, cylinder or cube.
apply the custom space object shape. Note that instead of an ``.obj`` or ``.glb`` file a custom shape can also be selected such as a sphere, cylinder or cube.

.. image:: ../_images/static/vizard-ImgCAD-5.jpg
:align: center
Expand Down
16 changes: 16 additions & 0 deletions docs/source/Vizard/VizardReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ Release Notes
- Continue to refine and improve the interactive information panels
- Save streamed data to file to avoid unbounded memory usage when viewing live data

**Version 2.2.1 (January 13, 2025)**

- Added support for loading .glb model files at runtime using the Import Model GUI Panel or using the custom model import VizMessage
- Added ability to plot each spacecraft’s true path trajectory relative to a parent body (default), another body selected by user, or relative to the origin of the inertial frame (old default), user can select how to plot the true path trajectory with an option button in the View menu
- Added ability to visualize true path trajectory in a two-body rotating frame, user can select which two celestial bodies make up the rotating frame under the View menu
- Added ability to plot each spacecraft’s true path trajectory in a selected spacecraft or celestial body’s fixed frame
- Revised True Path Trajectory settings and organization under View Menu to improve use and support added trajectory view settings
- Added support for the new True Path Trajectory view settings to VizMessage settings
- Added “Open Scenario File” button to File Menu to allow user to load a different playback file without quitting Vizard
- Added support for forcing any trainer selections in the View menu coordinate frames, osculating orbit lines, and true path trajectory lines to the broadcast viewers (trainees) when in ForcedSyncMode
- Pointing line vectors will increase their length when their source object is a large model to remain visible
- Reordered the View menu to put the chief selection button next to the orbit visualization toggles
- Bug fix: three-channel precision restored on depth map camera images
- Bug fix: protected against bad raycast call while loading obj at start that would cause app to freeze
- Added addressables for IceSat and Kepler satellites

**Version 2.2.0 (August 20, 2024)**

- Added VizEventDialog message type to VizMessage.proto. EventDialogs allow the user to create a GUI
Expand Down
32 changes: 32 additions & 0 deletions docs/source/Vizard/assetIceSat2_Kepler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. _assetIceSat2_Kepler:


IceSat2_Kepler
==============

The following models are available inside this bundle and can be applied in Vizard by using
the associated ModelKey.

.. note::

The ModelKeys are case sensitive.

.. list-table:: IceSat2 Kepler Asset Description
:widths: 20 20 10 30 20
:header-rows: 1

* - Model Description
- Model Key(s)
- Size
- Model Source
- Texture Source
* - IceSat2
- IceSat2
- 2.6MB
- https://nasa3d.arc.nasa.gov/models
- https://nasa3d.arc.nasa.gov/models
* - Kepler
- Kepler
- 855KB
- https://nasa3d.arc.nasa.gov/models
- https://nasa3d.arc.nasa.gov/models
2 changes: 2 additions & 0 deletions docs/source/Vizard/vizardAdvanced/vizardLiveComm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ The trainer has the option to force certain visual settings to the broadcast:
* - ``spacecraftCSon``
* - ``planetCSon``
* - ``showHillFrame``
* - ``showVelocityFrame``
* - ``truePathBodySetting``

See :ref:`vizardSettings` for types and descriptions of these variables.

Expand Down
28 changes: 16 additions & 12 deletions docs/source/Vizard/vizardAdvanced/vizardSettings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,20 @@ default setting for that behavior.
to use viz default, -1 for false, 1 for true
* - ``keyboardLiveInput``
- string
- string of alphanumeric key inputs to listen for during 2-way communication * - ``messageBufferSize``
- string of alphanumeric key inputs to listen for during 2-way communication
* - ``messageBufferSize``
- int
- [bytes] Maximum size of vizMessages to be loaded into memory at one time,
-1 to force loading of entire file into memory, 0 to use viz default
* - ``truePathRelativeBody``
- string
- String of the celestial body name to plot the true path trajectory line[s] against, empty string to use the spacecraft's primary body
* - ``truePathRotatingFrame``
- string
- String must contain the names of two distinct celestial bodies, separated by a space, to define the desired rotating frame for plotting true path trajectories
* - ``truePathFixedFrame``
- string
- String of the spacecraft or celestial body name whose rotation matrix will provide the fixed frame to plot the true path trajectory against


While the prior settings are only read once during start up, the following settings are checked
Expand Down Expand Up @@ -698,37 +707,32 @@ whose precision is configuration and platform dependent to return a value betwee
RGB color. The far clipping plane of the Instrument Camera determines the maximum depth of the
rendered texture and can be set as part of the camera configuration.

.. warning::

Three channel output (RGB) of depth is unavailable as of Vizard 2.2.0 until further notice,
due to a change in how Unity writes the color output from the fragment shader in Unity 2022.3.
Until this is resolved, the depth is encoded only in the red channel (R) of the pixel color.


.. warning::

The internal depth texture values are more accurate for objects closer to the camera. Error in
the calculated depth increases with distance from the camera.


To decode the depth for a specific pixel, sample its color. If your color sampler returns a float red
channel value between 0 and 1.0, calculate the depth as:
To decode the depth for a specific pixel, sample its color. If your color sampler returns float RGB
channel values between 0 and 1.0, calculate the depth as:

.. math::

depth = (farClippingPlane)(pixelColor.r)
depth = (farClippingPlane)*\left[(pixelColor.r)+\left(\frac{pixelColor.g}{255}\right)+\left(\frac{pixelColor.b}{255^2}\right)\right]

If your color sampler returns an integer red channel value between 0 and 255, calculate the depth as:

.. math::

depth = (farClippingPlane)(\frac{pixelColor.r} {255})
depth = (farClippingPlane)*\left[\left(\frac{pixelColor.r}{255}\right)+\left(\frac{pixelColor.g}{255^2}\right)+\left(\frac{pixelColor.b}{255^3}\right)\right]


If the depth is equal to or greater than the far clipping plane of the instrument camera, the
pixel color will be white (255, 255, 255).

.. note::

The color output shown on screen is dependent on the specific display used and may appear different, but the encoded values are accurate.



Expand Down
Binary file modified docs/source/_images/static/vizard-HotKey.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_images/static/vizard-Img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/source/_images/static/vizard-ImgCAD-1.jpg
Binary file not shown.
Binary file modified docs/source/_images/static/vizard-ImgCAD-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_images/static/vizard-ImgPointing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_images/static/vizard-Labels.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/scenarioAsteroidArrival.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,12 @@ def run(show_plots):
# , saveFile=fileName
)
viz.epochInMsg.subscribeTo(gravFactory.epochMsg)

viz.settings.showCelestialBodyLabels = 1
viz.settings.showSpacecraftLabels = 1
viz.settings.truePathFixedFrame = "bennu"
viz.settings.trueTrajectoryLinesOn = 5 # relative to celestial body fixed frame

viz.settings.scViewToPlanetViewBoundaryMultiplier = 100
viz.settings.planetViewToHelioViewBoundaryMultiplier = 100
viz.settings.orbitLinesOn = -1
Expand Down
2 changes: 2 additions & 0 deletions examples/scenarioDataToViz.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def run(show_plots, attType):
viz = vizSupport.enableUnityVisualization(scSim, simTaskName, scList
# , saveFile=fileName
)

viz.settings.trueTrajectoryLinesOn = 2 # relative to chief spacecraft
viz.settings.showSpacecraftLabels = 1
viz.settings.spacecraftShadowBrightness = 0.2
# load CAD for target spacecraft
Expand Down
12 changes: 9 additions & 3 deletions examples/scenarioHaloOrbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,15 @@ def run(showPlots=True):
scSim.AddModelToTask(simTaskName, scDataRec)
scSim.AddModelToTask(simTaskName, MoonDataRec)

viz = vizSupport.enableUnityVisualization(scSim, simTaskName, scObject,
# saveFile=__file__
)
if vizSupport.vizFound:
viz = vizSupport.enableUnityVisualization(scSim, simTaskName, scObject,
# saveFile=__file__
)
viz.settings.showCelestialBodyLabels = 1
viz.settings.mainCameraTarget = "earth"
viz.settings.trueTrajectoryLinesOn = 4
viz.settings.truePathRotatingFrame = "earth moon"

# Initialize simulation
scSim.InitializeSimulation()

Expand Down
5 changes: 4 additions & 1 deletion examples/scenarioOrbitManeuver.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ def run(show_plots, maneuverCase):
# , saveFile=fileName
)
viz.settings.mainCameraTarget = "earth"
viz.settings.trueTrajectoryLinesOn = 1
viz.settings.showCelestialBodyLabels = 1
viz.settings.showSpacecraftLabels = 1
viz.settings.truePathRelativeBody = "earth"
viz.settings.trueTrajectoryLinesOn = 3 # relative to celestial body inertial frame

#
# initialize Simulation
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ tqdm
Pillow
requests
bokeh
protobuf==5.27.0
protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def setupCSS(CSS):
justTheNoise = cssOutput - truthVector # subtract curve from noisy curve
outputStd = np.std(justTheNoise)
if name == 'plain':
plt.figure(3, figsize=(7, 5), dpi=80, facecolor='w', edgecolor='k')
plt.figure(figsize=(7, 5), dpi=80, facecolor='w', edgecolor='k')
plt.plot(dataLogSingle.times() * macros.NANO2MIN, cssOutput, label=name, zorder=zLevel, linewidth=lineWide)
plt.legend()
plt.xlabel('Time [min]')
Expand Down
3 changes: 3 additions & 0 deletions src/simulation/vizard/_GeneralModuleFiles/vizStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ VizSettings
int showMissionTime = 0; //!< flag to show the mission time instead of the simulation time. Value of 0 (protobuffer default) to use viz default, -1 for false, 1 for true
std::string keyboardLiveInput = ""; //!< string of alphanumeric key inputs to listen for during 2-way communication
int64_t messageBufferSize = 0; //!< [bytes] Maximum size of vizMessages to be loaded into memory at one time, -1 to force loading of entire file into memory, 0 to use viz default
std::string truePathRelativeBody = ""; //!< String of the celestial body name to plot the true path trajectory line[s] against, empty string to use the spacecraft's primary body
std::string truePathRotatingFrame = ""; //!< String must contain the names of two distinct celestial bodies, separated by a space, to define the desired rotating frame for plotting true path trajectories
std::string truePathFixedFrame = ""; //!< String of the spacecraft or celestial body name whose rotation matrix will provide the fixed frame to plot the true path trajectory against
}VizSettings;


Expand Down
7 changes: 5 additions & 2 deletions src/simulation/vizard/vizInterface/vizInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ void VizInterface::WriteProtobuffer(uint64_t CurrentSimNanos)

// define if true orbit lines should be shown
vizSettings->set_truetrajectorylineson(this->settings.trueTrajectoryLinesOn);
if (abs(this->settings.trueTrajectoryLinesOn)>2) {
bskLogger.bskLog(BSK_WARNING, "vizInterface: The Vizard trueTrajectoryLinesOn flag must be either -1, 0, 1 or 2. A value of %d was received.", this->settings.trueTrajectoryLinesOn);
if (abs(this->settings.trueTrajectoryLinesOn)>5) {
bskLogger.bskLog(BSK_WARNING, "vizInterface: The Vizard trueTrajectoryLinesOn flag must be either -1, 0, 1 2, 3, 4 or 5. A value of %d was received.", this->settings.trueTrajectoryLinesOn);
}

// define if spacecraft axes should be shown
Expand Down Expand Up @@ -659,6 +659,9 @@ void VizInterface::WriteProtobuffer(uint64_t CurrentSimNanos)
vizSettings->set_showmissiontime(this->settings.showMissionTime);
vizSettings->set_keyboardliveinput(this->settings.keyboardLiveInput);
vizSettings->set_messagebuffersize(this->settings.messageBufferSize);
vizSettings->set_truepathrelativebody(this->settings.truePathRelativeBody);
vizSettings->set_truepathrotatingframe(this->settings.truePathRotatingFrame);
vizSettings->set_truepathfixedframe(this->settings.truePathFixedFrame);

// define actuator GUI settings
for (size_t idx = 0; idx < this->settings.actuatorGuiSettingsList.size(); idx++) {
Expand Down
Loading
Loading