When dealing with multiple robot systems, I usually find that
maintaining consistency from robot-to-robot is usually the most
difficult part. Simply getting backups of all your robots can be a pain
if you don’t have the right tool for the job. If you’re using
Windows (you probably are), just a little knowledge of the command line
and the ftp
utility will make your life a lot easier.
The Command Prompt
If you’ve never used the Windows command prompt before, read this quick intro from the Princeton CS department.
FTP
Go read my very first blog post about using FTP with FANUC robots. It describes how to use the Windows command line FTP client to connect to your robots and download/upload files.
This client allows you to specify a command file which lists a series of commands to be executed when you connect to the ftp server. The command looks something like this:
> ftp -s:commands.txt 192.168.1.101
In essence, connect to 192.168.1.101
and execute the commands listed
in commands.txt
.
What does commands.txt
contain? How about this:
anon
bin
prompt
lcd backups
lcd R1
mget *.*
quit
What does this do? Let’s go over each line:
anon
- You don’t have to useanon
here, but you have to login to the FTP server when you connect.bin
- Switch to a binary mode connection. If you stay in the default ASCII mode, your binary TP and VR files may be corrupt.prompt
- Don’t prompt the user to enter yes/no to confirm commandslcd backups
- Change the local directory to./backups
lcd R1
- Change the local directory to./backups/R1
mget *.*
- Download all files on the robotMD:/
device to./backups/R1
quit
- Quit the FTP connection
You can type help
after establishing your FTP connection to get a list
of possible commands. You can also type ftp --help
on the command line
to get a list of options for the client.
Windows Batch Files
Now that you know how to use the command prompt and the command line FTP client, let’s learn a little bit about batch files. From the Wikipedia article:
A batch file is a type of script file in DOS, OS/2 and Windows. It consists of a series of commands to be executed by the command line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as "if", "for", "goto" and labels.
Batch files let us create little command scripts to automate repetitive tasks. I won’t go over the entire command interpreter here, but this seems to be a pretty comprehensive guide.
Batch Files + FTP
Finally, the good stuff: this is how I maintain consistency when working on multiple robot cells.
First, TP programs. Whenever possible, I try to keep the programs exactly the same on each robot. I usually start by developing my programs locally and using a simple batch file to load them on all the robots:
ftp -s:deploy.txt 192.168.1.101
ftp -s:deploy.txt 192.168.1.102
ftp -s:deploy.txt 192.168.1.103
...
deploy.txt
might look something like this if you have the ASCII upload
option.
anon
bin
prompt
mput src/*.ls
quit
If you don’t have the ASCII upload option, but you do have ROBOGUIDE,
you can use the maketp
utility to convert your LS files to binary TP
files with another batch file, translate.bat
:
for %%f in (bin/*.tp) do del bin/%%f
for %%f in (src/*.ls) do maketp src/%%f bin/%%~nf.tp
First I delete all the existing binary files in the ./bin
directory,
just in case maketp
fails and I don’t notice. Second, I translate each
LS file in the ./src
directory to its corresponding TP file in the
./bin
directory. See more on the for
command (including what that
%%~nf
does) here.
My process then for keeping things in sync is as follows;
- Make a program change. If it’s on the robot, make sure to update my local LS files
> translate
> deploy
A couple of things to watch out for:
maketp
may not succesfully translate your LS file if there’s a parse error or if it doesn’t feel like it. (It fails inexplicably sometimes.) Watch the command prompt output for these errors. (Bonus points for anyone who can write another batch file to watch out for these errors.)- The robot will not let you overwrite a file if it’s currently
selected, being edited or running. Make sure to
ABORT ALL
andSELECT
some other program before deploying. (Bonus points for anyone who can write a batch program to do this automatically…telnet
?)
What else?
Maybe you want to sync the position and numeric registers on all your robots. Write one program to grab the files from your “master” robot:
get_regs.bat
------------
ftp -s:get_regs.txt 192.168.1.101
get_regs.txt
------------
bin
anon
prompt
get numreg.vr
get posreg.vr
quit
…and another one to update your other robots:
put_regs.bat
------------
ftp -s:put_regs.txt 192.168.1.102
ftp -s:put_regs.txt 192.168.1.103
ftp -s:put_regs.txt 192.168.1.104
...
put_regs.txt
------------
bin
anon
prompt
put numreg.vr
put posreg.vr
quit
Combine them into a single program or create another one that does everything:
update_regs.bat
---------------
get_regs
put_regs
As you can see, just a little command line automation can make your robot programming go a lot smoother. Let me know in the comments if you have any other little scripts that make your life as a robot programmer easier.