Commit 5f3aa23c authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

prevent large moves

parent f829ab49
......@@ -359,6 +359,11 @@ int main(int argc, char **argv)
az * 2 * M_PI / 360.0, t);
setpoint_command_setpoint_time(sp_command_el,
el * 2 * M_PI / 360.0, t);
} else {
/* not enabled, send idle just in case we were
still moving */
setpoint_command_speed(sp_command_az, 0.0);
setpoint_command_speed(sp_command_el, 0.0);
}
}
......
......@@ -67,7 +67,7 @@ char tle_str[139] =
struct location *location;
struct predict *predict = NULL;
void set_tle(void)
bool set_tle(char newtle[139])
{
double lat, lon, alt;
......@@ -76,14 +76,18 @@ void set_tle(void)
alt = location_get_altitude(location);
printf("Using lat: %f, lon: %f, alt: %f\n", lat, lon, alt);
if (predict_tle_check(tle_str)) {
if (predict_tle_check(newtle)) {
printf("Invallid TLE\n");
return;
return false;
}
strcpy(tle_str, newtle);
if (predict)
predict_free(predict);
predict = predict_create(tle_str, lat, lon, alt);
return true;
}
......@@ -91,6 +95,7 @@ void set_tle(void)
bool refraction_enable = false;
bool dt_model_enable = false;
bool switch_enabled = false;
bool switch_cmd = false;
struct compensation_switch {
char *name;
......@@ -203,14 +208,20 @@ void handle_cmd(struct cmd_client *cmd)
printf("found switch %s\n", name);
if (val[0] == '1') {
*compensation_switches[i].value = true;
if (!strcmp(name, "enabled")) {
switch_cmd = true;
}
} else {
*compensation_switches[i].value = false;
}
}
}
if (!strcmp(name, "tle")) {
strcpy(tle_str, val);
set_tle();
char newtle[139];
strcpy(newtle, val);
if (!set_tle(newtle))
switch_enabled = false;
}
}
}
......@@ -328,7 +339,7 @@ int main(int argc, char **argv)
alt = location_get_altitude(location);
printf("Using lat: %f, lon: %f, alt: %f\n", lat, lon, alt);
set_tle();
set_tle(tle_str);
signal(SIGPIPE, SIG_IGN);
......@@ -415,17 +426,16 @@ int main(int argc, char **argv)
/* check if we might have compensate 360 degrees to
prevent large az steps
*/
if (az > 90.0 || az < -90.0) {
/* If the sat is very low,
don't bother swapping */
printf("fabs(%f - %f): %f\n", last_az,az,fabs(last_az- az));
if (el > -20.0) {
if (az > 90.0 || az < -90.0) {
/* large step? */
if (fabs(last_az - az) > 200.0) {
printf("Swapping AZ\n");
az += copysign(360.0, last_az);
}
}
if (switch_cmd && fabs(last_az - az) > 180.0) {
switch_enabled = false;
}
last_az = az;
......@@ -444,6 +454,7 @@ int main(int argc, char **argv)
setpoint_command_speed(sp_command_az, 0.0);
setpoint_command_speed(sp_command_el, 0.0);
}
switch_cmd = false;
}
FD_ZERO(&fdset_rx);
......
......@@ -354,6 +354,11 @@ int main(int argc, char **argv)
az * 2 * M_PI / 360.0, t);
setpoint_command_setpoint_time(sp_command_el,
el * 2 * M_PI / 360.0, t);
} else {
/* not enabled, send idle just in case we were
still moving */
setpoint_command_speed(sp_command_az, 0.0);
setpoint_command_speed(sp_command_el, 0.0);
}
}
......
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