Add laser_tracking_cli_tool/src/tracking.c
This commit is contained in:
parent
aa564b5a88
commit
51fa986a51
1 changed files with 73 additions and 0 deletions
73
laser_tracking_cli_tool/src/tracking.c
Normal file
73
laser_tracking_cli_tool/src/tracking.c
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* tracking.c - Simulierte Implementierung der Tracking-API
|
||||||
|
*
|
||||||
|
* Startet kein echtes Laser-Tracking, sondern simuliert nur sinnvolle
|
||||||
|
* Statuswerte, z.B. kleine Winkelabweichungen und Zeitstempel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tracking.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
bool start_tracking(const char *target_satellite,
|
||||||
|
double elevation_angle,
|
||||||
|
tracking_status *status_out,
|
||||||
|
int debug)
|
||||||
|
{
|
||||||
|
if (target_satellite == NULL || status_out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elevation_angle < 0.0 || elevation_angle > 90.0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In einer echten Implementierung würden hier:
|
||||||
|
* - Hardware-Schnittstellen geöffnet
|
||||||
|
* - Sicherheitschecks durchgeführt
|
||||||
|
* - TLE-/Ephemeriden-Daten ausgewertet
|
||||||
|
* - Steuerbefehle an Motoren/Controller gesendet
|
||||||
|
* werden.
|
||||||
|
*
|
||||||
|
* Hier: nur eine einfache Simulation. */
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
printf("[DEBUG] (simulation) Initialisiere Tracking auf '%s' bei elev=%.2fdeg\n",
|
||||||
|
target_satellite, elevation_angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_out->active = true;
|
||||||
|
status_out->last_update = time(NULL);
|
||||||
|
|
||||||
|
/* Simulierte kleine Abweichung (z.B. 0.0–0.1 Grad) */
|
||||||
|
double r = (double)rand() / (double)RAND_MAX; /* in [0,1] */
|
||||||
|
status_out->deviation = r * 0.1; /* in [0,0.1] */
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
printf("[DEBUG] (simulation) deviation=%.4fdeg\n", status_out->deviation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_status(tracking_status *status_out)
|
||||||
|
{
|
||||||
|
if (status_out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In einem realen System würden hier aktuelle Daten der Hardware
|
||||||
|
* oder eines Steuerprozesses abgefragt. Wir generieren nur einen
|
||||||
|
* plausiblen Demo-Status, der zu einer laufenden Messung passt. */
|
||||||
|
|
||||||
|
status_out->active = true;
|
||||||
|
status_out->last_update = time(NULL);
|
||||||
|
|
||||||
|
/* Kleine, fluktuierende Abweichung (z.B. 0.0–0.2 Grad). */
|
||||||
|
double r = (double)rand() / (double)RAND_MAX; /* [0,1] */
|
||||||
|
status_out->deviation = r * 0.2; /* [0,0.2] */
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue