Module: vizInterface¶
Executive Summary¶
This module provides an interface to package up Basilisk messages and pass them onto the Vizard application. This allows for the Basilisk simulation data to be recorded to a file for play-back, or for live streaming of the simulation data. It is possible to record the simulation data of a single spacecraft or a multitude of spacecraft.
Module Assumptions and Limitations¶
The module is only able to read Basilisk simulation state messages that are accessable from the task group that
is calling vizInterface.
Message Connection Descriptions¶
The following messages are set directly within vizInterface.  Additional messages are set within the
VizSpacecraftData data structures for each spacecraft.
| Msg Variable Name | Msg Type | Description | 
|---|---|---|
| opnavImageOutMsgName | If Vizard is used as a camera sensor, this is the the name of the output message of the camera image. | |
| cameraConfInMsgName | Name of the incoming camera data | 
User Guide¶
The vizInterface module can be directly configured, or setup using the helper methods in vizSupport.
More information can be found in BSK Scripting Settings page.  The scenarioFormationBasic illustrates and
discusses how to configure vizInterface for use with multiple satellites.
Defines
- 
VIZ_MAX_SIZE¶
- 
struct MsgCurrStatus¶
- #include <vizInterface.h>Structure to store that status of a Basilisk message being read in by vizInterface.
- 
struct ThrClusterMap¶
- #include <vizInterface.h>Structure to store a thruster group information. 
- 
struct PointLine¶
- #include <vizInterface.h>Vizard setting structure to define a pointing line feature. This is used to draw a colored line from one space object to another space object. 
- 
struct KeepOutInCone¶
- #include <vizInterface.h>Vizard setting structure to define a keep out/in cone visual feature. Here cone is drawn attached to one body with a body-fixed position and heading. If a second celestial object is within or outside this code, then the opacity of the cone changes. Public Members - 
bool isKeepIn¶
- True -> keep in cone created, False -> keep out cone created. 
 - 
double position_B[3]¶
- [m] cone start relative to from body coordinate frame 
 - 
double normalVector_B[3]¶
- [-] cone normal direction vector 
 - 
double incidenceAngle¶
- [rad] cone incidence angle 
 - 
double coneHeight¶
- [m] sets height of visible cone (asthetic only, does not impact function) 
 - 
std::string fromBodyName¶
- name of body to attach cone onto 
 - 
std::string toBodyName¶
- detect changes if this body has impingement on cone 
 - 
int coneColor[4]¶
- [-] desired RGBA as values between 0 and 255 
 - 
std::string coneName¶
- [-] cone name, if unspecified, viz will autogenerate name 
 
- 
bool 
- 
struct StdCameraSettings¶
- #include <vizInterface.h>Vizard setting structure to define a standard Vizard camera. These can be assigned to any spacecraft and set to point at either another object, or to point in a body-fixed direction. Public Members - 
std::string spacecraftName¶
- name of spacecraft onto which to place a camera 
 - 
int setMode= 1¶
- 0 -> body targeting, 1 -> pointing vector (default) 
 - 
double fieldOfView= -1¶
- [rad], field of view setting, -1 -> use default, values between 0.0001 and 179.9999 deg valid 
 - 
std::string bodyTarget¶
- Name of body camera should point to (default to first celestial body in messages). This is a setting for body targeting mode. 
 - 
int setView= 0¶
- 0 -> Nadir, 1 -> Orbit Normal, 2 -> Along Track (default to nadir). This is a setting for body targeting mode. 
 - 
double pointingVector_B[3]¶
- (default to 1, 0, 0). This is a setting for pointing vector mode. 
 - 
double position_B[3]¶
- (default to 0, 0, 0). If a non-zero vector, this determines the location of the camera. If a zero vector, then the camera is placed outside of the spacecraft along the pointing vector direction. 
 
- 
std::string 
- 
struct ActuatorGuiSettings¶
- #include <vizInterface.h>Vizard User Interface structure specifying what actuator visualizations to show. Public Members - 
std::string spacecraftName¶
- Specify which spacecraft should show actuator information. If not provided then the - viz.spacecraftNameis used.
 - 
int viewThrusterPanel= 0¶
- [bool] should thruster panel illustration be shown, -1 (off), 0 (default), 1 (on) 
 - 
int viewThrusterHUD= 0¶
- [bool] should thruster Heads-Up-Display be shown, -1 (off), 0 (default), 1 (on) 
 - 
int viewRWPanel= 0¶
- [bool] should reaction wheel panel illustration be shown, -1 (off), 0 (default), 1 (on) 
 - 
int viewRWHUD= 0¶
- [bool] should reaction wheel Heads-Up-Display be shown, -1 (off), 0 (default), 1 (on) 
 - 
int showThrusterLabels= 0¶
- [bool] should the thruster labels be shown, -1 (off), 0 (default), 1 (on) 
 - 
int showRWLabels= 0¶
- [bool] should the reaction wheel labels be shown, -1 (off), 0 (default), 1 (on) 
 
- 
std::string 
- 
struct CustomModel¶
- #include <vizInterface.h>Structure defining a custom CAD model to load to represent a simulation object. Public Members - 
std::string modelPath¶
- Path to model obj -OR- - CUBE,- CYLINDER, or- SPHEREto use a primitive shape.
 - 
std::vector<std::string> simBodiesToModify¶
- Which bodies in scene to replace with this model, use - ALL_SPACECRAFTto apply custom model to all spacecraft in simulation.
 - 
double offset[3]¶
- [m] offset to use to draw the model 
 - 
double rotation[3]¶
- [rad] 3-2-1 Euler angles to rotate CAD about z, y, x axes 
 - 
double scale[3]¶
- [-] desired model scaling factor along the body x, y, z axes in spacecraft CS 
 - 
std::string customTexturePath¶
- (Optional) Path to texture to apply to model (note that a custom model’s .mtl will be automatically imported with its textures during custom model import) 
 - 
std::string normalMapPath¶
- (Optional) Path to the normal map for the customTexture 
 - 
int shader= -1¶
- (Optional) Value of -1 to use viz default, 0 for Unity Specular Standard Shader, 1 for Unity Standard Shader 
 
- 
std::string 
- 
struct VizSpacecraftData¶
- #include <vizInterface.h>Defines a data structure for the spacecraft state messages and ID’s. Public Members - 
std::string spacecraftName= "bsk-Sat"¶
- [-] Name of the spacecraft. 
 - 
std::string cssDataInMsgName= "css_sensors_data"¶
- [-] (Optional) Name of the incoming css data message 
 - 
std::string cssConfInMsgName= "css_config_data"¶
- [-] (Optional) Name of the incoming css constellation data message 
 - 
std::string scPlusInMsgName= "inertial_state_output"¶
- [-] Name of the incoming SCPlus data message 
 - 
std::vector<std::string> rwInMsgName¶
- [-] Vector of names of the incoming RW state messages. If this is not set directly, then it is auto-generated using the spacecraft name as the prefix. This is required if - numRWis greater than 0.
 - 
std::vector<ThrClusterMap> thrMsgData¶
- [-] (Optional) Name of the incoming thruster data. This is required if - numThris greater than 0.
 - 
std::string starTrackerInMsgName= "star_tracker_state"¶
- [-] (Optional) Name of the incoming Star Tracker data 
 - 
int numRW= 0¶
- [-] (Optional) Number of RW 
 - 
int numThr= 0¶
- [-] (Optional) Number of Thrusters 
 - 
std::vector<MsgCurrStatus> rwInMsgID¶
- [-] (Private) ID of the incoming rw data 
 - 
std::vector<MsgCurrStatus> thrMsgID¶
- [-] (Private) ID of the incoming thruster data 
 - 
MsgCurrStatus starTrackerInMsgID¶
- [-] (Private) ID of the incoming Star Tracker data 
 - 
MsgCurrStatus scPlusInMsgID¶
- [-] (Private) ID of the incoming SCPlus data 
 - 
MsgCurrStatus cssDataInMsgId¶
- [-] (Private) ID of the incoming css data 
 - 
MsgCurrStatus cssConfInMsgId¶
- [-] (Private) ID of the incoming css constellation data 
 - 
std::vector<RWConfigLogSimMsg> rwInMessage¶
- [-] (Private) RW message data 
 - 
STSensorIntMsg STMessage¶
- [-] (Private) ST message data 
 - 
std::vector<THROutputSimMsg> thrOutputMessage¶
- [-] (Private) Thr message data 
 - 
SCPlusStatesSimMsg scPlusMessage¶
- [-] (Private) s/c plus message data 
 - 
CSSConfigFswMsg cssConfigMessage¶
- [-] (Private) CSS config message data 
 - 
std::string spacecraftSprite= ""¶
- Set sprite for this spacecraft only through shape name and optional int RGB color values [0,255] Possible settings: “CIRCLE”,”SQUARE”, “STAR”, “TRIANGLE” or “bskSat” for a 2D spacecraft sprite of the bskSat shape. 
 
- 
std::string 
- 
struct VizSettings¶
- #include <vizInterface.h>Structure defining various Vizard options Public Members - 
double ambient= -1.0¶
- [-] Ambient background lighting. Should be a value between 0 and 8. A value of -1 means it is not set. 
 - 
int32_t orbitLinesOn= 0¶
- toogle for showing orbit lines with values -1 (off), 0 (default), 1 (on) 
 - 
int32_t spacecraftCSon= 0¶
- toogle for showing spacecraft CS with values -1 (off), 0 (default), 1 (on) 
 - 
int32_t planetCSon= 0¶
- toogle for showing planet CS with values -1 (off), 0 (default), 1 (on) 
 - 
std::vector<KeepOutInCone> coneList¶
- vector of keep in/out cones 
 - 
std::vector<StdCameraSettings> stdCameraList¶
- vector of spacecraft cameras 
 - 
std::vector<CustomModel> customModelList¶
- vector of custom object models 
 - 
std::vector<ActuatorGuiSettings> actuatorGuiSettingsList¶
- msg containing the flags on displaying the actuator GUI elements 
 - 
std::string skyBox= ""¶
- string containing the star field options, an empty string’’ provides default NASA SVS Starmap, - ESOuse ESO Milky Way skybox,- blackprovides a black background, or provide a filepath to custom background
 - 
bool dataFresh¶
- [-] flag indicating if the settings have been transmitted, 
 - 
int32_t viewCameraBoresightHUD= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t viewCameraConeHUD= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t showCSLabels= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t showCelestialBodyLabels= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t showSpacecraftLabels= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t showCameraLabels= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
double customGUIScale= -1.0¶
- GUI scaling parameter, Value of -1 to use viz default, values in [0.5, 3]. 
 - 
std::string defaultSpacecraftSprite= ""¶
- Set sprite for ALL spacecraft through shape name and optional int RGB color values [0,255] Possible settings: “CIRCLE”,”SQUARE”, “STAR”, “TRIANGLE” or “bskSat” for a 2D spacecraft sprite of the bskSat shape. 
 - 
int32_t showSpacecraftAsSprites= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t showCelestialBodiesAsSprites= 0¶
- Value of 0 to use viz default, -1 for false, 1 for true. 
 - 
int32_t show24hrClock= 0¶
- Value of 0 (protobuffer default) to use viz default, -1 for false, 1 for true. 
 - 
int32_t showDataRateDisplay= 0¶
- flag to show data frame rate, 0 (protobuffer default), -1 for false, 1 for true 
 
- 
double 
- 
class VizInterface: public SysModel¶
- #include <vizInterface.h>Defines a data structure for the spacecraft state messages and ID’s. Public Functions - 
VizInterface()¶
- VizInterface Constructor 
 - 
~VizInterface()¶
- VizInterface Destructor 
 - 
void SelfInit()¶
- Initialization method for subscription to messages. This module does not output messages, but files containing the protobuffers for Vizard 
 - 
void CrossInit()¶
- Cross initialization. Module subscribes to other messages. In viz interface, many messages are subscribed to in order to extract information from the viz and give it to the visualization tool. 
 - 
void Reset(uint64_t CurrentSimNanos)¶
- A Reset method to put the module back into a clean state - Parameters
- CurrentSimNanos: The current sim time in nanoseconds
 
 
 - 
void UpdateState(uint64_t CurrentSimNanos)¶
- Update this module at the task rate - Parameters
- CurrentSimNanos: The current sim time
 
 
 - 
void ReadBSKMessages()¶
- A method in which the module reads the content of all available bsk messages 
 - 
void WriteProtobuffer(uint64_t CurrentSimNanos)¶
- The method in which the vizInterface writes a protobuffer with the information from the simulation. - Parameters
- CurrentSimNanos: The current sim time in nanoseconds
 
 
 Public Members - 
std::vector<VizSpacecraftData> scData¶
- [-] vector of spacecraft data containers 
 - 
std::vector<std::string> spiceInMsgName¶
- [-] Name of the incoming Spice data 
 - The name of the Image output message. 
 - [int] Set non-zero positive value if Unity/Viz couple in direct communication. (1 - regular opNav, 2 - performance opNav) 
 - 
bool saveFile¶
- [Bool] Set True if Vizard should save a file of the data. 
 - 
bool liveStream¶
- [Bool] Set True if Vizard should receive a live stream of BSK data. 
 - 
void *bskImagePtr¶
- [RUN] Permanent pointer for the image to be used in BSK without relying on ZMQ because ZMQ will free it (whenever, who knows) 
 - 
std::string cameraConfInMsgName= "camera_config_data"¶
- [-] Name of the incoming camera data 
 - 
MsgCurrStatus cameraConfMsgId¶
- [-] ID of the incoming camera data 
 - 
CameraConfigMsg cameraConfigMessage¶
- [-] Camera config 
 - 
std::vector<std::string> planetNames¶
- Vector of planet names we want to track, read in from python. 
 - 
uint64_t numOutputBuffers¶
- [-] Number of buffers to request for the output messages 
 - 
int64_t FrameNumber¶
- Number of frames that have been updated for TimeStamp message. 
 - 
std::string protoFilename¶
- Filename for where to save the protobuff message. 
 - 
VizSettings settings¶
- [-] container for the Viz settings that can be specified from BSK 
 - 
std::string comProtocol¶
- Communication protocol to use when connecting to Vizard. 
 - 
std::string comAddress¶
- Communication address to use when connecting to Vizard. 
 - 
std::string comPortNumber¶
- Communication port number to use when connecting to Vizard. 
 - 
std::string epochMsgName¶
- [-] name of the simulation epoch date/time msg 
 - 
MsgCurrStatus epochMsgID¶
- [-] ID of the epoch msg 
 - 
EpochSimMsg epochMsg¶
- [-] epoch msg data 
 Private Members - 
void *context¶
 - 
void *requester_socket¶
 - 
int firstPass¶
- Flag to intialize the viz at first timestep. 
 - 
int32_t imageOutMsgID¶
- ID for the outgoing Image message. 
 - 
std::vector<MsgCurrStatus> spiceInMsgID¶
- [-] IDs of the incoming planets’ spice data 
 - 
std::vector<SpicePlanetStateSimMsg> spiceMessage¶
- [-] Spice messages 
 - 
std::ofstream *outputStream¶
- [-] Output file stream opened in reset 
 - 
std::map<uint32_t, SpicePlanetStateSimMsg> planetData¶
- Internal vector of planets 
 
-