Go to Post Also, after 3 years of FRC I finally hugged that Platypi! - That 281 Guy [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 Rating: Thread Rating: 5 votes, 4.20 average. Display Modes
  #1   Spotlight this post!  
Unread 01-19-2016, 11:51 PM
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Tower Tracker 1.0

Team 3019 graciously presents their vision tracking program for everybody to use and borrow! Now instead of dreaming about the perils of computer vision YOU can bring your team the joy of having a robot that is capable of tracking the target with ease! No more Grip crashes or weird deploys, can calculate fun things such as: distance to target, and angle to target! to be used to auto align and auto aim!

if you are going to modify the code, all i ask is give me and my team credit in a comment at the top of the code and comment your suggestions and or your praise!

to install:
  • download opencv 3.1 from here
  • download Network table 3.0 jar
  • make a new project in eclipse
  • make opencv and networktables added as a user library to the build path of your new project
  • copy opencv_ffmpeg310_64.dll from C:\Path\to\opencv\build\bin to C:\Windows\System32
  • add the code in a class that is named TowerTracker.java
  • when your ready to export
  • export the .jar file as a runnable jar
  • move the .jar to a folder similar to this
  • run the .jar with "java -jar c:\Path\to\TowerTracker.jar" on a command prompt window

the code is just an example of what it can do, i can add network table stuff soon but i thought i would publish it first!
github link

want to see an example of what it can output?
here you go!

how it works: using an axis camera or a mjpeg streamer you can use a stream of a webcam to process images using an opencv program that runs on the driver station computer. This program can be modified to run on a coprocessor and directly input to the roborio for even better results because network tables can only go at 10hz vs the camera stream which is 30hz...this program can easily be ported over to c++ and python and would probably run better with those as c++ and python are way more supported then java with opencv.

Last edited by Fauge7 : 01-20-2016 at 11:27 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-20-2016, 11:56 AM
SenorZ's Avatar
SenorZ SenorZ is online now
Physics Teacher
AKA: Tom Zook
FRC #4276 (Surf City Vikings)
Team Role: Teacher
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Huntington Beach, California
Posts: 895
SenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond reputeSenorZ has a reputation beyond repute
Re: Tower Tracker 1.0

Thank you!

We're looking at non-vision tracking options this year since the retro-tape is so high up. But we'll take a look at this code, too.
__________________
2013-present: FRC Team 4276, Surf City Vikings
2011-2012: FRC Team 3677, The Don Bots
Reply With Quote
  #3   Spotlight this post!  
Unread 01-20-2016, 01:40 PM
akablack akablack is offline
Registered User
no team
 
Join Date: Dec 2015
Location: New York
Posts: 5
akablack is an unknown quantity at this point
Re: Tower Tracker 1.0

WOW! Awesome work! One question, Can this be deployed to run on the roborio ?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-20-2016, 05:26 PM
mklinker's Avatar
mklinker mklinker is offline
Coach FRC4485
AKA: Mike Klinker
FRC #4485 (Tribe Tech Robotics)
Team Role: Mentor
 
Join Date: Oct 2012
Rookie Year: 2013
Location: Danville, IN
Posts: 96
mklinker is a splendid one to beholdmklinker is a splendid one to beholdmklinker is a splendid one to beholdmklinker is a splendid one to beholdmklinker is a splendid one to beholdmklinker is a splendid one to beholdmklinker is a splendid one to behold
Re: Tower Tracker 1.0

Where do I install the Network Table 3.0 jar
__________________
Mike Klinker Mentor, Tribe Tech Robotics FRC 4485

2016 Walker Warren District Semi-Finalist
2015 Indiana District Championship Semi-Finalist, Purdue District Quarter Finalist, Kokomo District Quarter Finalist, R2OC Finalist
2014 Boilermaker Regional Quarter Finalist


Reply With Quote
  #5   Spotlight this post!  
Unread 01-20-2016, 11:17 PM
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Tower Tracker 1.0

Quote:
Originally Posted by akablack View Post
WOW! Awesome work! One question, Can this be deployed to run on the roborio ?
Yes! The only problem with running it on the rio is with the vision tracking will take up too much of the rio's resources and might lag out the robot. If you are going to do this I would suggest using a linux board such as a raspi 2 or an odroid c1+, they both run linux so they have similar interfaces and have more support. This will also allow you to do much more advanced tracking such as real time object tracking and detection

Quote:
Originally Posted by mklinker View Post
Where do I install the Network Table 3.0 jar
Network table goes in as a user library(tutorial) in your eclipse project, you will not need to do anything when you export the .jar unlike for opencv.
When you export the .jar file put it in a folder that looks similar to this where opencv_java310.dll could be opencv_java310.so for linux

Last edited by Fauge7 : 01-20-2016 at 11:37 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 01-20-2016, 11:27 PM
Munchskull's Avatar
Munchskull Munchskull is offline
CAD Designer/ Electrical Consaltant
AKA: Anthony Cardinali
FRC #0997 (Spartan Robotics)
Team Role: CAD
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Corvallis, OR
Posts: 493
Munchskull is a splendid one to beholdMunchskull is a splendid one to beholdMunchskull is a splendid one to beholdMunchskull is a splendid one to beholdMunchskull is a splendid one to beholdMunchskull is a splendid one to beholdMunchskull is a splendid one to behold
Re: Tower Tracker 1.0

Could this run on a C.H.IP computer?
__________________
“In theory, theory and practice are the same. In practice, they are not.” ― Anonymous
Anthony Cardinali
4th year of FRC
Class of 2017



Reply With Quote
  #7   Spotlight this post!  
Unread 01-20-2016, 11:31 PM
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Tower Tracker 1.0

Quote:
Originally Posted by Munchskull View Post
Could this run on a C.H.IP computer?
as long as it can run java, it can run...so theoretically, but this begs the question if you would WANT to run it on a chip computer...why wouldnt you upgrade to atleast a raspi or an odroid? at 35$ they provide atleast 4x the processing power, which makes every ounce of difference if you want realtime video processing...you could get away with only one or two frames...
Reply With Quote
  #8   Spotlight this post!  
Unread 01-21-2016, 07:28 AM
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 189
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Tower Tracker 1.0

Quote:
Originally Posted by Fauge7 View Post
Yes! The only problem with running it on the rio is with the vision tracking will take up too much of the rio's resources and might lag out the robot.
Im not an expert on multithreading, but would you still experience the lag if you ran the the code on a seperate thread on the roboRIO?

Thank you for this code, I have ported it to c++. I am running it on a separate thread, but just with a static image for now.
Reply With Quote
  #9   Spotlight this post!  
Unread 01-21-2016, 08:43 AM
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Tower Tracker 1.0

Quote:
Originally Posted by jreneew2 View Post
would you still experience the lag if you ran the the code on a seperate thread on the roboRIO
I am not an expert either which is why it is not multithreaded but my understanding of the Rio is that it already uses both cores to run the robot code. So I think it still might, of course why wouldn't you just test this and get back to me, it's an open source project
Reply With Quote
  #10   Spotlight this post!  
Unread 01-21-2016, 10:20 AM
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Tower Tracker 1.0

Thank you so much for making your java vision tracking solution public. For our team vision tracking seemed extremely daunting but this made it a realistic task.

I am trying to run the jar but I get a couple of errors. I may have added the network table user library incorrectly.
The steps I took are as follows: I made a new java project, added the user library for opencv following this tutorial: http://docs.opencv.org/2.4/doc/tutor...a_eclipse.html.
Then I added the network table user library from this directory: C:\Users\Curtis Johnston\wpilib\java\current\lib.
When I try to run the executable jar from command prompt I get the following errors.

Code:
platform: /Windows/amd64/
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ntcore in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at edu.wpi.first.wpilibj.networktables.NetworkTablesJNI.<clinit>(NetworkTablesJNI.java:57)
	at edu.wpi.first.wpilibj.networktables.NetworkTable.initialize(NetworkTable.java:42)
	at edu.wpi.first.wpilibj.networktables.NetworkTable.getTable(NetworkTable.java:176)
	at testing.TowerTracker.main(TowerTracker.java:80)
Reply With Quote
  #11   Spotlight this post!  
Unread 01-21-2016, 10:23 AM
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 189
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Tower Tracker 1.0

Quote:
Originally Posted by Fauge7 View Post
I am not an expert either which is why it is not multithreaded but my understanding of the Rio is that it already uses both cores to run the robot code. So I think it still might, of course why wouldn't you just test this and get back to me, it's an open source project
Yeah, I will tonight. I'm using static images now, but tonight i can set up some tape and test.

Again, thank you for this code, it is very helpful.
Reply With Quote
  #12   Spotlight this post!  
Unread 01-21-2016, 10:35 AM
kmckay's Avatar
kmckay kmckay is offline
Registered User
FRC #5401 (Fightin' Robotic Owls)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Bensalem, PA
Posts: 39
kmckay will become famous soon enough
Re: Tower Tracker 1.0

Quote:
Originally Posted by jreneew2 View Post

Thank you for this code, I have ported it to c++. I am running it on a separate thread, but just with a static image for now.
Would you be open to sharing the C++ version?
Reply With Quote
  #13   Spotlight this post!  
Unread 01-21-2016, 10:36 AM
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Tower Tracker 1.0

Quote:
Originally Posted by curtis0gj View Post
Thank you so much for making your java vision tracking solution public. For our team vision tracking seemed extremely daunting but this made it a realistic task.

I am trying to run the jar but I get a couple of errors. I may have added the network table user library incorrectly.
C:\Users\Curtis Johnston\wpilib\java\current\lib.
When I try to run the executable jar from command prompt I get the following errors.
for some reason first still distributes networktable 2.0, you are looking for the network tables 3.0
the specific file you want is the edu.wpi.first.wpilib.networktables.cpp:NetworkTabl es:3.0.0-SNAPSHOT

there it has the instructions for downloading the newest .jar file for the network tables...I made the same mistake when making this
Reply With Quote
  #14   Spotlight this post!  
Unread 01-21-2016, 10:39 AM
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Tower Tracker 1.0

The roboRIO has two cores and a modern linux scheduler. All processes and threads will be assigned to a processor core based on priority and history of execution. The default robot code doesn't use the entire roboRIO to execute, and in fact can be made much lighter and efficient if that is what the team chooses to do.

It is quite easy to consume an entire core on any computer by writing one loop without a wait or delay of some sort. At that point, you can add more cores or fix the problem.

There are intentionally many ways to approach the vision processing challenge, and the tradeoffs are as team-based as technical. I fully expect to see awesome processing based on the DB laptop, based on coprocessors, and based on just the roboRIO. None of these are, in my opinion, a bad approach. And of course there are teams who will solve the challenge with no camera at all.

By the way, the DS shows you the CPU trace of the roboRIO in realtime. Just click on the second or third tab on the right side. This info is also logged and can be reviewed using the Log File Viewer after a practice or a match. If the robot feels sluggish, you can try to identify if it was because you maxed the CPU or something else.

Greg McKaskle
Reply With Quote
  #15   Spotlight this post!  
Unread 01-21-2016, 12:52 PM
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 189
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: Tower Tracker 1.0

Quote:
Originally Posted by kmckay View Post
Would you be open to sharing the C++ version?
https://github.com/team2053tigertron...016/src/vision

Its a bit messy, and the algorithm is a bit different, but you can change it easily. Also, im getting resource initialized error after a while. It might be an array error.

Last edited by jreneew2 : 01-21-2016 at 12:56 PM.
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 08:28 PM.

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