|
|
@ -55,8 +55,7 @@ void axis_history_add(int axis, double diff, double out) {
|
|
|
|
axis_history[axis][axis_history_pos[axis]].out = out;
|
|
|
|
axis_history[axis][axis_history_pos[axis]].out = out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CALIB_MAXSPEED 1.0
|
|
|
|
#define CALIB_MAXSPEED 2.0
|
|
|
|
|
|
|
|
#define CALIB_DURATION_DELTA 10.0
|
|
|
|
#define CALIB_DURATION_DELTA 10.0
|
|
|
|
#define CALIB_DURATION_AXIS (CALIB_DURATION_DELTA / CALIB_MAXSPEED)
|
|
|
|
#define CALIB_DURATION_AXIS (CALIB_DURATION_DELTA / CALIB_MAXSPEED)
|
|
|
|
|
|
|
|
|
|
|
@ -407,6 +406,8 @@ void posctl_gui_update() {
|
|
|
|
char txt[255];
|
|
|
|
char txt[255];
|
|
|
|
double kp, ki, kd, mi, ma;
|
|
|
|
double kp, ki, kd, mi, ma;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *caliblabel = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_calib_label"));
|
|
|
|
GtkWidget *caliblabel = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_calib_label"));
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *btnclib = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_calib"));
|
|
|
|
GtkWidget *btnclib = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_calib"));
|
|
|
@ -436,12 +437,14 @@ void posctl_gui_update() {
|
|
|
|
GtkWidget *a1_ki = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a1_ki"));
|
|
|
|
GtkWidget *a1_ki = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a1_ki"));
|
|
|
|
GtkWidget *a1_kd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a1_kd"));
|
|
|
|
GtkWidget *a1_kd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a1_kd"));
|
|
|
|
GtkWidget *a1_out = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_outx"));
|
|
|
|
GtkWidget *a1_out = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_outx"));
|
|
|
|
|
|
|
|
GtkWidget *a1_pv = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_dx"));
|
|
|
|
GtkWidget *a2_min = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_min"));
|
|
|
|
GtkWidget *a2_min = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_min"));
|
|
|
|
GtkWidget *a2_max = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_max"));
|
|
|
|
GtkWidget *a2_max = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_max"));
|
|
|
|
GtkWidget *a2_kp = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_kp"));
|
|
|
|
GtkWidget *a2_kp = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_kp"));
|
|
|
|
GtkWidget *a2_ki = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_ki"));
|
|
|
|
GtkWidget *a2_ki = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_ki"));
|
|
|
|
GtkWidget *a2_kd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_kd"));
|
|
|
|
GtkWidget *a2_kd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_a2_kd"));
|
|
|
|
GtkWidget *a2_out = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_outy"));
|
|
|
|
GtkWidget *a2_out = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_outy"));
|
|
|
|
|
|
|
|
GtkWidget *a2_pv = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_lb_dy"));
|
|
|
|
|
|
|
|
|
|
|
|
posctl.LockMutex();
|
|
|
|
posctl.LockMutex();
|
|
|
|
int m = posctl.GetMode();
|
|
|
|
int m = posctl.GetMode();
|
|
|
@ -491,34 +494,40 @@ void posctl_gui_update() {
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(e_cal_a2len), txt);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(e_cal_a2len), txt);
|
|
|
|
|
|
|
|
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(e_posdevice), posctl.GetDevice().c_str());
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(e_posdevice), posctl.GetDevice().c_str());
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.out[0]);
|
|
|
|
|
|
|
|
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.axis_op[0]);
|
|
|
|
gtk_label_set_text(GTK_LABEL(a1_out), txt);
|
|
|
|
gtk_label_set_text(GTK_LABEL(a1_out), txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.out[1]);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.axis_op[1]);
|
|
|
|
gtk_label_set_text(GTK_LABEL(a2_out), txt);
|
|
|
|
gtk_label_set_text(GTK_LABEL(a2_out), txt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.axis_pv[0]);
|
|
|
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(a1_pv), txt);
|
|
|
|
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", posctl.axis_pv[1]);
|
|
|
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(a2_pv), txt);
|
|
|
|
|
|
|
|
|
|
|
|
posctl.GetAxisParam(0, &mi, &ma, &kp, &ki, &kd);
|
|
|
|
posctl.GetAxisParam(0, &mi, &ma, &kp, &ki, &kd);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", mi);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", mi);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a1_min), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a1_min, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ma);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ma);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a1_max), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a1_max, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kp);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kp);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a1_kp), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a1_kp, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ki);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ki);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a1_ki), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a1_ki, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kd);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kd);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a1_kd), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a1_kd, txt);
|
|
|
|
|
|
|
|
|
|
|
|
posctl.GetAxisParam(1, &mi, &ma, &kp, &ki, &kd);
|
|
|
|
posctl.GetAxisParam(1, &mi, &ma, &kp, &ki, &kd);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", mi);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", mi);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a2_min), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a2_min, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ma);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ma);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a2_max), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a2_max, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kp);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kp);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a2_kp), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a2_kp, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ki);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", ki);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a2_ki), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a2_ki, txt);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kd);
|
|
|
|
strfromd (txt, sizeof(txt-1), (const char *)"%f", kd);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY(a2_kd), txt);
|
|
|
|
gtk_entry_set_text_nofocus (a2_kd, txt);
|
|
|
|
|
|
|
|
|
|
|
|
posctl.UnLockMutex();
|
|
|
|
posctl.UnLockMutex();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -742,8 +751,6 @@ void PosCtl::Loop (int posx, int posy) {
|
|
|
|
// dist_axis1 --> will control pid_axis2
|
|
|
|
// dist_axis1 --> will control pid_axis2
|
|
|
|
// dist_axis2 --> will control pis_axis1
|
|
|
|
// dist_axis2 --> will control pis_axis1
|
|
|
|
else if (mode == POSCTL_MODE_CONTROL) {
|
|
|
|
else if (mode == POSCTL_MODE_CONTROL) {
|
|
|
|
double dist_axis1, out1;
|
|
|
|
|
|
|
|
double dist_axis2, out2;
|
|
|
|
|
|
|
|
position_f_2d p;
|
|
|
|
position_f_2d p;
|
|
|
|
double d;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
|
|
|
@ -756,21 +763,21 @@ void PosCtl::Loop (int posx, int posy) {
|
|
|
|
d = calib_axis1_v.perpendicular(calib_axis2_v, p);
|
|
|
|
d = calib_axis1_v.perpendicular(calib_axis2_v, p);
|
|
|
|
|
|
|
|
|
|
|
|
p.x = posx; p.y = posy;
|
|
|
|
p.x = posx; p.y = posy;
|
|
|
|
dist_axis1 = calib_axis1_v.perpendicular(p, target_pos);
|
|
|
|
axis_pv[0] = calib_axis2_v.perpendicular(p, target_pos);
|
|
|
|
dist_axis2 = calib_axis2_v.perpendicular(p, target_pos);
|
|
|
|
axis_pv[1] = calib_axis1_v.perpendicular(p, target_pos);
|
|
|
|
out1 = pid_axis[0].Update(0.0, dist_axis1);
|
|
|
|
axis_op[0] = pid_axis[0].Update(0.0, axis_pv[0]);
|
|
|
|
out2 = pid_axis[1].Update(0.0, dist_axis2);
|
|
|
|
axis_op[1] = pid_axis[1].Update(0.0, axis_pv[1]);
|
|
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
printf ("%s:%d %s", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
printf (" d: %+6.3f ", d);
|
|
|
|
printf (" d: %+6.3f ", d);
|
|
|
|
printf (" Axis1 [dist:%+6.3f out1:%+6.3f] ", dist_axis1, out1);
|
|
|
|
printf (" Axis1 [dist:%+6.3f out1:%+6.3f] ", axis_pv[0], axis_op[0]);
|
|
|
|
printf (" Axis2 [dist:%+6.3f out2:%+6.3f]\n", dist_axis2, out2);
|
|
|
|
printf (" Axis2 [dist:%+6.3f out2:%+6.3f]\n", axis_pv[1], axis_op[1]);
|
|
|
|
|
|
|
|
|
|
|
|
OutputWriteValue(0, out2);
|
|
|
|
OutputWriteValue(0, axis_op[0]);
|
|
|
|
OutputWriteValue(1, out1);
|
|
|
|
OutputWriteValue(1, axis_op[1]);
|
|
|
|
|
|
|
|
|
|
|
|
axis_history_add(0, dist_axis1, out1);
|
|
|
|
axis_history_add(0, axis_pv[0], axis_op[0]);
|
|
|
|
axis_history_add(1, dist_axis2, out2);
|
|
|
|
axis_history_add(1, axis_pv[1], axis_op[1]);
|
|
|
|
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
UnLockMutex();
|
|
|
|
gdk_threads_add_idle(cb_thread_posctl, NULL);
|
|
|
|
gdk_threads_add_idle(cb_thread_posctl, NULL);
|
|
|
|