Download Latest Version GreyhoundLua-2011-01-08.out (6.7 MB)
Email in envelope

Get an email when there's a new version of Greyhound Lua

Home / 2011-01-08
Name Modified Size InfoDownloads / Week
Parent folder
GreyhoundLua-2011-01-08.out 2011-01-08 6.7 MB
README.rst.txt 2011-01-08 7.6 kB
GreyhoundLua-2011-01-08.zip 2011-01-08 390.1 kB
Totals: 3 Items   7.1 MB 0

Greyhound Lua

Author:Ross Light
Copyright:Copyright © 2010, Ross Light
Version:2011-01-08

About Greyhound Lua

Greyhound Lua is a distribution of Lua intended to be used for the FIRST Robotics Competition. Teams can use this to write their robot code in Lua, a simple, lightweight programming language.

Greyhound Lua is in no way endorsed or sponsored by US FIRST.

Features

  • Lua is simple to learn and easy to maintain.
  • Greyhound Lua lets you reload code without restarting.
  • Greyhound Lua provides access to the WPILib.
  • You don't need to use WindRiver once the base code is installed.
  • Inclusion of the bitop library.

Installation

Open the project directory as a WindRiver project. Build the project and download the code to your robot. Now you have the Lua interpreter on the robot, now let's add some code.

Connect to your robot's IP with an FTP client (e.g. ftp://10.XX.YY.2/, where XXYY is your team number). Copy the samples/boot.lua file in the Greyhound Lua distribution to lua/boot.lua on the robot. This is the bootloader which will run the rest of your code; you shouldn't need to edit it.

Writing Code

The default Lua bootloader will load lua/robot.lua and try to call a function called run in there. This assumes that you are using the standard Lua packaging system (i.e. using the module function). A basic robot.lua file may look like this:

-- samples/template/robot.lua
module(..., package.seeall)

function run()
   -- Main loop
   while true do
      if wpilib.IsDisabled() then
         disabled()
         repeat wpilib.Wait(0.01) until not wpilib.IsDisabled()
      elseif wpilib.IsAutonomous() then
         autonomous()
         repeat wpilib.Wait(0.01) until not wpilib.IsAutonomous() or not wpilib.IsEnabled()
      else
         teleop()
         repeat wpilib.Wait(0.01) until not wpilib.IsOperatorControl() or not wpilib.IsEnabled()
      end
   end
end

function teleop()
   while wpilib.IsOperatorControl() and wpilib.IsEnabled() do
      -- Run one cycle of teleoperated here...
      wpilib.Wait(0.01)
   end
end

function autonomous()
   -- Run autonomous code here...
end

function disabled()
   -- Do something in disabled mode here...
end

You can find more examples of code in the samples directory.

Technical Overview

Greyhound Lua is a packaging of a patched Lua 5.1.4 interpreter (found in the lua subdirectory). All access to the WPILib is generated by a SWIG interface, which is found at wpilib.i. When the robot is started, it calls upon the LuaRobot class to set up the environment, which creates a Lua state and runs the file lua/boot.lua. From there, all responsibility is given to the boot.lua script, which is referred to as the bootloader.

Major Differences from standard Lua

  • No dynamic loading of C code. vxWorks does have the capability for it, but we haven't seen a need to introduce the complexity. The loadlib family of functions remain, but they will give an error. This restriction may be lifted eventually.
  • The bitop library is bundled with this project (as bit.c).
  • Some functions from os are removed, namely: * os.execute * os.exit * os.setlocale

Licensing

A brief overview of licensing terms:

If you redistribute Greyhound Lua and add other libraries, please include their licensing information here.

Lua License

Copyright © 1994–2008 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bitop

Copyright © 2008-2009 Mike Pall. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Greyhound Lua

Copyright © 2010 Ross Light

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Source: README.rst.txt, updated 2011-01-08