FIRST Robot Simulator - TheField
 @(#) $Header: /usr/local/scalawags_cvs/Scalawags/Simulator2006/TheField.wc,v 1.1 2006/03/13 23:15:57 abrown Exp $ 


What Is Simulated

TheField is the user written file for control the playing field and any objects on it, including the robot.


Where Used

TheField.tcl is sourced in RoboSystem.tcl along with TheRobot.tcl and TheOperatorInterface.tcl.


GUI View

Since TheField.tcl is written by the user it can vary considerably. Here is an example of a field created for the 2006 competition season.

The circles represent waypoints for autonomous mode. They don't really do anything useful other than assist in testing that autonomous navigation is working.

The robot is parked at its initial location on the right side of the screen in one of the middle boxes.

The center goals are not shown because they weren't needed for debugging this particular robot.


Example

The user will program TheField first by defining the window ".field" and the playing field in it .field.field.

    source {PlayingfieldObject.tcl}
    toplevel .field; wm group .field .

    ::Playingfield::new TheField .field.field {28*$::FOOT} {42*$::FOOT} \
      300 "#4444ff" Field
    pack .field.field -side left
  

The dimensions of the field can be set to anything you want. Here they are set to 28 by 42 feet. And the screen width is set to 300 pixels.

"#4444ff" is the color of the field. The color is three hexadecimal bytes specifying the three color components: red, green, blue.

If you want to place boxes on the field they look like this:

    ::Playingfield::Box_new BoxLL  TheField \
      {2.5*$::FOOT}  {0.6*$::FOOT} {4.2*$::FOOT} {1.4*$::FOOT} 0 0 \#ffffff
  

You should see the PlayingfieldObject.tcl source file for how to work with boxes, lines, and ovals. There is more there than I want to go into here.

To create a robot on the field and animate it, use the following:

    ::Playingfield::Robot_new OurBot TheField {26.9*$::FOOT} {26.0*$::FOOT} 0 \
      {$::leftdist} {$::rightdist} {20*$::INCH} 100 500 "#00ffff"

    ::Notify::Subscribe Cycle ::Playingfield::Robot_update OurBot
  

The first two lines define the robot. Its name is "OurBot" and it exists on "TheField". Its initial location is 26.9 feet by 26.0 feet from the bottom left corner of the field. The robot's initial heading is 0 degrees, or straight up. The variables ::leftdist and ::rightdist hold the running distance traveled by the left and right wheels. (This must be set up to be updated by ::Tractortank:: .) The distance between those two wheels is 20 inches. The number 100 isn't currently used but is reserved for simulating collisions on the field. The number 500 specifies how often the robot will deposit a visual "breadcrumb" on the field. And the last parameter is the color of the robot on the screen.

The robot is animated by the Notify line and the fact that the ::leftdist and ::rightdist variables are being updated. Because of this line the position of the robot on the field is updated every cycle.



Last modified 11 Dec 2006
http://brown.armoredpenguin.com/~abrown/contact.html
http://brown.armoredpenguin.com/~abrown/first/first2006/Scalawags/Simulator2006/TheField.html