214 printf(
"Usage: agent->control {nodename}");
241 tradio.
name =
"Direct";
242 tradio.info.freq = 0.;
244 tradio.otherradioindex = 9999;
245 tradio.beat.utc = 0.;
246 tradio.basefreq = 0.;
247 tradio.baseopmode = 0;
254 tradio.basefreq = tradio.info.freq;
255 tradio.baseopmode = tradio.info.opmode;
256 tradio.otherradioindex = 9999;
265 tradio.basefreq = tradio.info.freq;
266 tradio.baseopmode = tradio.info.opmode;
267 tradio.otherradioindex = 9999;
276 tradio.basefreq = tradio.info.freq;
277 tradio.baseopmode = tradio.info.opmode;
278 tradio.otherradioindex = 9999;
296 track[0].name =
"idle";
298 vector <string>
nodes;
300 for (
size_t i=0;
i<nodes.size(); ++
i)
303 FILE *
fp = fopen(path.c_str(),
"r");
307 fscanf(fp,
"{\"node_type\":%d", &type);
315 ttrack.
name = nodes[
i];
331 tradio.otherradioindex = 9999;
332 ttrack.
radios.push_back(tradio);
343 tradio.otherradioindex = 9999;
344 ttrack.
radios.push_back(tradio);
355 tradio.otherradioindex = 9999;
356 ttrack.
radios.push_back(tradio);
376 track.push_back(ttrack);
386 vector <tlestruc>
tle;
389 for (
size_t i=0;
i<tle.size(); ++
i)
394 ttrack.
name = tle[
i].name;
405 ttrack.
radios[0].name =
"radio";
406 ttrack.
radios[0].otherradioindex = 9999;
410 track.push_back(ttrack);
420 vector <gentry> trajectory;
430 iretn = fscanf(fp,
"%lf %lf %lf %lf\n", &tentry.second, &tentry.geod.lat, &tentry.geod.lon, &tentry.geod.h);
433 trajectory.push_back(tentry);
437 if (trajectory.size() > 2)
451 ttrack.
radios[0].name =
"radio";
452 ttrack.
radios[0].otherradioindex = 9999;
455 tfit.update(trajectory[0].second, trajectory[0].geod);
456 tfit.update(trajectory[1].second, trajectory[1].geod);
457 for (uint16_t
i=0;
i<(trajectory[0].second+trajectory[1].second)/2; ++
i)
461 for (uint16_t j=1; j<trajectory.size()-1; ++j)
464 tfit.update(trajectory[j-1].second, trajectory[j-1].geod);
465 tfit.update(trajectory[j].second, trajectory[j].geod);
466 tfit.update(trajectory[j+1].second, trajectory[j+1].geod);
467 for (uint16_t
i=static_cast<uint16_t>(.5+(trajectory[j-1].second+trajectory[j].second)/2);
i<(trajectory[j].second+trajectory[j+1].second)/2; ++
i)
473 tfit.update(trajectory[trajectory.size()-2].second, trajectory[trajectory.size()-2].geod);
474 tfit.update(trajectory[trajectory.size()-1].second, trajectory[trajectory.size()-1].geod);
475 for (uint16_t
i=static_cast<uint16_t>(.5+(trajectory[trajectory.size()-2].second+trajectory[trajectory.size()-1].second)/2);
i<trajectory[trajectory.size()-1].second; ++
i)
480 for (
double timestep=0.; timestep<=trajectory[trajectory.size()-1].second; timestep+=1.)
482 uint16_t timeidx =
static_cast<uint16_t
>(timestep);
485 printf(
"%f %f %f %f %f %f %f\n", timestep, tpos.
lat, tpos.
lon, tpos.
h, tvel.
lat, tvel.
lon, tvel.
h);
513 thread monitor_thread(
monitor);
526 for (
size_t i=0;
i<
track.size(); ++
i)
535 track[
i].target.loc.pos.eci.pass++;
540 track[
i].target.loc.pos.eci.pass++;
573 printf(
"%f: Request: %s\n", et.
lap(), request);
586 for (
size_t j=0; j<
myradios.size(); ++j)
590 size_t idx =
myradios[j].otherradioindex;
591 if (mjdnow -
myradios[j].beat.utc < 10.)
602 sprintf(request,
"set_frequency %f",
track[i].radios[idx].
info.freq +
track[i].radios[idx].dfreq);
604 sprintf(request,
"set_opmode %u",
track[i].radios[idx].
info.opmode);
628 request =
"set_azel 180. 90.";
644 monitor_thread.join();
Radio Receiver.
Definition: jsondef.h:508
uint16_t type
Definition: agent_control.cpp:167
Definition: jsondef.h:575
Definition: agent_control.cpp:165
gj_handle gjh
Definition: agent_control.cpp:171
float area
Definition: jsondef.h:3429
int32_t finish_active_loop()
Definition: agentclass.cpp:355
int32_t request_list_radios(string &request, string &response, Agent *)
Definition: agent_control.cpp:761
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
int32_t request_get_highest(string &req, string &response, Agent *)
Definition: agent_control.cpp:927
vector< LsFit > position
Definition: agent_control.cpp:172
Definition: agent_control.cpp:149
static std::vector< tlestruc > tle
Definition: agent_antenna.cpp:177
static Agent * agent
Definition: agent_control.cpp:142
3 element generic row vector
Definition: vector.h:53
int32_t json_setup_node(jsonnode json, cosmosstruc *cinfo, bool create_flag)
Setup JSON Namespace using Node description JSON.
Definition: jsonlib.cpp:6869
vector< uint16_t > rxr
Definition: jsondef.h:3914
double utc
UTC of Position.
Definition: convertdef.h:161
int i
Definition: rw_test.cpp:37
int32_t send_request(beatstruc cbeat, string request, string &output, float waitsec=5.)
Send a request over AGENT.
Definition: agentclass.cpp:424
Definition: cosmos-defs.h:101
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
rvector a
2nd derivative: Alpha - acceleration
Definition: convertdef.h:483
static antstruc target
Definition: agent_antenna.cpp:160
int32_t update_target(cosmosstruc *cinfo)
Update Track list.
Definition: jsonlib.cpp:11262
int32_t request_list_tracks(string &request, string &response, Agent *)
Definition: agent_control.cpp:688
int iretn
Definition: rw_test.cpp:37
void gauss_jackson_init_eci(gj_handle &gjh, uint32_t order, int32_t mode, double dt, double utc, cartpos ipos, qatt iatt, physicsstruc &physics, locstruc &loc)
Initialize Gauss-Jackson orbit using ECI state vector.
Definition: physicslib.cpp:2479
string to_unsigned(uint64_t value, uint16_t digits, bool zerofill)
Definition: stringlib.cpp:265
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
string output
Definition: agent-2-0.cpp:56
uint16_t tcv_cnt
Definition: jsondef.h:3888
uint16_t type
Definition: jsondef.h:1294
static string agentname
Definition: agent_control.cpp:140
string data_base_path(string node, string location, string agent, string filename)
Create data file path.
Definition: datalib.cpp:767
cosmosstruc * json_init()
Initialize JSON pointer map.
Definition: jsonlib.cpp:454
#define JPL_SUN
Definition: convertdef.h:120
vector< uint16_t > ant
Definition: jsondef.h:3895
const double DPI2
Double precision PI/2.
Definition: math/constants.h:18
static bool trackinit
Definition: agent_control.cpp:147
ElapsedTime et
Definition: agent_cpu_device_test.cpp:51
vector< uint16_t > txr
Definition: jsondef.h:3925
vector< string > data_list_nodes()
Get list of Nodes, directly.
Definition: datalib.cpp:583
rvector v
1st derivative: Omega - angular velocity
Definition: convertdef.h:481
#define JPL_MOON
Definition: convertdef.h:119
static string trajectoryname
Definition: agent_control.cpp:141
Definition: mathlib.h:361
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
uint16_t running()
Check if we're supposed to be running.
Definition: agentclass.cpp:391
Definition: cosmos-defs.h:90
Radio Transceiver.
Definition: jsondef.h:512
uint16_t txr_cnt
Definition: jsondef.h:3893
attstruc att
attstruc for this time.
Definition: convertdef.h:883
static vector< antennastruc > myantennas
Definition: agent_control.cpp:183
bool data_isfile(string path, off_t size)
Definition: datalib.cpp:1895
int32_t request_set_track(string &request, string &response, Agent *)
Definition: agent_control.cpp:700
string getAgent()
Definition: agentclass.cpp:2609
vector< uint16_t > tcv
Definition: jsondef.h:3920
double lap()
Lap Time.
Definition: elapsedtime.cpp:145
std::vector< cosmosstruc > nodes
Definition: agent_data-2-0.cpp:57
int32_t add_request(string token, external_request_function function, string synopsis="", string description="")
Add internal request to Agent request list with description and synopsis.
Definition: agentclass.cpp:312
void monitor()
Definition: agent_control.cpp:649
static char fname[100]
Definition: geomag.cpp:89
int32_t request_list_antennas(string &request, string &response, Agent *)
Definition: agent_control.cpp:877
Definition: agentclass.h:139
static vector< trackstruc > track
Definition: agent_control.cpp:175
qatt icrf
Definition: convertdef.h:830
string name
Definition: cubesat2obj.cpp:6
locstruc loc
Location structure.
Definition: jsondef.h:3596
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
int32_t shutdown()
Shutdown agent gracefully.
Definition: agentclass.cpp:366
double fixangle(double angle)
Limit angle to range 0-2PI.
Definition: mathlib.cpp:2159
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
double h
Height in meters.
Definition: vector.h:229
vector< locstruc > gauss_jackson_propagate(gj_handle &gjh, physicsstruc &physics, locstruc &loc, double tomjd)
Definition: physicslib.cpp:2871
string name
Definition: agent_control.cpp:170
gj_handle gjh
Definition: agent_node.cpp:80
double lon
Longitude in radians.
Definition: vector.h:227
static size_t highestindex
Definition: agent_control.cpp:163
double data_ctime(string path)
Definition: datalib.cpp:1910
rvector rv_zero()
Zero row order vector.
Definition: vector.cpp:107
int32_t load_lines_multi(string fname, vector< tlestruc > &lines)
Definition: convertlib.cpp:3714
void json_destroy(cosmosstruc *cinfo)
Remove JSON pointer map.
Definition: jsonlib.cpp:491
Definition: elapsedtime.h:62
#define JPL_EARTH
Definition: convertdef.h:112
string name
Definition: agent_control.cpp:151
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
targetstruc target
Definition: agent_control.cpp:168
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
double lat
Latitude in radians.
Definition: vector.h:225
int32_t request_unmatch_radio(string &request, string &response, Agent *)
Definition: agent_control.cpp:835
vector< radiostruc > radios
Definition: agent_control.cpp:173
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
backing_store_ptr info
Definition: jmemsys.h:181
float mass
Definition: jsondef.h:3425
beatstruc find_agent(string node, string agent, double waitsec=0.)
Find agent.
Definition: agentclass.cpp:559
int32_t request_match_radio(string &request, string &response, Agent *)
Definition: agent_control.cpp:778
locstruc loc
Definition: jsondef.h:1302
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
physicsstruc physics
Definition: agent_control.cpp:169
uint16_t ant_cnt
Definition: jsondef.h:3863
quaternion s
0th derivative: Quaternion
Definition: convertdef.h:479
Definition: cosmos-defs.h:100
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
uint16_t rxr_cnt
Definition: jsondef.h:3881
int32_t request_debug(string &request, string &response, Agent *)
Definition: agent_control.cpp:936
int32_t start_active_loop()
Definition: agentclass.cpp:347
cosmosstruc * cinfo
Definition: agentclass.h:346
cartpos eci
Definition: convertdef.h:737
FILE * fp
Definition: rw_test.cpp:38
quaternion q_eye()
Identity quaternion.
Definition: vector.cpp:1310
int32_t request_get_track(string &request, string &response, Agent *)
Definition: agent_control.cpp:751
static bool debug
Definition: agent_control.cpp:185
static size_t trackindex
Definition: agent_control.cpp:162
int32_t jplpos(long from, long to, double utc, cartpos *pos)
Position from JPL Ephemeris.
Definition: ephemlib.cpp:128
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
static float highestvalue
Definition: agent_control.cpp:164
Definition: jsondef.h:4199
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
Radio Transmitter.
Definition: jsondef.h:510
3 element geodetic vector
Definition: vector.h:222
Definition: cosmos-defs.h:98
physicsstruc phys
Definition: jsondef.h:3597
static vector< radiostruc > myradios
Definition: agent_control.cpp:160
static string nodename
Definition: agent_control.cpp:139
int tle2eci(double utc, tlestruc tle, cartpos &eci)
Definition: convertlib.cpp:3466
int32_t request_get_state(string &request, string &response, Agent *)
Definition: agent_control.cpp:887
#define CLIGHT
Speed of light.
Definition: convertdef.h:49
string to_double(double value, uint16_t precision)
Definition: stringlib.cpp:285