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.

Module I/O Messages

Msg Variable Name

Msg Type

Description

scStateOutMsgNames

scPlusStatesSimMsg

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

  • spacecraft 1 inertial position states

  • spacecraft 1 inertial velocity states

  • spacecraft 1 inertial attitude state in terms of either MRPs, quaternions or 3-2-1 Euler angles

  • spacecraft 1 inertial angular velocity vector in radians per second

  • repeat on the same line for additional spacecraft

The required module parameters are listed in the following table.

Module Required Parameters

Parameter

Type

Description

dataFileName

string

Absolute path to the simulation data file

scStateOutMsgNames

Vector of strings

List of spacecraft names. The state messages will have the same name.

The module is configurable with the following optional parameters:

Module Optional Parameters

Parameter

Default

Description

numSatellites

1

Number of satellites being simulated

delimiter

” “

delimiter string that separates data on a line

convertPosToMeters

1000.0

conversion factor to convert position and velocity measures to meters and meters per second.

headerLine

True

Boolean flag if the data file contains a header line that should be dismissed

attitudeType

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


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

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

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

Private Members

std::vector<int64_t> scStateOutMsgIds

vector of module output message IDs

std::ifstream *fileHandle

file handle to the simulation data input file