Fanuc - sending coordinates via TCP/IP with Python

  • Hello, I have big university project and part of it is to send coordinates and move Fanuc robot (M-1iA 0.5A delta robot). I have to use Python and send data via TCP/IP. I totally have no idea how to do it. Now I am reading Karel documentation and looking for tips. Before I will be able to use real robot I have to make simulation using Roboguide.


    Have you got any tips or guides how to make this connection? :smiling_face: Greetings from Poland :smiling_face:

  • If you want to use Karel for custom TCP/IP comms, first check to make sure that you have the user socket messaging option. Without that, you won't get anywhere.


    Also, what speed do you need this to happen at? At 1Hz or so, you can get away with some janky stuff using the robot's webpage, no Karel required.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Keep in mind that this is pretty hacky, and I wouldn't recommend it for anything that needs industrial levels of reliability.


    You can get the current position of the robot by reading "Your robot IP here"/MD/CURPOS.DG.


    You can set registers via the webpage, provided you unlocked the functionality via SETUP->HOST COMM->HTTP->Karel, by sending the following HTTP request: "Your robot IP here"/karel/ComSet?sValue="value you want to write"&sIndx="Register index to write to"&sRealFlag="-1 for integer, 1 for real"&sFc=2


    Using that, you would write to 7 registers, 6 for the position, and 1 to execute. Have the robot wait for the execute register, then read in the other 6 into a PR, then move to it. I would suggest a Linear move with the wrist joint option.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • I understand your idea to send coordinates via robot's webpage, but I think it will not be the best solution. In short, i have to convert Fanuc M1iA into 3D printer :smiling_face: I use coordinates generated from STL/3MF files and I wanted to send them to robot via TCP/IP (using Python), but I do not know how to recieve data and move robot using Karel. I set up a client tag on Fanuc and server in Python. I copied piece of code from Karel documentation with MSC_CONN() function and I can connect with Fanuc via Python, but I have no idea how to write Karel program to move robot. Currently I am studying Karel documentation, but I barely understand.

  • Since most 3d printers run off of Gcode, it may be easier just to use the existing tool chain. Fanuc sells an option to read and execute Gcode directly, so you may not need to pipe moves in. I guess that depends on what the scope of your project is.


    Another option in this vain would be to write a 'transpiler' that would take Gcode, and then output a Fanuc .ls file you could then load into the robot.


    If you have to use comms to make this work, I recommend you pull in a list of moves, and then have the robot run in a kind of circular buffer. Say pull in 20 positions, then overwrite the old ones as the robot completes its move. Like Hawkme said, Karel should be only be used for the comms portion. Its motion planner is decades out of date. I recommend you write to PRs from the Karel comms program, then use a tp program to execute them.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Okay :smiling_face: So I found on forum Karel program which saves recieved data to position register :smiling_face: On first look it should work fine, but when I send string with 6 coordinates (string is in format ("x, y, z, w, r, p")) the position register does not change :thinking_face: For me Karel is working properly, can you confirm if it is okay? :smiling_face:


    But i do not know why it does not get data from python. I made simple client and server code in python and I have connection between them :thinking_face:


Advertising from our partners