Skip to content

Commit 4804c9f

Browse files
committed
docs(FANUC): update to uniform register mapping; clarify status semantics; add pose frame behavior note (base→flange via temporary UF/UT save/restore)
1 parent 7c00d81 commit 4804c9f

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

FANUC/README_FANUC.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The interface uses familiar FANUC programming patterns:
2424
CALL GRI_TRIGGER_JOB_SYNC(1) ;
2525
2626
! Check result status
27-
IF R[150:gri obj status]=20,JMP LBL[object_found] ;
27+
IF R[150:gri error code]=0,JMP LBL[object_found] ;
2828
```
2929

3030
All communication complexity is handled internally, exposing only the essential functions needed for robot programming.
@@ -100,22 +100,25 @@ Optional example programs (load .ls files):
100100
- `R[143]` `gri param 1`: slot id (HEC_SET_POSE)
101101
- `R[144]` `gri param 2`: reserved
102102

103-
**Status Registers (KAREL → TP):**
104-
- `R[149]` `gri comm status`: handshake; 0 ready, -1 error/not running
105-
- `R[150]` `gri obj status`: function result for TP use (see notes below)
106-
- `R[151]` `gri status`: completion/error; 99 while processing, 0 on success, otherwise GRI error code
107-
- `R[152]` `gri data 1`: remaining primary items (e.g., for next/related)
108-
- `R[153]` `gri data 2`: remaining related items
103+
**Status Registers (KAREL → TP) - New uniform mapping:**
104+
- `R[149]` `gri comm status`: handshake; 0 ready, -1 stopped
105+
- `R[150]` `gri error code`: signed GRI status (<0 error, 0 ok, >0 warning)
106+
- `R[151]` `module return`: `data_1` (module/vendor code; can be <0/0/>0)
107+
- `R[152]` `remaining primary`: `data_2`
108+
- `R[153]` `remaining related`: `data_3`
109+
- `R[154]..R[159]` = `data_4..data_9`
110+
- `R[160]` = `data_10`
109111

110112
- Position registers
111113
- `PR[53]` `gri pose`: returned pose for job/next/related
112114

113115
- Notes on `R[150]/R[151]`
114116
- Pose-returning calls (`GRI_TRIGGER_JOB_SYNC`, `GRI_GET_NEXT_GRASP`, `GRI_GET_RELATED_GRASP`):
115-
- `R[150] = 20` → pose found; pose in `PR[53]`; remaining counts in `R[152]/R[153]`
116-
- If no pose or other error: `R[150] = 23`, and `R[151]` holds the specific error code (e.g., `13` = no poses)
117-
- Confirmation calls (`GRI_TRIGGER_JOB_ASYNC`, `GRI_HEC_*`): `R[150] = 1` on success; otherwise `23` with `R[151]` error code
118-
- Status call (`GRI_GET_JOB_STATUS`): `R[150] = 1|2|3|4` → INACTIVE|RUNNING|DONE|FAILED
117+
- On success: `R[150] = 0`; pose in `PR[53]`; counts in `R[152]/R[153]`
118+
- No poses: `R[150] = 1`
119+
- Errors: `R[150] < 0` (e.g., `-4` API_RESPONSE_ERROR; raw cause may be in `R[151]`)
120+
- Confirmation calls (`GRI_TRIGGER_JOB_ASYNC`, `GRI_HEC_*`): `R[150] = 0` on success; otherwise `<0` error, with detail possibly in `R[151]`
121+
- Status call (`GRI_GET_JOB_STATUS`): `R[150] = 0` on success; `R[152] = 1|2|3|4` → INACTIVE|RUNNING|DONE|FAILED
119122

120123

121124

@@ -131,7 +134,7 @@ Optional example programs (load .ls files):
131134
CALL GRI_TRIGGER_JOB_SYNC(1) ;
132135
133136
! Check if object was detected
134-
IF R[150:gri obj status]=20,JMP LBL[pick_object] ;
137+
IF R[150:gri error code]=0,JMP LBL[pick_object] ;
135138
MESSAGE[No parts detected] ;
136139
JMP LBL[cleanup] ;
137140
@@ -158,7 +161,7 @@ Optional example programs (load .ls files):
158161
CALL GRI_GET_NEXT_GRASP(1) ;
159162
160163
! Exit if no more objects
161-
IF R[150:gri obj status]<>20,JMP LBL[finished] ;
164+
IF R[150:gri error code]<>0,JMP LBL[finished] ;
162165
163166
! Process detected object
164167
J P[1:approach] 100% FINE ;
@@ -182,21 +185,21 @@ Optional example programs (load .ls files):
182185
```fanuc
183186
! Start vision job in background
184187
CALL GRI_TRIGGER_JOB_ASYNC(1) ;
185-
IF R[150:gri obj status]<>1, JMP LBL[async_failed] ;
188+
IF R[150:gri error code]<>0, JMP LBL[async_failed] ;
186189
187190
! Continue with other tasks
188191
CALL OTHER_ROBOT_OPERATIONS ;
189192
190193
! Poll job status until done
191194
LBL[poll] ;
192195
CALL GRI_GET_JOB_STATUS(1) ;
193-
IF R[150:gri obj status]=2, JMP LBL[poll] ; -- RUNNING
194-
IF R[150:gri obj status]<>3, JMP LBL[async_failed] ; -- not DONE
196+
IF R[152:gri data 1]=2, JMP LBL[poll] ; -- RUNNING
197+
IF R[152:gri data 1]<>3, JMP LBL[async_failed] ; -- not DONE
195198
196199
! Job is DONE → fetch results
197200
LBL[next] ;
198201
CALL GRI_GET_NEXT_GRASP(1) ;
199-
IF R[150:gri obj status]<>20, JMP LBL[finished] ;
202+
IF R[150:gri error code]<>0, JMP LBL[finished] ;
200203
L PR[53:gri pose] 150mm/sec FINE ;
201204
IF R[152:gri data 1]>0, JMP LBL[next] ;
202205
LBL[finished] ;
@@ -209,15 +212,7 @@ LBL[after] ;
209212

210213
## Status Codes
211214

212-
The system uses register R[150] for all status reporting:
213-
214-
| Status | Description |
215-
|--------|-------------|
216-
| 20 | Object detected, pose available in PR[53] |
217-
| 23 | Error occurred (check `R[151]` for specific code, e.g., 13 = no poses) |
218-
| 1 | Success (for confirmation functions like HEC, async trigger) |
219-
220-
For job status (`GRI_GET_JOB_STATUS`): `R[150] = 1|2|3|4` → INACTIVE|RUNNING|DONE|FAILED.
215+
R[150] carries signed status: `<0` error, `0` ok, `>0` warning. For pose-returning calls, success (`0`) means a pose is available in `PR[53]`. For job status (`GRI_GET_JOB_STATUS`), `R[150]=0` on success and the job state is in `R[152]` (1..4).
221216

222217
## Hand-Eye Calibration
223218

@@ -232,7 +227,7 @@ Quick start using the example program:
232227
! Initialize calibration
233228
CALL GRI_OPEN_COMMUNICATION ;
234229
CALL GRI_HEC_INIT(0) ;
235-
IF R[150:gri obj status]<>1,JMP LBL[error] ;
230+
IF R[150:gri error code]<>0,JMP LBL[error] ;
236231
237232
! Capture calibration poses
238233
J P[10:cal_pos_1] 100% FINE ;
@@ -248,7 +243,7 @@ CALL GRI_HEC_SET_POSE(0,8) ;
248243
249244
! Execute calibration
250245
CALL GRI_HEC_CALIBRATE(0) ;
251-
IF R[150:gri obj status]=1,MESSAGE[Calibration complete] ;
246+
IF R[150:gri error code]=0,MESSAGE[Calibration complete] ;
252247
253248
CALL GRI_QUIT ;
254249
```
@@ -315,6 +310,12 @@ The FANUC GRI client uses a layered architecture:
315310
- **Background Module**: Compiled KAREL `.pc` (`gri_comm_background.pc`) handling socket/protocol and register bridging
316311
- **TCP Socket**: Binary protocol communication with vision system
317312

313+
### Pose Frame Behavior
314+
315+
- The background module reads the current robot pose for protocol exchange as base (UF[0]) to flange (UT[0]).
316+
- Implementation detail: it temporarily saves and sets `$MNUFRAMENUM[1]`/`$MNUTOOLNUM[1]` to `0` only for the `CURPOS(0,0)` call, then restores the previous values immediately. This guarantees a deterministic world→flange pose independent of the active user/tool frames.
317+
- Future versions may replace this with a math-based conversion that avoids any temporary frame changes.
318+
318319
## Deployment Checklist
319320

320321
- [ ] `gri_comm_background.pc` loaded
@@ -339,7 +340,7 @@ CALL SETUP_GRIPPER ;
339340
! Add vision capability
340341
CALL GRI_OPEN_COMMUNICATION ;
341342
CALL GRI_TRIGGER_JOB_SYNC(1) ;
342-
IF R[150:gri obj status]=20,CALL PROCESS_VISION_RESULT ;
343+
IF R[150:gri error code]=0,CALL PROCESS_VISION_RESULT ;
343344
CALL GRI_QUIT ;
344345
345346
! Continue with existing logic
@@ -352,7 +353,7 @@ Integrate GRI error handling with your existing error management:
352353

353354
```fanuc
354355
CALL GRI_TRIGGER_JOB_SYNC(1) ;
355-
SELECT R[150:gri obj status] OF
356+
SELECT R[150:gri error code] OF
356357
CASE(20):
357358
CALL PROCESS_OBJECT ;
358359
CASE(23):

0 commit comments

Comments
 (0)