FaRoC (Fanuc Robot Control): a Python package for FANUC industrial robots
Project description
FaRoC (Fanuc Robot Control)
A Python library for communication with Fanuc robots. It can read data from the controller, write data to the controller, execute TP and Karel program, and move the robot.
Functionality and features
FaRoC is based on two works:
- fanucpy: Python package for FANUC industrial robots (https://github.com/torayeff/fanucpy)
- Fanuc DPM Mouse Demo (https://github.com/gavanderhoorn/fanuc_dpm_mouse_demo)
Fanucpy uses ASCII data transfer, whereas FaRoC uses BINARY data transfer for these reasons:
Quote from KAREL Reference Manual:
"Binary I/O is preferred to text I/O when creating files that are to be read only by KAREL programs for the following reasons:
- Positional, VECTOR, and PATH variables cannot be read directly from text input.
- Some formats and data combinations are not read in the same manner as they were written in text files or they become invalid if read with the same format.
- Binary data is generally more compact, reducing both the file size and the I/O time.
- There is some inevitable loss of precision when converting from REAL data to its ASCII representation and back.
Generally, no format specifiers need to be used with binary I/O. If this rule is followed, all input data can be read exactly as it was before it was written."
Fanucpy has these functionalities so far:
Attribute | Funktion |
---|---|
Current joint values (JOINTPOS) | GET |
Current pose (XYZWPR, without config) | GET |
TP Program - uses CALL_PROG |
START |
Move Robot to a given JOINTPOS - uses CALL_PROG |
START |
Move Robot to a given XYZWPR - uses CALL_PROG |
START |
I/O -> Robot OUT (RO) | GET, SET |
Instantaneous power consumption | GET |
When the robot is moved using the standard move method by specifying the XYZWPR position, the configuration cannot be specified explicitly. Instead, the current configuration of the robot is used by the controller to uniquely determine the pose.
Due to Fanucpy's ASCII data transfer, the data must be converted to strings before transfer. Fanucpy rounds the data to the third decimal place, which may not be sufficient for some applications.
Furthermore, the CALL_PROG
method included in Karel is used when external TP programs are executed or when the robot is moved, but this interrupts the running program.
The calling program, e.g. mapdk_server.kl, is not resumed until the program started by CALL_PROG
or the robot movement is finished.
During the interruption no communication between client and server is possible.
FaRoC provides the functionalities described in fanucpy and extends them by further functions:
Attribute | Funktion |
---|---|
Current joint values (JOINTPOS) | GET |
Current pose (XYZWPR and config) | GET |
External Program (KAREL or TP) - uses RUN_TASK or CALL_PROG |
START, ABORT, GET TYPE, CHECK STATUS, GET TASK INFO |
Move Robot to a given JOINTPOS - uses RUN_TASK or CALL_PROG - change one or more joint values |
START, ABORT |
Move Robot to a given XYZWPR - uses RUN_TASK or CALL_PROG - change one or more pose values |
START, ABORT |
I/O -> Robot OUT (RO) | GET, SET |
I/O -> SIUMLATED Robot IN (RI) | GET |
System variables - supported types: REAL, INTEGER, BOOLEAN, BYTE, SHORT and STRING |
GET, SET, GET TYPE |
Program variables - supported types: REAL, INTEGER, BOOLEAN, BYTE, SHORT and STRING |
GET, SET, GET TYPE |
Robot USER or TOOL frame | GET, SET |
number of the used USER or TOOL frame | GET, SET |
KAREL internal USER or TOOL frame | GET, SET |
I/O -> Flag | GET, SET |
DATA Regsiter ( R ) | GET, SET |
Comment for DATA Regsiter | GET, SET |
DATA String Regsiter (SR) | GET, SET |
Comment for DATA String Regsiter | GET, SET |
Position Regsiter (PR) | GET, SET, GET TYPE |
Pose (XYZWPR) | IS REACHABLE, CONVERT TO JOINTPOS |
Joint values (JOINTPOS) | IS REACHABLE, CONVERT TO XYZWPR |
RSI | ENABLE, DISABLE, IS ENABLE |
Robot Time | GET, SET |
Fanuc alarm code / KAREL status | Provide error details |
With FaRoC both of the methods CALL_PROG
and RUN_TASK
included in KAREL can be used to execute external TP or KAREL programs or to move the robot.
Unlike CALL_PROG
, the program called by RUN_TASK
runs in parallel with the calling program.
So the communication with the client is not interrupted and the server can still answer requests.
To provide Fanuc alarm code / KAREL status details, data has been extracted from the FANUC manual: OPERATOR'S MANUAL (Alarm Code List) | R-30+B CONTROLLER | B-83284EN-1/02.
Software contents
The package consists of two parts:
- Robot interface code written in Python programming language
- FANUC robot controller driver written in KAREL and FANUC teach pendant languages
Requirements
The following is needed for FaRoC software to work:
- Roboguide or physical robot
- R-30iB controller (
V8.xx
and up), with:R632
- KARELR648
- User Socket Msg
- Python
>= 3.6
To develop and test this software, a Fanuc M-900iB/700
robot with an R-30iB controller (V8.30
) was used. Roboguide version 9 (Rev.Z) was also used.
Python package installation
pip install faroc
Driver Building
You can use the command line OR Roboguide to build the *.kl files contained in src\fanuc-driver\
.
Command line
If ktrans.exe
is not installed in the default location (ie:C:\Program Files (x86)\Fanuc\WinOLPC\bin
),
open build.cmd
from src
-> fanuc-driver
and update the KTRANS_BIN
variable.
If ktrans.exe
is on the Windows PATH
, simply setting it to ktrans.exe
should also work.
If you need to build for a runtime software version other than V8.30
, change CORE_VERSION
as well.
Tip: You can use REM
to comment a line.
Now run build.cmd
in a command shell.
.\build
Six p-code files should be created.
Roboguide
Open build.cmd
from src
-> fanuc-driver
.
Add all Karel programs listed in build.cmd
and the three TP programs (*.ls
files) to your Roboguide
workcell and build them.
Driver Installation
Roboguide should have automatically uploaded the Karel programs to the virtual controller. Loading the TP program should copy it as well.
If build.cmd
was used, add the .pc
and .ls
files to the project and
load them onto the (virtual) controller. Alternatively an FTP client could be
used.
Configuration
Host Comm (SERVER)
Setup two Server Tags, Nr. 7 & 8, to use the SM
protocol and make sure to set
Startup State
to START
. Use the [ACTION]
menu to start the Tag
immediately, or restart the controller. The SETUP Server config can be found in MENU -> SETUP -> Host Comm. -> SHOW -> Servers.
FaRoC_SERVER
Open the KAREL Vars on the controller for FaRoC_SERVER
(after selecting it, i.e. SELECT -> FaRoC_Server -> ENTER -> MENU -> DATA -> KAREL Vars), switch to the cfg_
field, open the
structure and enter the following values:
S_TCP_PORT : 24087
S_TAG_NR : 7
UM_CLEAR : TRUE
Configure the rest automatically
Now you can start the TP program FAROC
. On the computer initialize an object of class FaRoC_Writer
and connect it to the server.
The rest of the configuration can be done with the script demo_FaRoC_setup.py
.
Finally, you will have to restart the controller to apply the changes.
Otherwise you can do it manually as follows:
Configure the rest manually
FaRoC_MOVER
Open the KAREL Vars for FaRoC_MOVER
, switch to the cfg_
field, open the
structure and enter the following values:
S_TCP_PORT : 24088
S_TAG_NR : 8
UM_CLEAR : FALSE
UFRAM_NUM : 1
UTOOL_NUM : 1
Host Comm (CLIENT)
In order to use FaRoC_dclnt1
set up a Client Tags, e.g. No. 1 to use the SM
protocol and
make sure the Startup State
is set to START
.
Set Server IP/Hostname
to the ip adress of the pc you want to use for socket messaging, e.g. 127.0.0.1
in case of Roboguide.
Use the [ACTION]
menu to start the Tag immediately, or restart the controller.
We use binary data transfare, so we need to set the system variable$HOSTC_CFG[1].$USE_UDP
to TRUE
A cleint tag is configured for each data client. You can configure up to 8 data clients if required. Each client can send up to 32 variables. If more data is needed simultaneously, new Data Clients (Karel programme) can simply be copied (the programme name must be changed in the file) and new 'client tags' can be configured as above.
Disclaimer
The author of this software is not affiliated with FANUC Corporation in any way. All trademarks and registered trademarks are property of their respective owners, and company, product and service names mentioned in this readme or appearing in source code or other artefacts in this repository are used for identification purposes only. Use of these names does not imply endorsement by FANUC Corporation.
References
Below is a list of resources that have been used as reference and inspiration for the development of FaRoc.
- fanucpy: Python package for FANUC industrial robots
- Fanuc DPM Mouse Demo
- OPERATOR'S MANUAL (Alarm Code List) | R-30+B CONTROLLER | B-83284EN-1/02
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.