Module: dataFileToViz¶
Executive Summary¶
This module reads in simulation data of one or more spacecraft, likely created outside of Basilisk, and creates associated Basilisk messages such that Module: vizInterface can stream of save a Vizard compatible data file. This makes it possible to use Vizard to illustrate a simulation. The use of this module is demonstrates in scenarioDataToViz.
Module Assumptions and Limitations¶
The module currently reads in the spacecraft position, velocity and orientation states.
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 | 
|---|---|---|
| scStateOutMsgNames | Vector of spacecraft names. These also become the output message names | 
User Guide¶
The module assumes the data file is in plain text form and the following format:
- time 
- inertial position states (m) 
- inertial velocity states (m/s) 
- inertial attitude state in terms of either MRPs, quaternions or 3-2-1 Euler angles (rad) 
- inertial angular velocity vector in radians per second (rad/s) 
- (optional) thruster force values (N) 
- (optional) RW Speed \(\Omega\) (rad/s) and RW motor torque \(u_s\) (N) 
- repeat on the same line for additional spacecraft 
The required module parameters are listed in the following table.
| Parameter | Type | Description | 
|---|---|---|
| 
 | string | Absolute path to the simulation data file | 
| 
 | Vector of strings | List of spacecraft names. The state messages will have the same name. | 
The module is configurable with the following optional parameters:
| Parameter | Default | Description | 
|---|---|---|
| 
 | 1 | Number of satellites being simulated | 
| 
 | ” “ | delimiter string that separates data on a line | 
| 
 | 1000.0 | conversion factor to convert position and velocity measures to meters and meters per second. | 
| 
 | True | Boolean flag if the data file contains a header line that should be dismissed | 
| 
 | 0 | Specify the attitude coordinate set used in the data file. 0 - MRP, 1 - quaternions as \((q_0, q_1, q_2, q_3)\), and 2 - (3-2-1) Euler angles in radians | 
| 
 | empty | vector of spacecraft thruster configuration vectors.  Each element contains a ThrClusterMap container
(defined in Module: vizStructures).
This allows for each spacecraft to have distinct sets of thrusters to be included.
See test_dataFileToViz for an example on how to configure for thruster information.  You add thruster
location, thrust force direction and maximum thrust values using  | 
| 
 | empty | Add a list of RW message names for a spacecraft.  Repeat for multiple spacecraft.  Add the RW location,
spin axis, maximum spin rate and maximum motor torque through the methods  | 
- 
class DataFileToViz: public SysModel¶
- #include <dataFileToViz.h>Defines a data structure for the spacecraft state messages and ID’s. Public Functions - 
DataFileToViz()¶
- DataFileToViz Constructor 
 - 
~DataFileToViz()¶
- DataFileToViz Destructor 
 - 
void SelfInit()¶
- Initialization method 
 - 
void CrossInit()¶
- Cross initialization. This module does not subscribe to any other messages. 
 - 
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 appendThrPos(double pos_B[3])¶
- Add a thruster 3d position vector to the list of thruster locations 
 - 
void appendThrDir(double dir_B[3])¶
- Add a thruster 3d unit direction vector to the list. The input vectors gets normalized before being added to the list. 
 - 
void appendThrForceMax(double)¶
- Add a thruster maximum force value to the list of thrusters. 
 - 
void appendThrClusterMap(std::vector<ThrClusterMap> thrMsgData)¶
- Add a thruster cluster map for each spacecraft 
 - 
void appendRwMsgNames(std::vector<std::string> rwMsgNameList)¶
- Add a RW output msg list for each spacecraft 
 - 
void appendRwPos(double pos_B[3])¶
- Add a thruster 3d position vector to the list of thruster locations 
 - 
void appendRwDir(double dir_B[3])¶
- Add a RW spin axis unit direction vector to the list. The input vectors gets normalized before being added to the list. 
 - 
void appendOmegaMax(double)¶
- Add a RW wheel rate value to the list 
 - 
void appendUMax(double)¶
- Add a RW maximum motor torque value to the list 
 Public Members - 
std::string dataFileName¶
- Name of the simulation data file. 
 - 
int numSatellites¶
- number of satellites being read in, default is 1 
 - 
std::vector<std::string> scStateOutMsgNames¶
- vector of spacecraft state messages 
 - 
std::string delimiter¶
- delimiter string that separates data on a line 
 - 
double convertPosToMeters¶
- conversion factor to meters 
 - 
bool headerLine¶
- [bool] flag to mark first line as a header 
 - 
int attitudeType¶
- 0 - MRP, 1 - EP or quaternions (q0, q1, q2, q3), 2 - (3-2-1) Euler angles 
 - 
std::vector<std::vector<ThrClusterMap>> thrMsgDataSC¶
- (Optional) vector of sets of thruster cluster mapping info 
 - 
std::vector<std::vector<std::string>> rwMsgOutNamesSC¶
- (Optional) vector of sets of RW msg names, each entry is per SC 
 - 
BSKLogger bskLogger¶
- [-] BSK Logging object 
 - 
uint64_t OutputBufferCount¶
- number of output buffers for messaging system 
 Private Functions - 
void pullVector(std::istringstream *iss, double*)¶
- pull a 3-d set of double values from the input stream 
 - 
void pullVector4(std::istringstream *iss, double*)¶
- pull a 4-d set of double values from the input stream 
 - 
double pullScalar(std::istringstream *iss)¶
- pull a double from the input stream 
 Private Members - 
std::vector<int64_t> scStateOutMsgIds¶
- vector of spacecraft module output message IDs 
 - 
std::vector<int64_t> thrMsgIds¶
- vector of thruster module output message IDs 
 - 
std::vector<int64_t> rwMsgIds¶
- vector of RW output message IDs 
 - 
std::ifstream *fileHandle¶
- file handle to the simulation data input file 
 - 
std::vector<Eigen::Vector3d> thrPosList¶
- [m] vector of thrust positions 
 - 
std::vector<Eigen::Vector3d> thrDirList¶
- [-] vector of thrust unit direction vectors in B-frame components 
 - 
std::vector<double> thrForceMaxList¶
- [-] vector of thrust maximum force values 
 - 
std::vector<Eigen::Vector3d> rwPosList¶
- [m] vector of RW positions 
 - 
std::vector<Eigen::Vector3d> rwDirList¶
- [-] vector of RW sprin axis unit direction vectors in B-frame components 
 - 
std::vector<double> rwOmegaMaxList¶
- [r/s] vector of RW maximum spin rate values 
 - 
std::vector<double> rwUMaxList¶
- [N] vector of RW maximum motor torque values values 
 
-