Go to Post note to self: do not use robot to retrieve cars from water. - Greg Marra [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-16-2017, 02:29 PM
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 263
TimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to beholdTimTheGreat is a splendid one to behold
FRC Programming, Done Right

Recently, a productive discussion was had on the FRC Discord about the spread of programming ability among teams. Many recognized that teams like 254 do better due to things such as trajectories and vision, but everyone should learn how to do this.

After some debate, we starting thinking of what we could do to help all teams raise their programming skills to become more competitive, even with bots that aren't as mechanically sound as 971s. I came up with the idea of FRC Programming Done Right, an online guide to teach both the basics of programming in Java, C++, and Python (LabView isn't very easy to teach textually, and it is more useful to learn text-based IMO), and good programming practices in FRC.

The guide is a work in progress right now, but over the summer I plan to make it my main focus (along with my job), but help is always wanted. If you have an aspect of programming you're passionate about (arrays, loops, opencv, vision in general, etc) feel free to contribute. Or, if you think something can be explained better, say so! Feedback on this is going to be the most crucial part. If the writers don't know something's bad, we can't fix. If you just want to see something added, open an issue.

You can find the docs here, and the github repo here
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #2   Spotlight this post!  
Unread 03-16-2017, 04:22 PM
GameNCode's Avatar
GameNCode GameNCode is offline
A Bit Of Everything
AKA: Roy Weisfeld
FRC #3075 (HaDream Team)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2013
Location: Israel
Posts: 9
GameNCode is an unknown quantity at this point
Re: FRC Programming, Done Right

I personally think this is a great idea and will surely be keeping an eye on this project.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-16-2017, 05:58 PM
pepemanboy pepemanboy is offline
Registered User
AKA: pepemanboy
no team (ROULT 4403 (2013-2016))
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2013
Location: Mexico
Posts: 71
pepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud ofpepemanboy has much to be proud of
Re: FRC Programming, Done Right

Vision NEEDS to be demistified. It is not hard at all to implement, and even rookie teams can implement a decent vision system.
__________________
ROULT 4403
Student (2013)
Mentor (2014-2016)

Mexico City Regional
Semifinalists 2014
Finalists 2015
Winners 2016
Reply With Quote
  #4   Spotlight this post!  
Unread 03-16-2017, 05:59 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
in hibernation
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,249
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: FRC Programming, Done Right

The trickiest parts of integrating vision have nothing to do with vision...they have to do with integration.
Reply With Quote
  #5   Spotlight this post!  
Unread 03-16-2017, 06:00 PM
tomer tomer is offline
Registered User
FRC #4590 (GreenBlitz)
Team Role: CAD
 
Join Date: Nov 2015
Rookie Year: 2014
Location: Israel
Posts: 18
tomer is an unknown quantity at this point
Re: FRC Programming, Done Right

Really great initiative!!

I would try to contribute some when I have the time.

Just one thing to consider: I am not sure writing language programming guides is as useful, there are many wonderful guides already freely available online and linking to them with some instructions about required as and relevant materials will probably be better than us re-inventing the wheel!
Reply With Quote
  #6   Spotlight this post!  
Unread 03-16-2017, 06:01 PM
tomer tomer is offline
Registered User
FRC #4590 (GreenBlitz)
Team Role: CAD
 
Join Date: Nov 2015
Rookie Year: 2014
Location: Israel
Posts: 18
tomer is an unknown quantity at this point
Re: FRC Programming, Done Right

Quote:
Originally Posted by Jared Russell View Post
The trickiest parts of integrating vision have nothing to do with vision...they have to do with integration.
Integration with control loops? Can you explain some more?
Reply With Quote
  #7   Spotlight this post!  
Unread 03-16-2017, 06:08 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 99
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: FRC Programming, Done Right

This does sound like a noble cause. I'll be seeing how I can help.
Reply With Quote
  #8   Spotlight this post!  
Unread 03-16-2017, 07:16 PM
brian5115's Avatar
brian5115 brian5115 is offline
Registered User
FRC #5115 (Knight Riders)
Team Role: Leadership
 
Join Date: Sep 2016
Rookie Year: 2015
Location: Maryland
Posts: 21
brian5115 is an unknown quantity at this point
Re: FRC Programming, Done Right

Quote:
Originally Posted by tomer View Post
Integration with control loops? Can you explain some more?
I'm not of 254, but I would guess he means integrating the camera with the vision coprocessor with the RIO. 5115 does this with a raspberry pi and a usb webcam, so we set exposure settings and the like using fswebcam (or whichever tool seems to work the best), use python and opencv for processing, and send data to the RIO with networktables. This turns into a giant headache of protocols and linux utilities, whereas just getting the data from the image is pretty simple.

I believe 254 uses an android phone for their vision; I'm interested to hear how it works.
Reply With Quote
  #9   Spotlight this post!  
Unread 03-16-2017, 07:40 PM
lucas.alvarez96's Avatar
lucas.alvarez96 lucas.alvarez96 is offline
Registered User
AKA: Lucas Alvarez
FRC #2576 (Chilean Heart)
Team Role: Alumni
 
Join Date: Dec 2013
Rookie Year: 2013
Location: Chile
Posts: 132
lucas.alvarez96 is a name known to alllucas.alvarez96 is a name known to alllucas.alvarez96 is a name known to alllucas.alvarez96 is a name known to alllucas.alvarez96 is a name known to alllucas.alvarez96 is a name known to all
Re: FRC Programming, Done Right

Quote:
Originally Posted by tomer View Post
Integration with control loops? Can you explain some more?
Adding to what Brian said, integrating the two separate systems (vision and robot) can be a real pain. A channel must be set up for sending data (NetworkTables, UDP sockets, etc.) and startup scripts have to be configured on the co-processor. This isn't extremely hard, but for a rookie team without technical mentors or programmers who have worked in Linux environments before, it becomes quite a challenge.

GRIP has managed to simplify this process quite a bit with deployment to RPi, but considering the amount of hardware out there, it's difficult to support every possible Linux SoC that rookies may get their hands on.
__________________
FRC 2576 2015-2016: Mentor
FRC 2576 2013-2015: Programmer & Chairman's Presenter

Los Angeles Regional 2014: Regional Chairman's Award
Reply With Quote
  #10   Spotlight this post!  
Unread 03-16-2017, 07:40 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,674
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: FRC Programming, Done Right


Demystify the concept of realtime

Many rookie teams, even those with students (or even mentors) who have done some programming do not understand threads and state machines etc. They wonder why their code doesn't work when they spin-wait in Teleop. Explain the concepts, and the proper way to code, in the various FRC languages and frameworks.

Debugging

Many teams don't know what to do when a problem occurs. Debugging should be a methodical process. Explain the built-in debugging support in the various languages (and frameworks). In cases where the framework doesn't have full support, explain the concept of code instrumentation like monitoring for thread execution overruns, missed cycles, and jitter... and toggling an unused DO pin in each thread so you can look at the timing on a scope or logic analyzer.


Reply With Quote
  #11   Spotlight this post!  
Unread 03-16-2017, 07:55 PM
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,739
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: FRC Programming, Done Right

Vision isn't hard. If you've been doing it for a while. But then again, autonomous isn't hard, driving straight in auto isn't hard, and driving a specific distance in auto isn't hard. Yet I'd say perhaps 50% of FRC teams struggle to do those things. At a minimum, to do vision correctly you need to understand:

1. Drive encoders.
2. Gyro.
3. Camera, field of view, trigonometry and methods to calculate distance and angles.
4. Vision software
5. Communication
6. Mechanical integration (the best coder in the world can't do vision if they don't understand momentum, drivetrain backlash, friction, etc etc.)

Now you need to take all of that and reteach it every year so the newest incoming batch of programmers comprehends it all and can do it by the time they are juniors or seniors.

"Vision" by itself isn't horribly difficult - it's all the other 'stuff'.

FYI - differential equations aren't all that hard either
Reply With Quote
  #12   Spotlight this post!  
Unread 03-16-2017, 07:56 PM
phurley67's Avatar
phurley67 phurley67 is offline
Programming Mentor
AKA: Patrick Hurley
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 92
phurley67 is an unknown quantity at this point
Re: FRC Programming, Done Right

Quote:
Originally Posted by tomer View Post
Integration with control loops? Can you explain some more?
Consider the following timeline:

Your robot is moving at 7ft/s following a slight (2/second) curve to the right while de-accelerating. Your camera camera captures an image with the peg vision targets. The vision processing code take 87ms to processes the image, giving you longitudinal and latitudinal offsets as well as the angle to the peg.

Assume everything above is accurate, you are well past the vision part of the problem and now in the thick of the control part of the problem. Your robot has moved over 7" since the image was taken along a complex path. Mix in the fact that you will be getting another 10-15 frames per second to continually adjust your loop against, might get hit by another robot, etc...

You can of course simplify the problem. Stop grab and process image. Rotate and move, etc. But realize that there is a spectrum of difficulty and for the most part, when given vision targets, the actual image processing is not the hardest piece of the puzzle

This is the hard (and fun) stuff.

Last edited by phurley67 : 03-16-2017 at 07:59 PM. Reason: Added summation paragraph
Reply With Quote
  #13   Spotlight this post!  
Unread 03-16-2017, 09:02 PM
Jaci's Avatar
Jaci Jaci is online now
http://imjac.in/ta/name
AKA: Jaci R Brunning
FRC #5333 (Can't C#) #5663 (Ground Control) | (OpenRIO, FRC West Aus)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 392
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: FRC Programming, Done Right

Just as a note, in the variables part of the document, I wouldn't recommend discussing things like what case to use for variables.

In C++, the standard library uses snake_case for functions, while WPILib uses CamelCase, while others might prefer lowerCamelCase. There is no 'right' way to do this, just like the argument of whether the open brace should be on its own line or not. Personally, I use snake_case in C++ and lowerCamelCase in Java, and with the open brace on the same line for both, but others might have different opinions.

The important thing is for it to be consistent.

I'll try and keep an eye on the project as it progresses and see if I can help. Good luck.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor, Former [Captain | Programmer | Driver]
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #14   Spotlight this post!  
Unread 03-16-2017, 10:52 PM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 453
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: FRC Programming, Done Right

I would eliminate the Introduction section as it is currently. Rather good online courses and books already exist for learning Java, C++, and Python. Instead, put the FRC specific things you're not likely to find anywhere else and focus more on the high level concepts that will help people become competitive, not on creating O'Reilly Java/C++/Python: The Good Parts (Except 95% Is Cut Out)
Of course, add in some links to good C++/Java/Python learning resources and wpilib screensteps.
I'd also put a very big warning to steer clear of C++ unless you are ready to make your life extremely difficult* for a small amount of extra performance

* builds take forever, segfaults silently crash your program, debugging is a bad eclipse GUI over gdb over ssh (annoying!), overall basically every C++ language feature comes with 20 ways to do it wrong without realizing
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #15   Spotlight this post!  
Unread 03-16-2017, 11:55 PM
Jaci's Avatar
Jaci Jaci is online now
http://imjac.in/ta/name
AKA: Jaci R Brunning
FRC #5333 (Can't C#) #5663 (Ground Control) | (OpenRIO, FRC West Aus)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 392
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: FRC Programming, Done Right

Quote:
Originally Posted by euhlmann View Post
I'd also put a very big warning to steer clear of C++ unless you are ready to make your life extremely difficult* for a small amount of extra performance

* builds take forever, segfaults silently crash your program, debugging is a bad eclipse GUI over gdb over ssh (annoying!), overall basically every C++ language feature comes with 20 ways to do it wrong without realizing
I would like to respectfully tell you that I disagree.

C/C++ is only a pain if you let it be a pain. If you take the time to learn what's the safe way to do things, and what isn't, you won't have any problems with silent segfaults. Sure, there are many ways to go about doing something, but none of them are the same. You have to identify what is the best for your situation.

Sure, C++ might have a bigger learning curve than Java, but it's learning curve is a lot more _steady_ than Java's. The basics might take a little longer to learn than Java's, but keep in mind that a lot of people that "know" Java only know the basics. Reflection, classloading, security policies, native interfacing are all language features of Java that commonly go unrecognized, not to mention the entire JVM architecture itself.

If anything, C/C++ are the most relevant languages you can learn in your time in FRC, as this is likely what you will be dealing with if you wish to pursue embedded software engineering further. That being said, there's nothing wrong with Java and Python.

None of the FRC languages are bad, it just depends on what your priorities are and what you want to use them for.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor, Former [Captain | Programmer | Driver]
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
Reply


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 07:06 AM.

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