Skip to content

Robot Programs: Generated From a Pendant Export, Started Over the Network, Verified From the Joint Log

The arm of the case study is programmed at its pendant: a person jogs it to a pose and stores the pose. A calibration path has more than a hundred poses and was re-planned a dozen times, so the programs had to be generated. The arm’s controller also accepts start and stop over the network, and reports its joint angles there. This page covers how the two were used and what went wrong.

The pendant can export a backup of its programs and import one from a USB stick. The method was to teach a few moves and a pause by hand, export, and read the file: the format documents itself. The writer then starts from that export as a template and changes only the function table and the calls in the main program. Every field whose meaning is unknown is copied as it was.

In our experience, three rules kept this safe:

  • Round trip first. Before generating anything new, regenerate the export from the tool’s own data and compare byte for byte.
  • The first import of anything new is the joint-direction check, at 5 % speed, with a person at the arm.
  • Restart the controller after an import, before running anything. We did so every time.

The model of the arm came from the datasheet. The directions in which the real joints count are a convention of the controller and are not in the datasheet. A program that moved one joint at a time by a few degrees showed that three of the six joints count the other way from the model. One of them could be read from the datasheet’s drawing and one from a pose already stored on the pendant; the third could be found only by watching the joint move.

The result is a file with one sign and one offset per joint. Everything the planner computes passes through it on the way to the robot, and everything the robot reports passes back.

A technician needs the arm to present the camera mount at a comfortable loading position, away from the target. Those moves were taught by hand at the pendant. An import overwrites what is on the pendant, so the taught main program became part of the package: its moves are kept instruction for instruction, and the generated functions are called from the middle of it.

One function per camera model sits in the package, each called by its own line in the main program, and exactly one line is active. In our experience, this arrangement is convenient and dangerous: with two lines active the arm runs both programs one after the other, and nothing complains.

The station sends start and stop and reads mode, alarm, speed and joint angles. What that taught:

Observation Consequence
After a controller restart an open connection kept returning the last values Every reading is time-stamped; an old reading is no reading; the link is reopened
The controller came back from a restart at 100 % speed where 10 % had been set The speed is read and said to the person at the cell before every remote start
Just after switching to automatic mode the speed register read 10 % for a moment Read it again before trusting it
A network link can die without anyone noticing (first row) The hardware stop buttons are the safety, never the network
A program stopped part-way resumes part-way on the next start A run starts only from the loading position
An alarm that says “not initialised” appears after an import and clears itself It is in the maker’s alarm table; wait

The station starts “the program”. Which program that is depends on what was imported and which call line is active, and both are set by hand at the pendant. On day five an older package was still loaded with two lines active. The arm ran two programs, the station recorded a video and reported a clean run of a third program that did not exist on the pendant.

The fix reads the joint log. The controller moves from target to target in a straight line in joint space, so every joint sample logged while a program runs lies on the path through that program’s targets. For each known program the station computes the share of samples that lie on its path and whether the moves only that program has were visited. It answers “wrong” only when certain, because a wrong “wrong” throws a good recording away.

In our experience, the first version of this check was wrong in the other direction. It counted how many of a program’s targets appeared in the log; at one sample per second the arm passes most targets between samples, and every known-good run failed. It was caught by running the check over all earlier logs before it went live.

Log What ran Check says
Five runs of the two near-identical paths the expected one ok
A run of the two-programs fault two programs “more than one program ran”
A run where the new program’s 45 own moves were never visited another program “did not run: 0 % of its own moves seen”

Two of the programs differ in a handful of slightly moved poses. At one sample per second the log cannot always separate them, and the check says so instead of guessing. The station now samples four times per second during a run.

  • Inputs: an export from your pendant with a small hand-taught program in it, notes of what you taught, your waypoints, and the joint map.
  • How to check: the round trip is byte-identical; the first import runs the joint check at low speed; the pendant shows the names and exactly one active call.
Write a tool that turns a list of joint-angle waypoints into a program my robot's pendant can
import, by learning the file format from a backup the pendant itself exported. The robot is an
industrial arm whose programs are normally taught by hand on the pendant; I want to generate them,
because a calibration path has more than a hundred poses and will be re-planned many times.
In this directory:
- `export/`: a backup exported from the pendant, as the original archive and unzipped, containing a
main program and two small functions I taught by hand: a few joint moves and pauses.
`export_notes.md` says what I taught, in the order I taught it, with the numbers I typed (the file
may hold the measured value, a few thousandths away). The pendant's speed is a percentage, 1 to
100.
- `waypoints/`: one JSON file per program to generate, `{"name": ..., "speed_pct": ..., "dwell_s":
..., "poses": [[6 joint angles in degrees], ...]}`. The poses are in my MODEL's angles; convert
them with `joint_map.yaml`. Move to each pose at `speed_pct`, pause `dwell_s` after each pose (not
at home), and use speed [20] for the moves to and from home.
- `joint_map.yaml`: for each joint the sign and offset that turn my model's angle into the pendant's
angle (pendant = sign * model + offset).
How to work:
1. Work out the format from the export alone. Find where my taught moves and pauses are, which
fields carry the joint angles, speed and pause time, how a function is declared and called from
the main program, and what marks the end of a program. Look hard at any numbering field: if its
values are not in line order it may record the order in which lines were created on the pendant,
not their position. Never renumber a line that is already in the export; give new lines numbers
that are not in use, state the rule you chose, and say that it is a guess until the pendant has
accepted it. Write what you found in `FORMAT.md`, and mark every field whose meaning you are
guessing.
2. Prove you understand it before generating anything new: regenerate the exported files from your
own data structures and compare with the originals byte for byte. Any difference is a
misunderstanding; resolve it or list it.
3. Change as little as possible. Start from the export as a template, replace only the function
table and the calls in the main program, and copy every field you do not understand exactly as it
was. A controller that meets a file it half-understands may load it and move somewhere else. My
taught functions are examples: overwrite them, put the generated programs in slots 0, 1, ... in
command-line order, and leave unused slots exactly as the export has them. Function names: at most
[10] characters from A-Z, 0-9 and _.
4. Keep the main program's own moves (the approach from and return to the loading position that I
taught). Add one call line per generated function, with exactly one call active and the others
present but disabled, and say in the output which one is active: with two active the robot runs
both, one after the other.
5. Every generated program begins and ends at the home pose in `joint_map.yaml`.
6. Also generate a joint-direction check named [JOINT_CHK], in the slot after the paths: from home
it moves one joint at a time by [+10] degrees in MODEL angles and back, at [5] % speed, with a [3]
s pause after the move out and after the move back, ending at home, every move at that speed, so a
person can stand at the robot and confirm that each joint turns the way the model says before any
real path runs. `--enable` accepts it like any other program, and it is what I will enable for the
first import of anything this tool writes.
7. Write the package the way the pendant expects it back (same file names, same archive layout,
file-name encoding, compression and naming pattern as the original archive, named with the current
time), into an emptied `out/`, with a `programs.json` beside it: `{"main": [[6 pendant angles],
...], "programs": {"NAME": [[6 pendant angles], ...]}}`, every joint target in order including the
home moves. A station can later compare the robot's joint log with this file to see which program
ran.
Write `robot_program.py` (a library and a command line: `python3 robot_program.py pack
waypoints/*.json --enable NAME`), `FORMAT.md`, and tests: the byte-for-byte round trip, joint limits
respected (limits in `joint_map.yaml`), exactly one active call.
Report: what you are sure of in the format, what you are guessing, and what I should check on the
pendant after the first import (for example: the program list shows the names, the active call is
the one I asked for, the joint check at low speed moves each joint the way the model says). If one
export cannot settle a question, tell me which second export would (for example: the same program
after I insert one line in the middle).

Two fresh AI sessions, each with an export in our arm’s format holding a taught main program and two taught functions. Neither had our writer, and both were told not to look the format up.

The first, on an earlier wording, reproduced all six exported files byte for byte, generated two paths and a joint check with the signs of joints 2, 3 and 5 turned as the joint map says, kept the taught main program’s moves, and made exactly one call active. Its notes showed what the prompt had left open: that the waypoints are in model angles, the speed of the moves to and from home, and that the first import should enable the joint check, not a path at full speed.

The second, on the wording above, also rebuilt the original archive bit for bit, put the joint check in its own slot as the only active call, and wrote the list of joint targets that the which-program-ran check reads.

Both sessions read the numbering field of the format the same way: as a record of the order in which lines were created on the pendant, not of their position. Both therefore numbered the lines of a new function in order. The writer that has run on our arm numbers moves first and pauses after, copying the export it learned from. We do not know whether the controller cares; each session listed it as a guess and named the second export that would settle it. That is the case the joint check at 5 % speed exists for.

  • Inputs: the joint targets of every program (the program writer produces them), joint logs, the loading position.
  • How to check: run it over logs of runs you know; it must never call a good run wrong.
Write a check for a robot calibration station: after a run, decide from the robot's joint log which
program the robot actually ran, and whether it ran exactly once.
Why: the station tells the robot to start, but the program that runs is whichever one is enabled on
the robot's pendant. On our cell an old package was still loaded with two programs enabled; the
robot ran both, and the station reported a clean run of a third. Nothing failed until someone looked
at the joint log.
Inputs in this directory:
- `programs.json`: `{"main": [[6 joint angles], ...], "programs": {"NAME": [[6 joint angles], ...],
...}}`: for every program the joint targets it visits, in order, in degrees. `main` holds the
moves the robot makes around the program: from the loading position through the first half of
`main`, then the enabled program (or programs, one after another, when more than one is enabled),
then the second half of `main` back to the loading position. Each program is a stop-and-go part, a
return to its first pose with a pause, then continuous loops; a target repeated twice in a row is
a pause, not an error. The programs share most of their targets: [PATH_C is PATH_A with 45 extra
targets; PATH_A and PATH_B differ in 7 slightly moved poses].
- `logs/*.csv`: one joint log per run, sampled about once per second with occasional gaps; the check
must work as well on logs sampled four times per second. Columns: unix time, robot mode (7 =
running a program; other values = idle or manual), alarm code (0 = none), moving flag, then the
six joint angles separated by spaces, to 0.01 degree.
- `home.json`: the loading position, where every run starts and ends.
Facts about the robot: it moves from target to target in a straight line in joint space. In the
continuous part it does not stop at a target and rounds the corner (it leaves the incoming line
before the target and joins the outgoing one after it), so a sample near a target can be a few
degrees inside the corner; in the stop-and-go part it stops exactly. At one sample a second most
targets are never seen exactly in the log. The robot repeats a path to within [0.1] degree, and no
joint moves faster than [600] degrees per second.
Write `check_run.py` with `check_run(log_path, expected_program) -> dict(ok, ran, why, evidence)`:
- `ok` is True when the expected program ran, once, and the robot returned to the loading position;
False only when you are certain it did not (another program ran, or more than one, or none of the
known ones, or the run ended in an alarm or away from the loading position); None when the log
cannot decide (for example two programs that the log cannot tell apart). A wrong False throws a
good recording away, so prefer None to a guess, and say what counts as proof (for example: a
sample in the stop-and-go part more than [1] degree off every point of a program's path).
- `ran`: your best identification, `why`: one sentence a technician can act on, `evidence`: the
numbers behind it.
Also a command line: `python3 check_run.py LOG EXPECTED`.
Then run it on every log in `logs/` against every program name and print a table. I will compare it
with what really ran. Tell me which pairs of programs your method cannot separate at this sample
rate, and what sample rate would.

How the which-program-ran prompt was tested

Section titled “How the which-program-ran prompt was tested”

A fresh AI session got an earlier wording of this prompt, the joint targets of three programs under neutral names, and seven real joint logs from the cell sampled once per second. It was not told what had run.

Log What really ran What its check said
1, 5 the first path the first path, once
2, 3, 4 the second path, which differs from the first in a handful of slightly moved poses the second path, once
6 the first path, then the second, in one start two programs in a row, with the instruction “on the pendant leave only one enabled”
7 nothing: an emergency stop two seconds after the start no program completed, stopped with an alarm away from the loading position; it added that the moves of the main program before the path had been skipped

All seven are right, for every expected program: 21 verdicts, none wrong and none undecided. It separated the two near-identical paths that our own check, at this sample rate, leaves undecided, by finding the few samples on the moves the two do not share and measuring them against a noise floor it took from the data (0.07 degrees). It then thinned the logs to every second, third and fourth sample to see how its check degrades: 140 verdicts right, 22 undecided, none wrong.

Its notes show what the prompt had left it to discover: that the arm rounds corners in the continuous part, how the main program wraps the paths, and what a run that ends in an alarm should return. The wording above now states them.