Go to Post I'm definitely not advocating PVC tanks. I'm just saying that if you're going to be an idiot, please be slightly less of an idiot. - FourPenguins [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-10-2012, 16:56
zombiezen's Avatar
zombiezen zombiezen is offline
Registered User
AKA: Ross Light
FRC #0973 (Greyhound Robotics)
Team Role: College Student
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Atascadero
Posts: 12
zombiezen is a jewel in the roughzombiezen is a jewel in the roughzombiezen is a jewel in the roughzombiezen is a jewel in the rough
Team 973 Code Now Public

Team 973 presents our code from previous seasons. Notable is that 2011 & 2012 are entirely Lua, so teams interested in using Greyhound Lua will want to examine it.

https://bitbucket.org/zombiezen/team-973-public
__________________
Cheers,
Ross Light

http://www.zombiezen.com/
  #2   Spotlight this post!  
Unread 06-10-2012, 17:54
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Team 973 Code Now Public

The choice of Lua is interesting -- what advantages and disadvantages does it afford you over Java/C++/Python?
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
  #3   Spotlight this post!  
Unread 07-10-2012, 03:05
Mk.32's Avatar
Mk.32 Mk.32 is offline
Registered User
AKA: Mark
FRC #2485 (W.A.R. Lords)
Team Role: Engineer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: San Diego
Posts: 770
Mk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud of
Re: Team 973 Code Now Public

I am a bit confused, how did you guys run Lua on our robots? And what advantages does it have compared to the usual Java/C++?
__________________
Engineering mentor: Team 2485: WARLords 2013-

Team President: Team 3647 2010-2013
  #4   Spotlight this post!  
Unread 07-10-2012, 20:26
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Would somebody please explain what luna is
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
  #5   Spotlight this post!  
Unread 07-10-2012, 20:35
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 945
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Team 973 Code Now Public

Quote:
Originally Posted by inkspell4 View Post
Would somebody please explain what luna is
Lua is a scripting language (http://www.lua.org/). It is used a lot in the gaming industry as a second-level language to interact with higher level APIs. For example, World of Warcraft, Warhammer Online, and RIFT have all allowed users to create modifications to their user interface by writing Lua scripts against their exposed APIs.

I have never used Lua with FRC, but I am assuming the benefits are a faster change-upload-run cycle while developing code, because Lua is interpreted and not compiled.
  #6   Spotlight this post!  
Unread 07-10-2012, 20:46
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,506
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Team 973 Code Now Public

Quote:
Originally Posted by F22Rapture View Post
The choice of Lua is interesting -- what advantages and disadvantages does it afford you over Java/C++/Python?
Ross can provide more detailed answers on the technical side, but I'll field some of the reasons.

We're a small team, in a community that doesn't really prepare kids at all in technical fields. It's not uncommon for a student to have never used email before joining the team. It is rare we have any students coming in with programming experience, and more rare that we even have kids interested in programming (this last season and the upcoming season we have a few, which is a refreshing change of pace). Also, for random and unrelated reasons, we've had huge turnover in students interested in programming, 2013 will be the first season since 2008 that a student programmer participated the previous year.

Throw that all together with the fact that our mentorship is low, and it's HARD to get kids trained as programmers.

The barrier to entry with Lua is just lower than a language like C++. Students spend more time problem solving and doing the real tasks that programming is, and less time focusing on syntax and variable types. Ross is a computer science major (and I'm a minor in it), so we both understand the importance of these skills, but we believe they will learn these skills down the road in whatever college program they choose. We're more interested in just getting them to program (as programming in anything is better than not doing it at all), and letting them spend more time per hour coding on the high level tasks and logic problems.

It's worked well for us in that regard.
  #7   Spotlight this post!  
Unread 07-10-2012, 21:17
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Team 973 Code Now Public

Quote:
Originally Posted by AdamHeard View Post
Ross can provide more detailed answers on the technical side, but I'll field some of the reasons.

...
I can help with some technical reasons as well:

As BigJ pointed out, Lua is used in a lot of games. The interesting thing about use in games is that games have very strict speed requirements. If a game is designed to run at 30 frames per second, everything has to run within 1/30 of a second (about 33 ms) or your game is going to lag. Games tend toward Lua because it's very light and very fast (some benchmark comparisons to python are available here), while still having the high-level advantages of a scripting language.

Even disregarding the speed or the general advantages of high-level interpreted languages vs lower-level compiled languages, Lua as a language is impressively flexible, with first-class functions and extensible tables allowing programmers capable of a little more abstract thinking to make some extremely clever code. It wouldn't necessarily be my first choice for FIRST programming, but I can definitely see why team 973 settled on it.
  #8   Spotlight this post!  
Unread 07-10-2012, 21:30
zombiezen's Avatar
zombiezen zombiezen is offline
Registered User
AKA: Ross Light
FRC #0973 (Greyhound Robotics)
Team Role: College Student
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Atascadero
Posts: 12
zombiezen is a jewel in the roughzombiezen is a jewel in the roughzombiezen is a jewel in the roughzombiezen is a jewel in the rough
Re: Team 973 Code Now Public

Quote:
Originally Posted by Mk.32 View Post
I am a bit confused, how did you guys run Lua on our robots?
Greyhound Lua. It has been discussed before.

The gist is that the Lua interpreter is off-the-shelf code written in clean ANSI C. It compiles with minimal modification under WindRiver, and with some SWIG bindings to grant access to WPILib. It is released under an open source license and is free for other teams to use.

Quote:
Originally Posted by F22Rapture View Post
The choice of Lua is interesting -- what advantages and disadvantages does it afford you over Java/C++/Python?
All of what Adam said plus:

The edit/compile/run cycle is dramatically reduced, as BigJ pointed out, but even more than that, the barrier to experimentation is much lower. Students can try out snippets of code in an interactive interpreter and develop on practically any OS, since the Greyhound Lua interpreter only needs to be compiled once. We don't need to develop in WindRiver, so we have students that are using Ubuntu, Mac, Windows, vim, gedit, and Notepad++.

From a teaching perspective, the language of Lua also lends itself to procedural programming, which is easier to demonstrate and reason about for new students. Gone are the discussions of memory management, inheritance, and NULL pointer crashes. Lua instead builds from combining simple concepts. For instance, we can re-bind controls using closures inside a table.

I've been asked by people inside and outside FRC whether the use of Lua in FRC is a good idea. Their concerns vary from runtime performance to software engineering best practices (usually phrased as "Lua isn't a real language"). If I (as a mentor) were the only one writing the code, you can bet I would be using C++ because the syntax doesn't bother me and the static typing and performance help me during development. But it isn't about me; it's about the students. I've made sure to explain to the new students what the tradeoffs are and why the decision was made. Should all teams be using Lua? No, but it meets our needs, and ultimately, the choice of programming language in a software project does not matter. The real question is: "is your team productive?" And after the last two seasons, I think the results speak for themselves.

On a sidenote, the Python port didn't come until after I finished Greyhound Lua, and IIRC it uses the SWIG bindings I wrote. I initially tried porting Python, but found that the effort required exceeded the amount of time I had before the 2011 season started.

tl;dr: Lua fits our needs.
__________________
Cheers,
Ross Light

http://www.zombiezen.com/
  #9   Spotlight this post!  
Unread 07-10-2012, 22:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Team 973 Code Now Public

Quote:
Originally Posted by Ginto8 View Post
(some benchmark comparisons to python are available here)
Why the big difference in CPU time for the pidigits benchmark?


  #10   Spotlight this post!  
Unread 07-10-2012, 22:27
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Team 973 Code Now Public

Quote:
Originally Posted by Ether View Post
Why the big difference in CPU time for the pidigits benchmark?
Looking at the two programs, it seems that the python sample is using a built-in multi-precision library for python (GMPY, which includes C and C++ for speed), while the lua code is doing... something... with dynamic compilation to make it happen.
  #11   Spotlight this post!  
Unread 07-10-2012, 23:45
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Team 973 Code Now Public

Quote:
Originally Posted by Ginto8 View Post
...games have very strict speed requirements...
Not to hijack the thread, but a 30hz (or even 60hz) timing requirement on a 2ghz+ x86 cpu with a 3d rendering coprocessor isn't really that bad.

Many automotive and industrial control systems operate at extremely high speeds, for various reasons. It's not uncommon for active suspension and other vehicle dynamics related systems to operate at 100hz to 1000hz, depending on how fast their actuators can be actuated, and these often run on relatively slow processors (e.g. I worked on a suspension system at 1000hz on a MPC5534 clocked at 80mhz, and many engine controllers I work with use the MPC5xx family at 56mhz).
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #12   Spotlight this post!  
Unread 08-10-2012, 00:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Team 973 Code Now Public

Quote:
Originally Posted by apalrd View Post
Many automotive and industrial control systems operate at extremely high speeds, for various reasons. It's not uncommon for active suspension and other vehicle dynamics related systems to operate at 100hz to 1000hz, depending on how fast their actuators can be actuated, and these often run on relatively slow processors (e.g. I worked on a suspension system at 1000hz on a MPC5534 clocked at 80mhz, and many engine controllers I work with use the MPC5xx family at 56mhz).
The last embedded automotive project I worked had a 3000Hz task, a 1000Hz task, two slower tasks, and a handful of hardware interrupts (SPI, PWM input edge detection, etc) running on an 8-bit microcontroller clocked at 16MHz. I wrote the RTOS (preemptive with rate monotonic priority) and app (integrated) in assembly and C.


  #13   Spotlight this post!  
Unread 10-10-2012, 00:35
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Team 973 Code Now Public

Quote:
Originally Posted by zombiezen View Post
On a sidenote, the Python port didn't come until after I finished Greyhound Lua, and IIRC it uses the SWIG bindings I wrote.
Initially it used the SWIG bindings, now it uses SIP-based bindings.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 00:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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