Commit 5e200b8e authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Accellerate sattracker when picking up

parent 13b65893
......@@ -56,7 +56,8 @@
#define EL_HORIZON -1.0
#define NEXTPASS_RANGE_T (3600 * 24)
#define COORD_NR 50
#define MAX_ELEV 50.
#define MAX_ELEV 48.
#define MAX_ELEV_TIME 30
char *command_host = "localhost";
......@@ -77,7 +78,8 @@ struct predict *predict = NULL;
static bool passknown = false;
time_t delay;
static double az_aos = 0;
static double az_maxelev = 0;
static double az_maxelev = 0, az_maxelev_plus = 0, el_maxelev_plus = 0;
static double t_maxelev = 0;
static time_t t_aos;
static time_t t_los;
struct status_server *stat_srv;
......@@ -132,6 +134,7 @@ void nextpass(struct predict *predict)
/* this is a pass */
if (above_maxelev && el < MAX_ELEV) {
az_maxelev = az;
t_maxelev = tnow + i;
log_send(LOG_T_DEBUG,
"Going below max elev at azimuth %f", az_maxelev);
above_maxelev = false;
......@@ -141,6 +144,10 @@ void nextpass(struct predict *predict)
log_send(LOG_T_DEBUG,
"Going above max elev at azimuth %f", az);
}
if (tnow + i == t_maxelev + MAX_ELEV_TIME) {
az_maxelev_plus = az;
el_maxelev_plus = el;
}
if (az < -90.0 && prev_az > 90.0) {
/* crossed north */
prev_az -= 360.0;
......@@ -187,6 +194,7 @@ void nextpass(struct predict *predict)
if (az_aos < -90) {
az_aos += 360;
az_maxelev += 360;
az_maxelev_plus += 360;
}
} else if (times_after_cross_east >= times_before_cross_east &&
times_after_cross_east >= times_before_cross_west &&
......@@ -194,6 +202,7 @@ void nextpass(struct predict *predict)
/* if we begin with start az we go through east in wrong way first */
az_aos += 360;
az_maxelev += 360;
az_maxelev_plus += 360;
} else if (times_before_cross_west >= times_before_cross_east &&
times_before_cross_west >= times_after_cross_east &&
times_before_cross_west >= times_after_cross_west) {
......@@ -201,10 +210,12 @@ void nextpass(struct predict *predict)
if (az_aos > 90) {
az_aos -= 360;
az_maxelev -= 360;
az_maxelev_plus -= 360;
}
} else {
az_aos -= 360;
az_maxelev -= 360;
az_maxelev_plus -= 360;
}
if (az_aos > 270.0)
......@@ -470,6 +481,8 @@ int main(int argc, char **argv)
"Preset to aos position %f -> %f",
az, az_aos);
az += copysign(360.0, az_aos);
az_maxelev += copysign(360.0, az_aos);
az_maxelev_plus += copysign(360.0, az_aos);
}
check_swap = check_az;
check_az = false;
......@@ -486,9 +499,13 @@ int main(int argc, char **argv)
log_send(LOG_T_DEBUG,
"Swapping AZ");
az += copysign(360.0, last_az);
az_maxelev += copysign(360.0, last_az);
az_maxelev_plus += copysign(360.0, last_az);
if (check_swap && (az > 270.0 || az < -270.0)) {
log_send(LOG_T_DEBUG, "Swap not possible!");
az -= copysign(360.0, last_az);
az_maxelev -= copysign(360.0, last_az);
az_maxelev_plus -= copysign(360.0, last_az);
}
}
}
......@@ -535,30 +552,41 @@ int main(int argc, char **argv)
if (switch_enabled) {
struct command_entry entry;
if (el < MAX_ELEV) {
log_send(LOG_T_DEBUG, "Setpoint: %d %f %f %f",
(unsigned int)t, JD, az, el);
entry.type = COMMAND_PTYPE_SETPOINT_TIME;
entry.t.tv_sec = t;
entry.t.tv_nsec = 0;
entry.type = COMMAND_PTYPE_SETPOINT_TIME;
entry.t.tv_sec = t;
entry.t.tv_nsec = 0;
entry.value.f = az * 2 * M_PI / 360.0;
if (t > t_maxelev - MAX_ELEV_TIME && t < t_maxelev + MAX_ELEV_TIME) {
// Accelerate going downwards to pick up satellite again
log_send(LOG_T_DEBUG,
"Speeding up");
log_send(LOG_T_DEBUG, "Setpoint override accellerate: %d %f %f %f (not %f %f)",
(unsigned int)t, JD, az_maxelev_plus, el_maxelev_plus, az, el);
entry.value.f = az_maxelev_plus * 2 * M_PI / 360.0;
command_send(sp_command_az, &entry);
entry.value.f = el * 2 * M_PI / 360.0;
entry.value.f = el_maxelev_plus * 2 * M_PI / 360.0;
command_send(sp_command_el, &entry);
} else {
} else if (el > MAX_ELEV) {
// Too high, go to point where to pick up satellite again
log_send(LOG_T_DEBUG,
"Above max elev");
entry.type = COMMAND_PTYPE_SETPOINT_TIME;
entry.t.tv_sec = t;
entry.t.tv_nsec = 0;
entry.value.f = az_maxelev * 2 * M_PI / 360.0;
log_send(LOG_T_DEBUG, "Setpoint override: %d %f %f %f (not %f %f)",
(unsigned int)t, JD, az_maxelev, MAX_ELEV, az, el);
entry.value.f = az_maxelev * 2 * M_PI / 360.0;
command_send(sp_command_az, &entry);
entry.value.f = MAX_ELEV * 2 * M_PI / 360.0;
command_send(sp_command_el, &entry);
} else {
// Normal tracking
log_send(LOG_T_DEBUG, "Setpoint: %d %f %f %f",
(unsigned int)t, JD, az, el);
entry.value.f = az * 2 * M_PI / 360.0;
command_send(sp_command_az, &entry);
entry.value.f = el * 2 * M_PI / 360.0;
command_send(sp_command_el, &entry);
}
} else {
struct command_entry entry;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment