Using AXIS_RA/DEC consistently

master
Stefan Jahn 2 years ago
parent 62fd3c84fc
commit a41c7566ae

@ -133,12 +133,12 @@ void cb_posctl_btn_axismove (GtkWidget *widget, gpointer data) {
posctl.GetAxisParam(0, &ramin, &ramax, NULL, NULL, NULL); posctl.GetAxisParam(0, &ramin, &ramax, NULL, NULL, NULL);
posctl.GetAxisParam(1, &decmin, &decmax, NULL, NULL, NULL); posctl.GetAxisParam(1, &decmin, &decmax, NULL, NULL, NULL);
if (widget == btn_ramin) posctl.OutputWriteValue(AXIS_DEC, ramin); if (widget == btn_ramin) posctl.OutputWriteValue(AXIS_RA, ramin);
else if (widget == btn_racenter) posctl.OutputWriteValue(AXIS_DEC, (ramax-ramin)/2.0+ramin); else if (widget == btn_racenter) posctl.OutputWriteValue(AXIS_RA, (ramax-ramin)/2.0+ramin);
else if (widget == btn_ramax) posctl.OutputWriteValue(AXIS_DEC, ramax); else if (widget == btn_ramax) posctl.OutputWriteValue(AXIS_RA, ramax);
else if (widget == btn_decmin) posctl.OutputWriteValue(AXIS_RA, decmin); else if (widget == btn_decmin) posctl.OutputWriteValue(AXIS_DEC, decmin);
else if (widget == btn_deccenter) posctl.OutputWriteValue(AXIS_RA, (decmax-decmin)/2.0+decmin); else if (widget == btn_deccenter) posctl.OutputWriteValue(AXIS_DEC, (decmax-decmin)/2.0+decmin);
else if (widget == btn_decmax) posctl.OutputWriteValue(AXIS_RA, decmax); else if (widget == btn_decmax) posctl.OutputWriteValue(AXIS_DEC, decmax);
posctl_gui_update(); posctl_gui_update();
} }
@ -336,8 +336,8 @@ void cb_posctl_entryanglelen (GtkWidget *widget, gpointer data) {
#define AXIS_DIFF_MAX 20.0 #define AXIS_DIFF_MAX 20.0
void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data) { void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data) {
GtkWidget *da1 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_ra")); GtkWidget *dra = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_ra"));
GtkWidget *da2 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_dec")); GtkWidget *ddec = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_dec"));
position_2d center; position_2d center;
int axis = 0 , i, cnt; int axis = 0 , i, cnt;
@ -365,8 +365,8 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
cairo_stroke(cr); cairo_stroke(cr);
cairo_set_dash(cr, NULL, 0, 0); cairo_set_dash(cr, NULL, 0, 0);
if (da1 == area) axis = 0; if (dra == area) axis = 0;
else if (da2 == area) axis = 1; else if (ddec == area) axis = 1;
else { else {
cairo_move_to(cr, 30, 0); cairo_move_to(cr, 30, 0);
cairo_show_text(cr, (char *)"unknown"); cairo_show_text(cr, (char *)"unknown");
@ -581,14 +581,14 @@ void posctl_gui_update() {
* the gtk/gui updates must and will be processed in a separate gui thread * the gtk/gui updates must and will be processed in a separate gui thread
*/ */
gboolean cb_thread_posctl (gpointer data) { gboolean cb_thread_posctl (gpointer data) {
GtkWidget *da1 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_ra")); GtkWidget *dra = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_ra"));
GtkWidget *da2 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_dec")); GtkWidget *ddec = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_dec"));
GtkWidget *tg = NULL; GtkWidget *tg = NULL;
posctl_gui_update(); posctl_gui_update();
gtk_widget_queue_draw(da1); gtk_widget_queue_draw(dra);
gtk_widget_queue_draw(da2); gtk_widget_queue_draw(ddec);
if (posctl_rot_da == NULL) // should only be called once if (posctl_rot_da == NULL) // should only be called once
posctl_rot_da = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_rotation")); posctl_rot_da = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_rotation"));
@ -798,7 +798,6 @@ void PosCtl::CalibModeWait(int x, int y) {
void PosCtl::CalibModeDelta(int x, int y) { void PosCtl::CalibModeDelta(int x, int y) {
struct timeval tv; struct timeval tv;
float timediff; float timediff;
double ramin, ramax;
float dist = hypot ((float)(x - calib_pos.x), (float)(y - calib_pos.y)); float dist = hypot ((float)(x - calib_pos.x), (float)(y - calib_pos.y));
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
@ -808,7 +807,6 @@ void PosCtl::CalibModeDelta(int x, int y) {
position_f_2d fp; position_f_2d fp;
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
pid_axis[0].GetParam(&ramin, &ramax, NULL, NULL, NULL);
fp.x = (x - calib_pos.x) / (float)timediff; fp.x = (x - calib_pos.x) / (float)timediff;
fp.y = (y - calib_pos.y) / (float)timediff; fp.y = (y - calib_pos.y) / (float)timediff;
@ -822,7 +820,7 @@ void PosCtl::CalibModeDelta(int x, int y) {
calib_mode = POSCTL_CALIB_MODE_AXIS1START; calib_mode = POSCTL_CALIB_MODE_AXIS1START;
if (OutputWriteStop()) mode = POSCTL_MODE_OFF; if (OutputWriteStop()) mode = POSCTL_MODE_OFF;
if (OutputWriteValue(0, pid_axis[0].GetMax())) mode = POSCTL_MODE_OFF; if (OutputWriteValue(AXIS_RA, pid_axis[AXIS_RA].GetMax())) mode = POSCTL_MODE_OFF;
gettimeofday (&calib_timestamp, NULL); gettimeofday (&calib_timestamp, NULL);
calib_pos.x = x; calib_pos.x = x;
@ -853,7 +851,7 @@ void PosCtl::CalibModeAxis(int x, int y) {
calib_axis1_v = fp - calib_rot_v; calib_axis1_v = fp - calib_rot_v;
calc_vec2anglelen(&calib_axis1_v, &calib_axis1); calc_vec2anglelen(&calib_axis1_v, &calib_axis1);
if (OutputWriteStop()) mode = POSCTL_MODE_OFF; if (OutputWriteStop()) mode = POSCTL_MODE_OFF;
else if (OutputWriteValue(1, pid_axis[1].GetMax())) mode = POSCTL_MODE_OFF; else if (OutputWriteValue(AXIS_DEC, pid_axis[AXIS_DEC].GetMax())) mode = POSCTL_MODE_OFF;
} }
else if (calib_mode == POSCTL_CALIB_MODE_AXIS2M) { else if (calib_mode == POSCTL_CALIB_MODE_AXIS2M) {
calib_axis2_v = fp - calib_rot_v; calib_axis2_v = fp - calib_rot_v;
@ -876,8 +874,8 @@ void PosCtl::CalibModeFinish() {
mode = POSCTL_MODE_OFF; mode = POSCTL_MODE_OFF;
calib_mode = POSCTL_CALIB_MODE_OFF; calib_mode = POSCTL_CALIB_MODE_OFF;
if (OutputWriteStop()) mode = POSCTL_MODE_OFF; if (OutputWriteStop()) mode = POSCTL_MODE_OFF;
if (OutputWriteValue(0, 0.5 * (pid_axis[0].GetMin() + pid_axis[0].GetMax()))) mode = POSCTL_MODE_OFF; if (OutputWriteValue(AXIS_RA, 0.5 * (pid_axis[AXIS_RA].GetMin() + pid_axis[AXIS_RA].GetMax()))) mode = POSCTL_MODE_OFF;
if (OutputWriteValue(1, 0.5 * (pid_axis[1].GetMin() + pid_axis[1].GetMax()))) mode = POSCTL_MODE_OFF; if (OutputWriteValue(AXIS_DEC, 0.5 * (pid_axis[AXIS_DEC].GetMin() + pid_axis[AXIS_DEC].GetMax()))) mode = POSCTL_MODE_OFF;
gettimeofday (&calib_timestamp, NULL); gettimeofday (&calib_timestamp, NULL);
NotifyGtk(); NotifyGtk();
}; };
@ -942,14 +940,14 @@ void PosCtl::Loop (int posx, int posy) {
// > 0.0 pid should decrease the output // > 0.0 pid should decrease the output
target_p.x = target_pos.x; target_p.y = target_pos.y; target_p.x = target_pos.x; target_p.y = target_pos.y;
p.x = posx; p.y = posy; p.x = posx; p.y = posy;
axis_pv[0] = calib_axis2_v.perpendicular(p, target_pos); axis_pv[AXIS_RA] = calib_axis2_v.perpendicular(p, target_pos);
axis_pv[1] = calib_axis1_v.perpendicular(p, target_pos); axis_pv[AXIS_DEC] = calib_axis1_v.perpendicular(p, target_pos);
axis_op[0] = pid_axis[0].Update(0.0, axis_pv[0]); axis_op[AXIS_RA] = pid_axis[AXIS_RA].Update(0.0, axis_pv[AXIS_RA]);
axis_op[1] = pid_axis[1].Update(0.0, axis_pv[1]); axis_op[AXIS_DEC] = pid_axis[AXIS_DEC].Update(0.0, axis_pv[AXIS_DEC]);
#ifdef DEBUG_POSCTL #ifdef DEBUG_POSCTL
pid_axis[0].GetParam(NULL, NULL, &kp0, &ki0, &kd0); pid_axis[AXIS_RA].GetParam(NULL, NULL, &kp0, &ki0, &kd0);
pid_axis[1].GetParam(NULL, NULL, &kp1, &ki1, &kd1); pid_axis[AXIS_DEC].GetParam(NULL, NULL, &kp1, &ki1, &kd1);
debug_tofile((char*)"posctl.log", 0, (char*)"%d , %g,%g , %d,%d,%g,%g,%g,%g , %g,%g , %g,%g,%g,%g,%g , %g,%g , %g,%g,%g,%g,%g\n", debug_tofile((char*)"posctl.log", 0, (char*)"%d , %g,%g , %d,%d,%g,%g,%g,%g , %g,%g , %g,%g,%g,%g,%g , %g,%g , %g,%g,%g,%g,%g\n",
mode, calib_rot.a, calib_rot.l, mode, calib_rot.a, calib_rot.l,
posx, posy, target_pos.x, target_pos.y, posx - target_pos.x, posy - target_pos.y, posx, posy, target_pos.x, target_pos.y, posx - target_pos.x, posy - target_pos.y,
@ -957,7 +955,7 @@ void PosCtl::Loop (int posx, int posy) {
calib_axis2.a, calib_axis2.l, axis_pv[1], axis_op[1],kp1,ki1,kd1); calib_axis2.a, calib_axis2.l, axis_pv[1], axis_op[1],kp1,ki1,kd1);
#endif #endif
if (OutputWriteValue(0, axis_op[0]) || OutputWriteValue(1, axis_op[1])) if (OutputWriteValue(AXIS_RA, axis_op[AXIS_RA]) || OutputWriteValue(AXIS_DEC, axis_op[AXIS_DEC]))
mode = POSCTL_MODE_OFF; mode = POSCTL_MODE_OFF;
axis_history_add(0, axis_pv[0], axis_op[0]); axis_history_add(0, axis_pv[0], axis_op[0]);

Loading…
Cancel
Save