Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Announcing FIRSTLua (http://www.chiefdelphi.com/forums/showthread.php?t=87185)

zombiezen 19-10-2010 01:26

Announcing FIRSTLua
 
Hello, teams!

I would like to announce a project that we (Team 973) have been working on during the off-season: FIRSTLua. FIRSTLua is a fully functioning Lua interpreter that can be used for developing robot control code.

Some advantages of using Lua:
  • Lua is (arguably) easier to learn than C
  • Live code reloads
  • Errors won't crash the robot
  • Lua provides automatic garbage collection
  • WindRiver isn't needed after the base code is installed. Just a text editor and an FTP client. :)

This is beta-quality software: we have had success using Lua on our robot, but your mileage may vary. Examples and documentation are included. We are announcing this project now in the hopes that other teams will find it useful and will want to test it and contribute to it. By the time build season comes around, we'd like this to be a viable option for writing FIRST control code. Please help us out by reporting any bugs you find, and happy coding!

Project Page:
http://redmine.zombiezen.com/projects/firstlua

README:
http://redmine.zombiezen.com/project...try/README.txt

Download:
http://redmine.zombiezen.com/projects/firstlua/files

FIRSTLua is released under an MIT Open Source License, as detailed in the README.

AdamHeard 19-10-2010 01:28

Re: Announcing FIRSTLua
 
We'll be running two different and unique robots in 1323's offseason in November running Lua to fully test it out.

Peter Johnson 19-10-2010 02:14

Re: Announcing FIRSTLua
 
What a great idea and great work putting it all together! Since you're using SWIG, given the work you've done so far, it will make life easier for people who want to try adding other scripting languages in the future (Python anyone?).

zombiezen 19-10-2010 12:00

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by Peter Johnson (Post 977676)
What a great idea and great work putting it all together! Since you're using SWIG, given the work you've done so far, it will make life easier for people who want to try adding other scripting languages in the future (Python anyone?).

I would love to see Python working on the cRIO! I am a hard-core Python user and advocate, and that's what we first tried, but we ran into some troubles with that. Not to say that Python is impossible to get working or shouldn't be done, but let me give you a little history of the FIRSTLua project.

Before settling on Lua, one of our first attempts was getting the Python 3 interpreter working. However, Python rather heavily depends on having Unicode strings, which vxWorks doesn't provide. Along with that and a multitude of other compiler and linker errors to sort out, we decided we didn't have the development time to get it done. It's certainly possible to get Python working (and I'd love to see it), but after evaluating the performance characteristics and necessary development time, we settled on Lua.

We also found that Lua gives some flexibility that Python doesn't offer (though it pains me to admit it). Lua's core library is small, so it gives the team the option to pick what they need. Also, Lua's handling of modules is more favorable when trying to implement live code reloading (it can be done in Python, but it would be less straightforward). All of that aside, Lua is also designed to work on a smaller footprint than Python. The bulk of the code size when fully built is the WPILib wrapper (~20K lines of generated code), not Lua.

None of this is to say teams shouldn't try to get Python working. I would love that. :) I just would like to warn everybody of some of the difficulties we ran into while trying to do it.

AustinSchuh 19-10-2010 13:15

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by zombiezen (Post 977710)
I would love to see Python working on the cRIO! I am a hard-core Python user and advocate, and that's what we first tried, but we ran into some troubles with that.

If you are interested in working on getting Python working some time, let me know. I'd love to use Python for testing out algorithms. And nice work getting Lua to run!

Dustin Shadbolt 19-10-2010 14:49

Re: Announcing FIRSTLua
 
Amazing idea! I hope it goes well.

demosthenes2k8 19-10-2010 16:07

Re: Announcing FIRSTLua
 
YES! Now I have an excuse to learn Lua!

lynca 19-10-2010 20:12

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by zombiezen (Post 977710)

Before settling on Lua, one of our first attempts was getting the Python 3 interpreter working. However, Python rather heavily depends on having Unicode strings, which vxWorks doesn't provide. Along with that and a multitude of other compiler and linker errors to sort out, we decided we didn't have the development time to get it done. It's certainly possible to get Python working (and I'd love to see it), but after evaluating the performance characteristics and necessary development time, we settled on Lua.

We also found that Lua gives some flexibility that Python doesn't offer (though it pains me to admit it). Lua's core library is small, so it gives the team the option to pick what they need. Also, Lua's handling of modules is more favorable when trying to implement live code reloading (it can be done in Python, but it would be less straightforward). All of that aside, Lua is also designed to work on a smaller footprint than Python. The bulk of the code size when fully built is the WPILib wrapper (~20K lines of generated code), not Lua.

None of this is to say teams shouldn't try to get Python working. I would love that. :) I just would like to warn everybody of some of the difficulties we ran into while trying to do it.

Thank you for writing this, I was waiting for Python to be ported but sadly too many hurdles for now.

Regardless, Lua is also an interpreted language that will open up programming to a much broader audience than C++/Java

Universities teach Computer Science freshmen interpreted Languages (Scheme, Python) with great success.

Robototes2412 19-10-2010 22:21

Re: Announcing FIRSTLua
 
Can this interpreter be adapted to use perl grammar?

davidthefat 19-10-2010 23:55

Re: Announcing FIRSTLua
 
Oh man, our team is a mess... I think I will be the only full time competent programmer in our team. I would have to teach rest of the programmers. One guys didn't know C++ had classes -__- I know, thats pretty bad. I been talking about off season work ever since the end of the competition, it never happened, especially me working on the autonomous mode of the robot. So I also had the plan of creating a LUA interpretor for the robot, but you guys did it for me, thank you, I am not sure if I would be using it but thank you in advance and I will give you credit if I ever use it

zombiezen 20-10-2010 00:54

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by Robototes2412 (Post 977785)
Can this interpreter be adapted to use perl grammar?

No, not directly. The interpreter being used is just a patched version of off-the-shelf Lua; you would have to get Perl working from scratch. I haven't looked at the Perl codebase too extensively, but it looks like it would be an effort.

The only thing that may be of use from here (if you were determined) is the SWIG interface file that I assembled from the WPILib headers.

Peter Johnson 24-10-2010 01:02

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by zombiezen (Post 977710)
I would love to see Python working on the cRIO! I am a hard-core Python user and advocate, and that's what we first tried, but we ran into some troubles with that.

I was inspired by your work and... ported Python to the cRIO. It's working well enough to initialize and print sys.modules.keys() using PyRun_SimpleString(). Next steps: load and run a .py file rather than using PyRun_SimpleString(), and port your SWIG WPILib wrappers to Python.

Not yet ready for prime time like your Lua port is, but I wanted to let folks know I've got it at least minimally running. I'll make another announcement when I've got WPILib-using code running and it's ready for other people to really experiment with.

Git repo at: http://git.tortall.net/cgit.cgi/RobotPy.git/
I recommend TortoiseGit for getting a copy on Windows.

On another note: you may want to rename your project to not use the FIRST name. FIRST recently became more sensitive about such things as they've trademarked the "FIRST" name and thus have to protect it from dilution. I named my Python port "RobotPy" for this reason; you might want to rename yours to "RobotLua" or something similar.

AustinSchuh 24-10-2010 01:06

Re: Announcing FIRSTLua
 
Quote:

Originally Posted by Peter Johnson (Post 978175)
I was inspired by your work and... ported Python to the cRIO. It's working well enough to initialize and print sys.modules.keys() using PyRun_SimpleString().

Thanks a bunch for doing this! I'm very excited! While I don't have access to a robot to try to help right now, I'd love to help test it and fix it up. Unfortunately, I'm probably booked until the semester ends. Please keep me/us updated.

Robototes2412 24-10-2010 18:26

Re: Announcing FIRSTLua
 
Python? <3

I can finally teach the freshmen how to do more with less.

see http://teddziuba.com/2010/10/taco-bell-programming.html

Robototes2412 24-10-2010 18:50

Re: Announcing FIRSTLua
 
sorry for the double-post, but I can't get it compile.

it spat out this:
Code:

MainRobot.cpp:28:20: Python.h: No such file or directory
MainRobot.cpp: In member function `virtual void PyRobot::StartCompetition()':
MainRobot.cpp:75: error: `Py_SetPythonHome' undeclared (first use this function)
MainRobot.cpp:75: error: (Each undeclared identifier is reported only once for each function it appears in.)
MainRobot.cpp:76: error: `Py_Initialize' undeclared (first use this function)
MainRobot.cpp:79: error: `PyRun_SimpleFile' undeclared (first use this function)
MainRobot.cpp:86: error: `Py_Finalize' undeclared (first use this function)
make: *** [PPC603gnu_DEBUG/MainRobot.o] Error 1



All times are GMT -5. The time now is 15:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi