Package: faroc
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 featuresFaRoC 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:AttributeFunktionCurrent joint values (JOINTPOS)GETCurrent pose (XYZWPR, without config)GETTP Program- usesCALL_PROGSTARTMove Robot to a given JOINTPOS- usesCALL_PROGSTARTMove Robot to a given XYZWPR- usesCALL_PROGSTARTI/O -> Robot OUT (RO)GET, SETInstantaneous power consumptionGETWhen 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, theCALL_PROGmethod 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 byCALL_PROGor 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:AttributeFunktionCurrent joint values (JOINTPOS)GETCurrent pose (XYZWPR and config)GETExternal Program (KAREL or TP)- usesRUN_TASKorCALL_PROGSTART, ABORT,GET TYPE, CHECK STATUS, GET TASK INFOMove Robot to a given JOINTPOS- usesRUN_TASKorCALL_PROG- change one or more joint valuesSTART, ABORTMove Robot to a given XYZWPR- usesRUN_TASKorCALL_PROG- change one or more pose valuesSTART, ABORTI/O -> Robot OUT (RO)GET, SETI/O -> SIUMLATED Robot IN (RI)GETSystem variables- supported types: REAL, INTEGER, BOOLEAN, BYTE, SHORT and STRINGGET, SET, GET TYPEProgram variables- supported types: REAL, INTEGER, BOOLEAN, BYTE, SHORT and STRINGGET, SET, GET TYPERobot USER or TOOL frameGET, SETnumber of the used USER or TOOL frameGET, SETKAREL internal USER or TOOL frameGET, SETI/O -> FlagGET, SETDATA Regsiter ( R )GET, SETComment for DATA RegsiterGET, SETDATA String Regsiter (SR)GET, SETComment for DATA String RegsiterGET, SETPosition Regsiter (PR)GET, SET, GET TYPEPose (XYZWPR)IS REACHABLE, CONVERT TO JOINTPOSJoint values (JOINTPOS)IS REACHABLE, CONVERT TO XYZWPRRSIENABLE, DISABLE, IS ENABLERobot TimeGET, SETFanuc alarm code / KAREL statusProvide error detailsWith FaRoC both of the methodsCALL_PROGandRUN_TASKincluded in KAREL can be used to execute external TP or KAREL programs or to move the robot.
UnlikeCALL_PROG, the program called byRUN_TASKruns 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 contentsThe package consists of two parts:Robot interface code written in Python programming languageFANUC robot controller driver written in KAREL and FANUC teach pendant languagesRequirementsThe following is needed for FaRoC software to work:Roboguide or physical robotR-30iB controller (V8.xxand up), with:R632- KARELR648- User Socket MsgPython>= 3.6To develop and test this software, aFanuc M-900iB/700robot with an R-30iB controller (V8.30) was used.Roboguideversion 9 (Rev.Z) was also used.Python package installationpipinstallfarocDriver BuildingYou can use the command line OR Roboguide to build the *.kl files contained insrc\fanuc-driver\.Command lineIfktrans.exeis not installed in the default location (ie:C:\Program Files (x86)\Fanuc\WinOLPC\bin),
openbuild.cmdfromsrc->fanuc-driverand update theKTRANS_BINvariable.
Ifktrans.exeis on the WindowsPATH, simply setting it toktrans.exeshould also work.If you need to build for a runtime software version other thanV8.30, changeCORE_VERSIONas well.Tip: You can useREMto comment a line.Now runbuild.cmdin a command shell..\buildSix p-code files should be created.RoboguideOpenbuild.cmdfromsrc->fanuc-driver.
Add all Karel programs listed inbuild.cmdand the three TP programs (*.lsfiles) to your Roboguide
workcell and build them.Driver InstallationRoboguide should have automatically uploaded the Karel programs to the virtual controller.
Loading the TP program should copy it as well.Ifbuild.cmdwas used, add the.pcand.lsfiles to the project and
load them onto the (virtual) controller. Alternatively an FTP client could be
used.ConfigurationHost Comm (SERVER)Setup twoServer Tags, Nr. 7 & 8, to use theSMprotocol and make sure to setStartup StatetoSTART. 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_SERVEROpen theKAREL Varson the controller forFaRoC_SERVER(after selecting it, i.e. SELECT -> FaRoC_Server -> ENTER -> MENU -> DATA -> KAREL Vars), switch to thecfg_field, open the
structure and enter the following values:S_TCP_PORT   : 24087
S_TAG_NR     : 7
UM_CLEAR     : TRUEConfigure the rest automaticallyNow you can start the TP programFAROC. On the computer initialize an object of classFaRoC_Writerand connect it to the server.
The rest of the configuration can be done with the scriptdemo_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 manuallyFaRoC_MOVEROpen theKAREL VarsforFaRoC_MOVER, switch to thecfg_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    : 1Host Comm (CLIENT)In order to useFaRoC_dclnt1set up aClient Tags, e.g. No. 1 to use theSMprotocol and
make sure theStartup Stateis set toSTART.
SetServer IP/Hostnameto the ip adress of the pc you want to use for socket messaging, e.g.127.0.0.1in 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_UDPtoTRUEAcleint tagis 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.DisclaimerThe 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.ReferencesBelow is a list of resources that have been used as reference and inspiration for the development of FaRoc.fanucpy: Python package for FANUC industrial robotsFanuc DPM Mouse DemoOPERATOR'S MANUAL (Alarm Code List) | R-30+B CONTROLLER | B-83284EN-1/02