adding calibration debuging information

master
Steffen Pohle 2 years ago
parent da15e98d2d
commit bffbea0637

@ -18,6 +18,7 @@
class Configuration {
private:
int histogram_log = 1; // logarithmic or linear scale
int calibration_showdata = 0; // needed for debugging calibration
JSONParse config;
std::string GetDefaultFileName();
@ -41,6 +42,9 @@ public:
void SetHistogramLog(int trueorfalse);
int GetHistogramLog() { return histogram_log; };
void SetCalibrationShowData(int enabled) { calibration_showdata = enabled; };
int GetCalibrationShowData() { return calibration_showdata; };
void SetPresetButton (int btn, list<VideoDevCtrl> *parameters);
list<VideoDevCtrl> GetPresetButton (int btn);
};

@ -69,6 +69,15 @@ enum {
};
struct PosCtl_ThreadData {
position_2d c[2];
position_2d a1[2];
position_2d a2[2];
int mode;
};
class PosCtl {
private:
GMutex mutex;
@ -85,6 +94,9 @@ class PosCtl {
int calib_mode;
position_2d calib_pos;
struct PosCtl_ThreadData threaddata; // will be copied to gtk thread
void NotifyGtk();
void CalibModeStart(int x, int y);
void CalibModeDelta(int x, int y);
void CalibModeAxis(int x, int y);

@ -205,6 +205,7 @@ G_MODULE_EXPORT void cb_posctl_track_draw(GtkWidget *area, cairo_t *cr, int w, i
// menu elements
G_MODULE_EXPORT void cb_menu_set_rgbenc (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
G_MODULE_EXPORT void cb_menu_set_histlog (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
G_MODULE_EXPORT void cb_menu_set_displaycalibdata(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
//
// error handling

@ -46,6 +46,8 @@ struct AxisHistory {
struct AxisHistory axis_history[2][AXIS_HISTORY_CNT];
int axis_history_pos[2] = { 0, 0 };
struct PosCtl_ThreadData posctl_calib_debug;
void axis_history_add(int axis, double diff, double out) {
if (axis > 1 || axis < 0) return;
@ -99,8 +101,16 @@ void cb_posctl_btncontrol (GtkWidget *widget, gpointer data) {
posctl_gui_update();
}
void cb_menu_set_displaycalibdata(GtkCheckMenuItem *checkmenuitem, gpointer user_data) {
if (gtk_check_menu_item_get_active(checkmenuitem) == TRUE) config.SetCalibrationShowData(true);
else config.SetCalibrationShowData(false);
}
void cb_posctl_show (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
posctl_calib_debug.mode = -1;
posctl_gui_update();
}
@ -569,6 +579,7 @@ void posctl_gui_update() {
gboolean cb_thread_posctl (gpointer data) {
GtkWidget *da1 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_axis1"));
GtkWidget *da2 = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_axis2"));
GtkWidget *tg = NULL;
posctl_gui_update();
@ -579,6 +590,47 @@ gboolean cb_thread_posctl (gpointer data) {
posctl_rot_da = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_da_rotation"));
gdk_window_invalidate_rect(gtk_widget_get_window(posctl_rot_da), NULL, true);
if (data != NULL) {
posctl_calib_debug = *(struct PosCtl_ThreadData*) data;
free (data);
switch (posctl_calib_debug.mode) {
case (POSCTL_CALIB_MODE_OFF):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_off"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_STOP1):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_rs"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_DELTAM):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_r"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_AXIS1START):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_a1s"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_AXIS1M):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_a1"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_AXIS2START):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_a2s"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_AXIS2M):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_a2"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
case (POSCTL_CALIB_MODE_FINISH):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_f"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
break;
default:
break;
}
}
return false;
};
@ -607,7 +659,51 @@ PosCtl::PosCtl() {
void PosCtl::Stop() {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
mode = POSCTL_MODE_OFF;
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
}
void PosCtl::NotifyGtk() {
int i;
struct PosCtl_ThreadData *data = (struct PosCtl_ThreadData*) malloc(sizeof(struct PosCtl_ThreadData));
threaddata.mode = calib_mode;
switch (calib_mode) {
case(POSCTL_CALIB_MODE_STOP1):
for (i = 0; i < 2; i++) {
threaddata.c[i].x = threaddata.c[i].y = -1;
threaddata.a1[1].x = threaddata.a1[i].y = -1;
threaddata.a2[1].x = threaddata.a2[i].y = -1;
}
break;
case(POSCTL_CALIB_MODE_DELTAM):
threaddata.c[0].x = calib_pos.x;
threaddata.c[0].y = calib_pos.y;
break;
case(POSCTL_CALIB_MODE_AXIS1START):
threaddata.c[1].x = calib_pos.x;
threaddata.c[1].y = calib_pos.y;
break;
case(POSCTL_CALIB_MODE_AXIS1M):
threaddata.a1[0].x = calib_pos.x;
threaddata.a1[0].y = calib_pos.y;
break;
case(POSCTL_CALIB_MODE_AXIS2START):
threaddata.a1[1].x = calib_pos.x;
threaddata.a1[1].y = calib_pos.y;
break;
case(POSCTL_CALIB_MODE_AXIS2M):
threaddata.a2[0].x = calib_pos.x;
threaddata.a2[0].y = calib_pos.y;
break;
case(POSCTL_CALIB_MODE_FINISH):
threaddata.a2[1].x = calib_pos.x;
threaddata.a2[1].y = calib_pos.y;
break;
default:
break;
}
*(struct PosCtl_ThreadData*)data = threaddata;
gdk_threads_add_idle(cb_thread_posctl, data);
}
@ -623,7 +719,7 @@ void PosCtl::StartCalibration() {
mode = POSCTL_MODE_CALIB;
calib_mode = POSCTL_CALIB_MODE_STOP1;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
}
void PosCtl::StartControl() {
@ -637,7 +733,7 @@ void PosCtl::StartControl() {
pid_axis[0].Start();
pid_axis[1].Start();
mode = POSCTL_MODE_CONTROL;
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
}
@ -673,7 +769,7 @@ void PosCtl::CalibModeStart(int x, int y) {
calib_mode = POSCTL_CALIB_MODE_STOP1;
if (OutputWriteStop()) mode = POSCTL_MODE_OFF;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
};
@ -692,7 +788,7 @@ void PosCtl::CalibModeWait(int x, int y) {
calib_pos.y = y;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
}
}
@ -727,7 +823,9 @@ void PosCtl::CalibModeDelta(int x, int y) {
if (OutputWriteValue(0, pid_axis[0].GetMax())) mode = POSCTL_MODE_OFF;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
calib_pos.x = x;
calib_pos.y = y;
NotifyGtk();
}
};
@ -762,7 +860,10 @@ void PosCtl::CalibModeAxis(int x, int y) {
if (calib_mode != POSCTL_CALIB_MODE_OFF) calib_mode++;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
calib_pos.x = x;
calib_pos.y = y;
NotifyGtk();
}
};
@ -776,7 +877,7 @@ void PosCtl::CalibModeFinish() {
if (OutputWriteValue(0, 0.5 * (pid_axis[0].GetMin() + pid_axis[0].GetMax()))) mode = POSCTL_MODE_OFF;
if (OutputWriteValue(1, 0.5 * (pid_axis[1].GetMin() + pid_axis[1].GetMax()))) mode = POSCTL_MODE_OFF;
gettimeofday (&calib_timestamp, NULL);
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
};
@ -813,7 +914,7 @@ void PosCtl::Loop (int posx, int posy) {
default:
calib_mode = POSCTL_CALIB_MODE_OFF;
mode = POSCTL_MODE_OFF;
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
break;
}
}
@ -858,7 +959,7 @@ void PosCtl::Loop (int posx, int posy) {
axis_history_add(1, axis_pv[1], axis_op[1]);
UnLockMutex();
gdk_threads_add_idle(cb_thread_posctl, NULL);
NotifyGtk();
}
else {

@ -993,6 +993,149 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="cal_mode_off">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_rs">
<property name="label" translatable="yes">RS</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_r">
<property name="label" translatable="yes">R</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_a1s">
<property name="label" translatable="yes">A1S</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_a1">
<property name="label" translatable="yes">A1</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_a2s">
<property name="label" translatable="yes">A2S</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="margin-bottom">1</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_a2">
<property name="label" translatable="yes">A2</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="cal_mode_f">
<property name="label" translatable="yes">F</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">cal_mode_off</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -2159,6 +2302,14 @@ Image Data</property>
<signal name="toggled" handler="cb_menu_set_histlog" swapped="no"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="menu-settings-debugcalibration">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Display Calibration Data</property>
<signal name="toggled" handler="cb_menu_set_displaycalibdata" swapped="no"/>
</object>
</child>
</object>
</child>
</object>

@ -31,6 +31,8 @@ extern position_2d video_enterdata_pos;
extern detect_movement detectedpos_data;
extern Configuration config;
extern struct PosCtl_ThreadData posctl_calib_debug;
void videoctrl_grid_delete ();
void videoctrl_grid_build ();
@ -238,6 +240,42 @@ void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data)
gtk_label_set_text(GTK_LABEL(lbX), txt1);
gtk_label_set_text(GTK_LABEL(lbY), txt2);
if (config.GetCalibrationShowData()) {
// printf ("%s:%d posctl_calib_debug.c : %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.c[0].x, posctl_calib_debug.c[0].y,
// posctl_calib_debug.c[1].x, posctl_calib_debug.c[1].y);
// printf ("%s:%d posctl_calib_debug.a1: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.a1[0].x, posctl_calib_debug.a1[0].y,
// posctl_calib_debug.a1[1].x, posctl_calib_debug.a1[1].y);
// printf ("%s:%d posctl_calib_debug.a2: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.a2[0].x, posctl_calib_debug.a2[0].y,
// posctl_calib_debug.a2[1].x, posctl_calib_debug.a2[1].y);
if (posctl_calib_debug.c[0].x != -1 && posctl_calib_debug.c[0].y != -1 &&
posctl_calib_debug.c[1].x != -1 && posctl_calib_debug.c[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.c[0].x), S_Y(posctl_calib_debug.c[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.c[1].x), S_Y(posctl_calib_debug.c[1].y));
cairo_stroke(cr);
}
if (posctl_calib_debug.a1[0].x != -1 && posctl_calib_debug.a1[0].y != -1 &&
posctl_calib_debug.a1[1].x != -1 && posctl_calib_debug.a1[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 0.5, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.a1[0].x), S_Y(posctl_calib_debug.a1[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.a1[1].x), S_Y(posctl_calib_debug.a1[1].y));
cairo_stroke(cr);
}
if (posctl_calib_debug.a2[0].x != -1 && posctl_calib_debug.a2[0].y != -1 &&
posctl_calib_debug.a2[1].x != -1 && posctl_calib_debug.a2[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 0.5, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.a2[0].x), S_Y(posctl_calib_debug.a2[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.a2[1].x), S_Y(posctl_calib_debug.a2[1].y));
cairo_stroke(cr);
}
}
#ifdef DEBUG_ANGLES
debug_angles_draw(cr);
#endif

Loading…
Cancel
Save