KAREL Programming

  1. Simplifying Robotics: Mastering FANUC CRX Plugins and Timeline Editor

    FANUC CRX Robots and the Timeline Editor

    I contend that programming FANUC robots is easy and can be learned quickly. But what if the idea of writing code is too intimidating or you just don’t have time?

    Wouldn’t it be great if you could make the robot do a job without writing a single line of code?

    That’s the idea behind FANUC’s new(ish) timeline editor for CRX robots. You basically program the robot by dropping functional blocks onto a timeline. My two-year old could figure it out.

  2. How to Write a FANUC KAREL Logging Utility

    I received a question via email the other day where someone wanted to know how to log timestamped position data to a file. As luck would have it, I’d been meaning to write a post about something like this for quite a while now.

    This application ends up being a great example that covers a broad range of KAREL programming fundamentals:

    1. KAREL variables, constants and data types
    2. Custom ROUTINEs
    3. String manipulation
    4. Bitwise operations
    5. TPE parameters
    6. Error-checking and the status convention
    7. File operations
    8. File pipes (the PIP: device)
    9. Data formatting

    Let’s get started by considering our desired TPE interface. We want to be able to log Position Register (PR) values (X, Y, Z, W, P, R) to a logfile whenever this KAREL program is called from a TP program. For maximum flexibility, let’s accept two parameters: one will be an INTEGER id for the PR we want to log, and the other will be a STRING filename for the desired logfile.

  3. Using KAREL Pipe Files

    I’m currently working on a project where two separate tasks need to pass data to eachother. How do we do that in KAREL? Enter the pipe PIP: device.

    The concept of a pipe has been around since the early 1970s, originating as a crucial part of the Unix operating system. Pipes simply provide a mechanism for data to travel from one process to another.

    While the KAREL manual does a pretty good job of describing how pipes work and how to use them, I ran into a couple of issues while implementing the provided example. Here’s a quick tutorial showing some of the issues I dealt with along with a working example of how to use KAREL pipes.

  4. Hash Table Implementation for FANUC KAREL

    I was working on a KAREL project the other day where I really wanted to use an associative array to store some key => value pairs. While a STRUCT would be appropriate if my keys were known ahead of time, there’s no data type for mapping unknown keys to values…

    …so I built a hash table implementation that you can use in your own KAREL programs. The source is available here: https://github.com/onerobotics/hash.

    Usage is documented in the README, but I thought it might be interesting/useful to talk a bit about what’s going on behind the scenes.

  5. Introducing KUnit: a simple unit testing framework for FANUC's KAREL programming language

    I’m happy to share a real open source project that I’ve been working on: KUnit. The source code is available on GitHub: https://github.com/onerobotics/KUnit.

    Coming from a Ruby background where automated unit testing is common-practice, it’s frustrating to come work on a robot where tools for automated testing don’t exist. No matter how careful I am when making changes to my code, I always feel a little bit exposed without a comprehensive set of unit tests making sure I didn’t break something. I haven’t come up with a solution for automating TP program testing, but here’s a tool you can use to make sure your KAREL programs are doing what they are supposed to do.

  6. FANUC KAREL Programming: An Introduction (with Examples)

    You can program FANUC robots in two different languages: the TP (teach pendant) programming language or KAREL. TP is good enough for 99% of the things you need to do on the robot, but for everything else, there’s KAREL.

    KAREL is a lower-level language very similar to Pascal. It features strongly typed variables, constants, custom types, procedures, functions, and gives you access to all sorts of useful built-ins for things you may not be able to do with TP. (By the way, if you’re interested in TP programming, please check out the book I wrote on programming FANUC robots.)

  7. Testing FANUC TP and KAREL Code

    UPDATE 2014/02/27:

    If you're looking for a how-to guide on FANUC KAREL programming, you're probably better off reading my Introduction to KAREL Programming article.

    One of the things I love about the Ruby community is its dedication and support for testing. Having very little formal computer science education, concepts like unit testing and integration testing were completely foreign to me. After first ignoring everyone’s advice to test now and test often, I eventually forced myself to learn out of necessity and now advocate the practice to anyone who will listen. Having confidence in your code is very important, especially when your code is the only thing keeping a $100k robot from crashing through a $500k machine tool. By testing thoroughly, it’s much easier to have confidence in your code and gives you the freedom to perform large refactorings while still maintaining essential functionality.