@@ -158,6 +158,7 @@ static int axis_mask = 0;
158158 ARRAY(hal_bit_t ,jjog_increment_minus,EMCMOT_MAX_JOINTS+1 ) /* Incremental jogging, negative direction */ \
159159\
160160 FIELD(hal_float_t ,ajog_speed) /* pin for setting the jog speed (halui internal) */ \
161+ FIELD(hal_float_t ,ajog_speed_angular) /* pin for setting the angular jog speed (halui internal) */ \
161162 ARRAY(hal_bit_t ,ajog_minus,EMCMOT_MAX_AXIS+1 ) /* pin to jog in positive direction */ \
162163 ARRAY(hal_bit_t ,ajog_plus,EMCMOT_MAX_AXIS+1 ) /* pin to jog in negative direction */ \
163164 ARRAY(hal_float_t ,ajog_analog,EMCMOT_MAX_AXIS+1 ) /* pin for analog jogging (-1..0..1) */ \
@@ -250,6 +251,8 @@ static local_halui_str old_halui_data;
250251
251252static double lastjogspeed = 0 ;
252253static double internaljogspeed = 0 ;
254+ static double lastangularjogspeed = 0 ;
255+ static double internalangularjogspeed = 0 ;
253256static int lastaxis = -1 ;
254257
255258static char *mdi_commands[MDI_MAX];
@@ -1068,6 +1071,8 @@ int halui_hal_init(void)
10681071
10691072 retval = halui_export_pin_IN_float (&(halui_data->ajog_speed ), " halui.axis.jog-speed" );
10701073 if (retval < 0 ) return retval;
1074+ retval = halui_export_pin_IN_float (&(halui_data->ajog_speed_angular ), " halui.axis.jog-speed-angular" );
1075+ if (retval < 0 ) return retval;
10711076 retval = halui_export_pin_IN_float (&(halui_data->ajog_deadband ), " halui.axis.jog-deadband" );
10721077 if (retval < 0 ) return retval;
10731078
@@ -1787,6 +1792,7 @@ static void hal_init_pins()
17871792 *(halui_data->ajog_increment_minus [EMCMOT_MAX_AXIS]) = old_halui_data.ajog_increment_minus [EMCMOT_MAX_AXIS] = 0 ;
17881793 *(halui_data->ajog_deadband ) = 0.2 ;
17891794 *(halui_data->ajog_speed ) = 0 ;
1795+ *(halui_data->ajog_speed_angular ) = 0 ;
17901796
17911797 *(halui_data->joint_selected ) = 0 ; // select joint 0 by default
17921798 *(halui_data->axis_selected ) = -1 ; // select no axis by default
@@ -1890,9 +1896,55 @@ static void py_call_axis_jogspeed(double speed)
18901896 Py_DECREF (pFuncWrite);
18911897}
18921898
1899+ static double py_call_axis_get_angular_jogspeed () {
1900+ double jspd = 0 ;
1901+ // check socket messages for angular jogspeed
1902+ pFuncRead = PyObject_GetAttrString (pInstance, " getJogRateAngular" );
1903+ if (pFuncRead && PyCallable_Check (pFuncRead)) {
1904+ pValue = PyObject_CallNoArgs (pFuncRead);
1905+ if (pValue == NULL ){
1906+ fprintf (stderr, " Halui Bridge: getJogRateAngular function failed: returned NULL\n " );
1907+ jspd = 0 ;
1908+ }else {
1909+ if (PyFloat_Check (pValue)) {
1910+ jspd = PyFloat_AsDouble (pValue);
1911+ if (PyErr_Occurred ()) {
1912+ jspd = 0 ;
1913+ // Handle conversion error
1914+ PyErr_Print ();
1915+ // Clear the error state if needed
1916+ PyErr_Clear ();
1917+ }
1918+ }
1919+ }
1920+ Py_DECREF (pValue);
1921+ }
1922+ Py_DECREF (pFuncRead);
1923+ return jspd;
1924+ }
1925+
1926+ static void py_call_axis_angular_jogspeed (double speed)
1927+ {
1928+ pFuncWrite = PyObject_GetAttrString (pInstance, " setJogRateAngular" );
1929+
1930+ if (pFuncWrite && PyCallable_Check (pFuncWrite)) {
1931+ pValue = PyObject_CallFunction (pFuncWrite, " d" , speed);
1932+ if (pValue == NULL ){
1933+ fprintf (stderr, " halui bridge: setJogRateAngular function failed: returned NULL\n " );
1934+ if (PyErr_Occurred ()) PyErr_Print ();
1935+ }
1936+ Py_DECREF (pValue);
1937+
1938+ }else {
1939+ if (PyErr_Occurred ()) PyErr_Print ();
1940+ fprintf (stderr, " halui Bridge: Failed python function" );
1941+ }
1942+ Py_DECREF (pFuncWrite);
1943+ }
1944+
18931945static int py_call_get_axis_selected () {
18941946 int value = 0 ;
1895- // check socket messages for jogspeed
1947+ // check socket messages for selected axis
18961948 pFuncRead = PyObject_GetAttrString (pInstance, " getSelectedAxis" );
18971949 if (pFuncRead && PyCallable_Check (pFuncRead)) {
18981950 pValue = PyObject_CallNoArgs (pFuncRead);
@@ -1968,8 +2020,10 @@ static void check_hal_changes()
19682020 int js;
19692021 hal_float_t floatt;
19702022 double jogspeed;
2023+ double angularjogspeed;
19712024 int jjog_speed_changed;
19722025 int ajog_speed_changed;
2026+ int ajog_speed_angular_changed;
19732027 int is_any_axis_selected, deselected;
19742028
19752029 // get python to process socket messages
@@ -2236,6 +2290,7 @@ static void check_hal_changes()
22362290 } else {
22372291 jjog_speed_changed = 0 ;
22382292 }
2293+
22392294// axis stuff (selection, homing..)
22402295 aselect_changed = -1 ; // flag to see if the selected joint changed
22412296
@@ -2259,7 +2314,27 @@ static void check_hal_changes()
22592314 fprintf (stderr, " JogRate value = %f\n " , jogspeed );
22602315 }
22612316
2262-
2317+ // if the ANGULAR jog-speed changes while in a continuous jog, we want to
2318+ // re-start the jog with the new speed
2319+ if (fabs (old_halui_data.ajog_speed_angular - new_halui_data.ajog_speed_angular ) > 0.00001 ) {
2320+ old_halui_data.ajog_speed_angular = new_halui_data.ajog_speed_angular ;
2321+ internalangularjogspeed = new_halui_data.ajog_speed_angular ;
2322+ ajog_speed_angular_changed = 1 ;
2323+ py_call_axis_angular_jogspeed (internalangularjogspeed);
2324+ } else {
2325+ ajog_speed_angular_changed = 0 ;
2326+ }
2327+
2328+ // check socket messages for ANGULAR jogspeed
2329+ angularjogspeed = py_call_axis_get_angular_jogspeed ();
2330+ if (fabs (angularjogspeed - lastangularjogspeed) > 0.00001 ) {
2331+ ajog_speed_angular_changed = 1 ;
2332+ lastangularjogspeed = angularjogspeed;
2333+ internalangularjogspeed = angularjogspeed;
2334+ fprintf (stderr, " angular JogRate value = %f\n " , angularjogspeed );
2335+ }
2336+
2337+
22632338 for (joint=0 ; joint < num_joints; joint++) {
22642339 if (check_bit_changed (new_halui_data.joint_home [joint], old_halui_data.joint_home [joint]) != 0 )
22652340 sendHome (joint);
0 commit comments