1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/***********************************************/
/**
* @file simulateStarCamera.cpp
*
* @brief Rotation from satellite (x: along, y: cross, z: nadir) to inertial frame.
*
* @author Torsten Mayer-Guerr
* @date 2005-01-21
*/
/***********************************************/
// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
This program simulates \file{star camera}{instrument} measurements at each satellite's position.
The satellite's orientation follows a local orbit frame with the x-axis in along track (along velocity),
y-axis is cross track (normal to position and velocity vector) and z-axis pointing nadir (negative position vector).
As for non circular orbit the position and velocity are not exact normal, the default is the x-axis to be exact
along velocity and the z-axis forms a right hand system (not exact nadir) or with \config{nadirPointing} the z-axis
is exact nadir and x-axis approximates along.
The resulting rotation matrices rotate from satellite frame to inertial frame.
)";
/***********************************************/
#include "programs/program.h"
#include "files/fileInstrument.h"
/***** CLASS ***********************************/
/** @brief Rotation from satellite (x: along, y: cross, z: nadir) to inertial frame.
* @ingroup programsGroup */
class SimulateStarCamera
{
public:
void run(Config &config, Parallel::CommunicatorPtr comm);
};
GROOPS_REGISTER_PROGRAM(SimulateStarCamera, PARALLEL, "Rotation from satellite (x: along, y: cross, z: nadir) to inertial frame.", Simulation, Instrument)
/***********************************************/
void SimulateStarCamera::run(Config &config, Parallel::CommunicatorPtr comm)
{
try
{
FileName orbitName, starCameraName;
Bool isNadirPointing;
readConfig(config, "outputfileStarCamera", starCameraName, Config::MUSTSET, "", "rotation from satellite to inertial frame (x: along, y: cross, z: nadir)");
readConfig(config, "inputfileOrbit", orbitName, Config::MUSTSET, "", "position and velocity defines the orientation of the satellite at each epoch");
readConfig(config, "nadirPointing", isNadirPointing, Config::DEFAULT, "0", "false: exact along and nearly nadir, true: nearly along and exact nadir");
if(isCreateSchema(config)) return;
logStatus<<"read orbit and generate star camera data"<<Log::endl;
InstrumentFile orbitFile(orbitName);
std::vector<Arc> arcList(orbitFile.arcCount());
Parallel::forEach(arcList, [&](UInt arcNo)
{
OrbitArc orbit = orbitFile.readArc(arcNo);
StarCameraArc arc;
for(UInt i=0; i<orbit.size(); i++)
{
Vector3d velocity = orbit.at(i).velocity; // velocity vector
if(velocity.r()==0)
{
if(i<orbit.size()-1)
velocity = orbit.at(i+1).position - orbit.at(i).position;
else
velocity = orbit.at(i).position - orbit.at(i-1).position;
}
Vector3d y = normalize(crossProduct(velocity, orbit.at(i).position)); // cross
Vector3d x = normalize((isNadirPointing) ? crossProduct(orbit.at(i).position, y) : velocity); // along
StarCameraEpoch epoch;
epoch.time = orbit.at(i).time;
epoch.rotary = Rotary3d(x, y);
arc.push_back(epoch);
}
return arc;
}, comm);
if(Parallel::isMaster(comm))
{
logStatus<<"write star camera data to file <"<<starCameraName<<">"<<Log::endl;
InstrumentFile::write(starCameraName, arcList);
Arc::printStatistics(arcList);
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
|