|
|
|
@ -55,6 +55,21 @@ void cb_posctl_btncalib (GtkWidget *widget, gpointer data) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cb_posctl_btnstop (GtkWidget *widget, gpointer data) {
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
posctl.Stop();
|
|
|
|
|
posctl_gui_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cb_posctl_btncontrol (GtkWidget *widget, gpointer data) {
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
posctl.StartControl();
|
|
|
|
|
posctl_gui_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cb_posctl_show (GtkWidget *widget, gpointer data) {
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
posctl_gui_update();
|
|
|
|
@ -299,7 +314,8 @@ void posctl_gui_update() {
|
|
|
|
|
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 *cbenable = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_enablectl"));
|
|
|
|
|
GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_stop"));
|
|
|
|
|
GtkWidget *btncontrol = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_control"));
|
|
|
|
|
|
|
|
|
|
GtkWidget *e_cal_rotangle = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_rotangle"));
|
|
|
|
|
GtkWidget *e_cal_rotlen = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_entry_rotlen"));
|
|
|
|
@ -336,13 +352,14 @@ void posctl_gui_update() {
|
|
|
|
|
|
|
|
|
|
if (m == POSCTL_MODE_OFF) {
|
|
|
|
|
gtk_widget_set_sensitive(btnclib, true);
|
|
|
|
|
gtk_widget_set_sensitive(btncontrol, true);
|
|
|
|
|
gtk_widget_set_sensitive(btnstop, false);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1min, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1center, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1max, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a2min, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a2center, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a2max, true);
|
|
|
|
|
gtk_widget_set_sensitive(cbenable, true);
|
|
|
|
|
gtk_widget_set_sensitive(e_posdevice, true);
|
|
|
|
|
gtk_label_set_label(GTK_LABEL(caliblabel), (char *) "");
|
|
|
|
|
}
|
|
|
|
@ -351,7 +368,8 @@ void posctl_gui_update() {
|
|
|
|
|
gtk_label_set_label(GTK_LABEL(caliblabel), (char *) "running");
|
|
|
|
|
}
|
|
|
|
|
gtk_widget_set_sensitive(btnclib, false);
|
|
|
|
|
gtk_widget_set_sensitive(cbenable, false);
|
|
|
|
|
gtk_widget_set_sensitive(btncontrol, false);
|
|
|
|
|
gtk_widget_set_sensitive(btnstop, true);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1min, false);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1center, false);
|
|
|
|
|
gtk_widget_set_sensitive(btn_a1max, false);
|
|
|
|
@ -457,6 +475,9 @@ void PosCtl::StartControl() {
|
|
|
|
|
printf ("%s:%d mode is not off, can't start control.\n", __FILE__, __LINE__);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
printf ("%s:%d %s start controlling Target:%f , %f\n", __FILE__, __LINE__, __FUNCTION__,
|
|
|
|
|
target_pos.x, target_pos.y);
|
|
|
|
|
|
|
|
|
|
pid_axis[0].Start();
|
|
|
|
|
pid_axis[1].Start();
|
|
|
|
|
mode = POSCTL_MODE_CONTROL;
|
|
|
|
@ -606,6 +627,44 @@ void PosCtl::Loop (int posx, int posy) {
|
|
|
|
|
gdk_threads_add_idle(cb_thread_posctl, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// dist_axis1+axis2 should contain the lot distance to the
|
|
|
|
|
// of the calibrated axis vector with the starting point at target_pos
|
|
|
|
|
// if the current position is below the axis line, the distance must be negative.
|
|
|
|
|
//
|
|
|
|
|
// this distance must be controlled by the PID axis controller.
|
|
|
|
|
// dist_axis1 --> will control pid_axis2
|
|
|
|
|
// dist_axis2 --> will control pis_axis1
|
|
|
|
|
else if (mode == POSCTL_MODE_CONTROL) {
|
|
|
|
|
double dist_axis1, out1;
|
|
|
|
|
double dist_axis2, out2;
|
|
|
|
|
position_f_2d p;
|
|
|
|
|
|
|
|
|
|
LockMutex();
|
|
|
|
|
|
|
|
|
|
// calculate
|
|
|
|
|
// dist_axis < 0.0 pid should increase the output.
|
|
|
|
|
// > 0.0 pid should decrease the output
|
|
|
|
|
p.x = posx; p.y = posy;
|
|
|
|
|
dist_axis1 = calib_axis1_v.perpendicular(p, target_pos);
|
|
|
|
|
dist_axis2 = calib_axis2_v.perpendicular(p, target_pos);
|
|
|
|
|
|
|
|
|
|
out1 = pid_axis[0].Update(0.0, dist_axis2);
|
|
|
|
|
out2 = pid_axis[1].Update(0.0, dist_axis1);
|
|
|
|
|
|
|
|
|
|
OutputWriteValue(0, out1);
|
|
|
|
|
OutputWriteValue(1, out2);
|
|
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
LockMutex();
|
|
|
|
|
target_pos.x = posx;
|
|
|
|
|
target_pos.y = posy;
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -698,6 +757,7 @@ int PosCtl::OutputWriteValue (int axis, double value) {
|
|
|
|
|
char outbuf[255];
|
|
|
|
|
printf ("%s:%d %s Axis %d Value:%f\n", __FILE__, __LINE__, __FUNCTION__, axis, value);
|
|
|
|
|
|
|
|
|
|
if (isnan(value)) return -1;
|
|
|
|
|
if (device_type == POSCTL_DEVTYPE_SIM) {
|
|
|
|
|
simulation.AxisSetValue(axis, value);
|
|
|
|
|
return 0;
|
|
|
|
|