FIRST Robot Simulator - Robot C Code To Work With The Simulator

Click on a thumbnail sketch to see the full size picture.

Intro

This page will provide an introduction to the process of writing/compiling the C code of the Robot so that it will work with the Tcl Robot System Simulator.

Modifications to the C Code

Some of the code that Innovation First provides for the FRC is poorly designed. I am trying to pick a middle ground between completely rewriting their code and having a system that doesn't really work. To that end, I will have you make some changes to files that Innovation First has marked "do not modify". But don't worry. We won't break the system. We will just rewrite the code the way they should have. The most significant restructuring will happen in main.c and user_routines_fast.c. More on that later.

Breaking this down further, the customized C files used by the simulator consist of the files at right. The changes are explained below.
  • user_routines.c
  • user_routines.h
  • user_routines_fast.c
The standardized C files in the simulator are mostly slightly customized versions of the .h files that Innovation First provides. But in addition we also have the files at right.
  • main.c -- derived from IFI code
  • ifi_picdefs.h -- modified from IFI code
  • printf_lib.h -- modified from IFI code
  • simfuncs.c -- New
  • simfuncs.h -- New
  • supportfuncs.c -- New
  • supportfuncs.h -- New
The files at right are supplied by Innovation First, but are not modified, either because they are not used or because they are OK as is.
  • ifi_aliases.h -- OK as is.
  • ifi_default.h -- OK as is.
  • ifi_utilities.h -- OK as is.
  • delays.h -- Not used.
  • ifi_startup.c -- Not used.
  • ifi_utilities.c -- Not used.
  • printf_lib.c -- Not used.
  • README.txt -- Not used.

Compiling Under Linux

Compling and maintaining the program under Linux is quick and easy. Simply run "make". If there are no compile errors, you will get a binary called "main". You can run it simply with "./main". (Exit by using Control-D.) But most people will find it more convenient to use the Tcl GUI. More on that later.

If you want to create additional source files that will be compiled and linked into the robot and simulator, there is a structure for that. The template files are designed to show the way.

You should copy each of those files. If you are creating a function called myfunc(), you would copy template.c to myfunc.c, etc. You then need to edit each of those files, customizing them for your purpose.

Before you link your function into user_routines or user_routines_fast there are some things to do. In order:


Next Running It

Last modified 26 Aug 2006
http://brown.armoredpenguin.com/~abrown/contact.html
_URL_