Skip to content

Commit 7eeafad

Browse files
authored
Merge pull request #3481 from itaib/homing-abort
Abort homing on all joints when encoutering an error while homing any single joint
2 parents 9bfdb69 + e0c3b39 commit 7eeafad

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/emc/motion/homing.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,8 @@ static int base_1joint_state_machine(int joint_num)
757757
if (H[joint_num].home_flags & HOME_IS_SHARED && home_sw_active) {
758758
rtapi_print_msg(RTAPI_MSG_ERR, _("Cannot home while shared home switch is closed j=%d"),
759759
joint_num);
760-
H[joint_num].home_state = HOME_IDLE;
760+
H[joint_num].home_state = HOME_ABORT;
761+
immediate_state = 1;
761762
break;
762763
}
763764
/* set flags that communicate with the rest of EMC */
@@ -815,7 +816,8 @@ static int base_1joint_state_machine(int joint_num)
815816
} else {
816817
rtapi_print_msg(RTAPI_MSG_ERR,
817818
_("invalid homing config: non-zero LATCH_VEL needs either SEARCH_VEL or USE_INDEX"));
818-
H[joint_num].home_state = HOME_IDLE;
819+
H[joint_num].home_state = HOME_ABORT;
820+
immediate_state = 1;
819821
}
820822
} else {
821823
if (H[joint_num].home_latch_vel != 0.0) {
@@ -825,7 +827,8 @@ static int base_1joint_state_machine(int joint_num)
825827
} else {
826828
rtapi_print_msg(RTAPI_MSG_ERR,
827829
_("invalid homing config: non-zero SEARCH_VEL needs LATCH_VEL"));
828-
H[joint_num].home_state = HOME_IDLE;
830+
H[joint_num].home_state = HOME_ABORT;
831+
immediate_state = 1;
829832
}
830833
}
831834
break;
@@ -974,7 +977,8 @@ static int base_1joint_state_machine(int joint_num)
974977
rtapi_print_msg(RTAPI_MSG_ERR,
975978
_("Home switch inactive before start of backoff move j=%d"),
976979
joint_num);
977-
H[joint_num].home_state = HOME_IDLE;
980+
H[joint_num].home_state = HOME_ABORT;
981+
immediate_state = 1;
978982
break;
979983
}
980984
/* set up a move at '-search_vel' to back off of switch */
@@ -1022,7 +1026,8 @@ static int base_1joint_state_machine(int joint_num)
10221026
if (home_sw_active) {
10231027
rtapi_print_msg(RTAPI_MSG_ERR, _("Home switch active before start of latch move j=%d"),
10241028
joint_num);
1025-
H[joint_num].home_state = HOME_IDLE;
1029+
H[joint_num].home_state = HOME_ABORT;
1030+
immediate_state = 1;
10261031
break;
10271032
}
10281033
/* set up a move at 'latch_vel' to locate the switch */
@@ -1079,7 +1084,8 @@ static int base_1joint_state_machine(int joint_num)
10791084
rtapi_print_msg(RTAPI_MSG_ERR,
10801085
_("Home switch inactive before start of latch move j=%d"),
10811086
joint_num);
1082-
H[joint_num].home_state = HOME_IDLE;
1087+
H[joint_num].home_state = HOME_ABORT;
1088+
immediate_state = 1;
10831089
break;
10841090
}
10851091
/* set up a move at 'latch_vel' to locate the switch */
@@ -1351,12 +1357,14 @@ static int base_1joint_state_machine(int joint_num)
13511357
break;
13521358

13531359
case HOME_ABORT:
1354-
H[joint_num].homing = 0;
1355-
H[joint_num].homed = 0;
1356-
H[joint_num].joint_in_sequence = 0;
1357-
joint->free_tp.enable = 0;
1358-
H[joint_num].home_state = HOME_IDLE;
1359-
H[joint_num].index_enable = 0;
1360+
for(int i = 0; i < all_joints; i++) {
1361+
H[i].homing = 0;
1362+
H[i].homed = 0;
1363+
H[i].joint_in_sequence = 0;
1364+
joint[i].free_tp.enable = 0;
1365+
H[i].home_state = HOME_IDLE;
1366+
H[i].index_enable = 0;
1367+
}
13601368
immediate_state = 1;
13611369
break;
13621370

0 commit comments

Comments
 (0)