COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
fast_contacts.cpp File Reference
#include "support/convertlib.h"
#include "support/jsonlib.h"
#include "agent/agentclass.h"
#include "physics/physicslib.h"
#include "math/mathlib.h"
Include dependency graph for fast_contacts.cpp:

Classes

struct  trackstruc
 

Functions

void propcalc (size_t index)
 
int main (int argc, char *argv[])
 

Variables

Agentagent
 
double minimum_elevation = RADOF(10.)
 
string nodename
 
string tlename
 
vector< tlestructlelist
 
std::vector< trackstructrack
 
double utcnow
 
double utcstart
 
double utcend
 
double mylat
 
double mylon
 

Function Documentation

void propcalc ( size_t  index)
149 {
150  tle2eci(utcnow, track[index].tle, track[index].loc.pos.eci);
151  track[index].loc.pos.eci.pass++;
152  pos_eci(&track[index].loc);
153  geoc2topo(agent->cinfo->node.loc.pos.geod.s, track[index].loc.pos.geoc.s, track[index].topo);
154  topo2azel(track[index].topo, track[index].azfrom, track[index].elfrom);
155  switch ((uint8_t)track[index].visible)
156  {
157  case 0:
158  if (track[index].elfrom > minimum_elevation)
159  {
160  track[index].highest = track[index].elfrom;
161  track[index].startutc = utcnow;
162  track[index].visible = true;
163  track[index].peaked = false;
164  printf("%s %13.5f %s AOS%02d: %4.0f sec %6.1f %5.1f deg\n", mjdToGregorian(utcnow).c_str(), utcnow, track[index].name.c_str(), (int)(DEGOF(minimum_elevation)), 86400.*(utcnow-track[index].startutc), DEGOF(track[index].azfrom), DEGOF(track[index].elfrom));
165  fflush(stdout);
166  }
167  break;
168  case 1:
169  if (track[index].elfrom < minimum_elevation)
170  {
171  track[index].visible = false;
172  printf("%s %13.5f %s LOS%02d: %4.0f sec %6.1f %5.1f deg\n", mjdToGregorian(utcnow).c_str(), utcnow, track[index].name.c_str(), (int)(DEGOF(minimum_elevation)), 86400.*(utcnow-track[index].startutc), DEGOF(track[index].azfrom), DEGOF(track[index].elfrom));
173  fflush(stdout);
174  }
175  else
176  {
177  if (track[index].elfrom > track[index].highest)
178  {
179  track[index].highest = track[index].elfrom;
180  }
181  else
182  {
183  if (!track[index].peaked)
184  {
185  track[index].peaked = true;
186  printf("%s %13.5f %s MAX: %4.0f sec %6.1f %5.1f deg\n", mjdToGregorian(utcnow).c_str(), utcnow, track[index].name.c_str(), 86400.*(utcnow-track[index].startutc), DEGOF(track[index].azfrom), DEGOF(track[index].elfrom));
187  }
188  }
189  }
190  break;
191  }
192 }
double utcnow
Definition: fast_contacts.cpp:63
static std::vector< tlestruc > tle
Definition: agent_antenna.cpp:177
static float highest
Definition: get_contacts.cpp:58
int32_t geoc2topo(gvector source, rvector targetgeoc, rvector &topo)
Geocentric to Topocentric.
Definition: convertlib.cpp:3033
int32_t mjdToGregorian(double mjd, int32_t &year, int32_t &month, int32_t &day, int32_t &hour, int32_t &minute, int32_t &second)
Definition: timelib.cpp:1364
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double minimum_elevation
Definition: fast_contacts.cpp:37
string name
Definition: cubesat2obj.cpp:6
locstruc loc
Location structure.
Definition: jsondef.h:3596
Agent * agent
Definition: fast_contacts.cpp:36
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
std::vector< trackstruc > track
Definition: fast_contacts.cpp:56
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
gvector s
Position vector.
Definition: convertdef.h:263
cosmosstruc * cinfo
Definition: agentclass.h:346
geoidpos geod
Definition: convertdef.h:741
int32_t topo2azel(rvector tpos, float &az, float &el)
Definition: convertlib.cpp:3129
int tle2eci(double utc, tlestruc tle, cartpos &eci)
Definition: convertlib.cpp:3466
int main ( int  argc,
char *  argv[] 
)
72 {
73  //int32_t iretn;
74  double period = 1.;
75 
76  printf("Iniitial\n");
77  fflush(stdout);
78  switch (argc)
79  {
80  case 6:
81  minimum_elevation = RADOF(atof(argv[5]));
82  case 5:
83  period = atof(argv[4]);
84  case 4:
85  mylon = atof(argv[3]);
86  mylat = atof(argv[2]);
87  tlename = argv[1];
88  break;
89  default:
90  printf("Usage: fast_contacts tlename nodename [days]");
91  exit (1);
92  break;
93  }
94 
95  // Establish the command channel and heartbeat
96  printf("Starting agent\n");
97  fflush(stdout);
98  agent = new Agent();
99 // if ((iretn = agent->wait()) < 0)
100 // {
101 // fprintf(agent->get_debug_fd(), "%16.10f %s Failed to start Agent %s on Node %s Dated %s : %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str(), cosmos_error_string(iretn).c_str());
102 // exit(iretn);
103 // }
104 // else
105 // {
106 // fprintf(agent->get_debug_fd(), "%16.10f %s Started Agent %s on Node %s Dated %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str());
107 // }
108 
109 
112  agent->cinfo->node.loc.pos.geod.s.h = 348.;
116 
117 
118  // Load Nodes
119 
120  printf("loading %s\n", tlename.c_str());
121  fflush(stdout);
123  for (size_t i=0; i<tlelist.size(); ++i)
124  {
125  trackstruc ttrack;
126  ttrack.name = tlelist[i].name;
127  ttrack.visible = false;
128  ttrack.peaked = false;
129  ttrack.highest = 0.;
130  // ttrack.type = NODE_TYPE_SATELLITE;
131  ttrack.tle = tlelist[i];
132  pos_clear(ttrack.loc);
133  track.push_back(ttrack);
134  }
135 
136  utcstart = currentmjd();
137  utcend = utcstart + period;
138  for (utcnow=utcstart; utcnow<utcend; utcnow+=1./86400)
139  {
140 //#pragma omp parallel for
141  for (size_t i=0; i<track.size(); ++i)
142  {
143  propcalc(i);
144  }
145  }
146 }
vector< tlestruc > tlelist
Definition: fast_contacts.cpp:40
Definition: agent_control.cpp:165
void propcalc(size_t index)
Definition: fast_contacts.cpp:148
double utcstart
Definition: fast_contacts.cpp:64
double mylon
Definition: fast_contacts.cpp:67
double utcnow
Definition: fast_contacts.cpp:63
int i
Definition: rw_test.cpp:37
double utcend
Definition: fast_contacts.cpp:65
string tlename
Definition: fast_contacts.cpp:39
double mylat
Definition: fast_contacts.cpp:66
bool visible
Definition: fast_contacts.cpp:52
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double minimum_elevation
Definition: fast_contacts.cpp:37
int32_t pos_clear(locstruc *loc)
Initialize posstruc.
Definition: convertlib.cpp:77
locstruc loc
Definition: fast_contacts.cpp:44
gvector gv_zero()
Zero geodetic vector.
Definition: vector.cpp:946
Definition: agentclass.h:139
locstruc loc
Location structure.
Definition: jsondef.h:3596
Agent * agent
Definition: fast_contacts.cpp:36
double h
Height in meters.
Definition: vector.h:229
Definition: eci2kep_test.cpp:33
std::vector< trackstruc > track
Definition: fast_contacts.cpp:56
string name
Definition: agent_control.cpp:170
double lon
Longitude in radians.
Definition: vector.h:227
int32_t pos_geod(locstruc *loc)
Set Geodetic position.
Definition: convertlib.cpp:576
int32_t load_lines_multi(string fname, vector< tlestruc > &lines)
Definition: convertlib.cpp:3714
bool peaked
Definition: fast_contacts.cpp:53
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
gvector s
Position vector.
Definition: convertdef.h:263
double lat
Latitude in radians.
Definition: vector.h:225
float highest
Definition: fast_contacts.cpp:50
tlestruc tle
Definition: fast_contacts.cpp:43
cosmosstruc * cinfo
Definition: agentclass.h:346
geoidpos geod
Definition: convertdef.h:741
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:269
gvector v
Velocity vector.
Definition: convertdef.h:265
#define RADOF(deg)
Radians of a Degree value.
Definition: math/constants.h:29

Variable Documentation

Agent* agent
double minimum_elevation = RADOF(10.)
string nodename
string tlename
vector<tlestruc> tlelist
std::vector<trackstruc> track
double utcnow
double utcstart
double utcend
double mylat
double mylon