Go to Post Just because something has never been done, doesn't mean it's impossible. See: everything ever. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 15-01-2014, 00:19
jrmeza514 jrmeza514 is offline
Registered User
FRC #2643
 
Join Date: Jan 2014
Location: United States
Posts: 1
jrmeza514 is an unknown quantity at this point
Angry Custom Vision Processing

Hello,

I am a member of team 2643 and we havedecided to make our own custom vision tool. We were able to get it working marvelously on a regular java project, but as well you may know FRC applications remove some of the java classes and libraries. For example, Math.atan() does no exist. Anyway, our application is dependent on the following classes: java.awt.Image , java.awt.BufferedImage, java.net.URL, java.awt.Graphics, and java.imageio.ImageIO; Here is the problem: none of these classes actually exist in an FRC java application. I have tried fetching those files one by one but the problem is that all that all those files have endless references to other files, making the task impossible. I also the tried extracting all .class files from the .jar files in my JDK directory and decompiling them to .java files and dragging them into the project's SRC directory. This would have worked except it slowed netbeans down to the point that it was inoperable. I guess that what I want is to find a way to upload a library to my FRC application from a .jar file or find an application that can tell me which files are absolutely necessary for my application to work. I anyone can provide me with a solution I
would greatly appreciate it.

-JuanMeza, Team 2643
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2014, 10:37
muaddib42 muaddib42 is offline
Registered User
FRC #3128
 
Join Date: Jan 2013
Location: United States
Posts: 9
muaddib42 is an unknown quantity at this point
This is not necessarily possible. The Java environment is based off of J2ME, almost any library you will use is going to be based on J2SE. On a side note the squawk MathUtils class has a lot of implementations of the J2SE math functions.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-01-2014, 03:05
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 108
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Custom Vision Processing

It is possible to do the vision processing outside of the cRIO (as a stand-alone Java application). You can:
  • Create a stand-alone Java application which grabs image data directly from the IP camera (it sounds like you have completed this step).
  • Send the computed information from your Java application back to your robot program running on the cRIO (the step you need to do).

There are several ways to send the information back. Probably the easiest method is to use the NetworkTable objects provided in the FRC plugins. Add the networktables-desktop.jar JAR file to your stand alone Java project. It can be found under the $HOME/sunspotfrcsdk/desktop-lib folder (where $HOME refers to your home directory - something like C:\Users\LOGIN_NAME if you are on a Windows system).

Once the JAR file has been added to your project you should be able to use the NetworkTable objects. Somewhere in your initialization code, you can add code similar to the following (use the IP address of your cRIO):

Code:
NetworkTable smartDashboard;

private void setupRobotComm() {
   NetworkTable.setClientMode();
   // NOTE: Change to the IP address of your cRIO
   NetworkTable.setIPAddress("10.8.68.2");

   // Get access to the smart dashboard values (allows both put and get)
   smartDashboard = NetworkTable.getTable("SmartDashboard");
}
Once your image processing code has information to deliver to the robot, you can use the "put" methods to deliver the information to the robot:

Code:
private void sendRobotInfo(boolean leftHot, boolean rightHot) {
  smartDashboard.putBoolean("Left Goal Hot", leftHot);
  smartDashboard.putBoolean("Right Goal Hot", rightHot);
}
The NetworkTable class should deliver this information to both the robot and the smart dashboard. Within your robot code, you should be able to check the state of these values using methods like the following (make sure your key names match):

Code:
public boolean isLeftHot() {
  return SmartDashboard.getBoolean("Left Goal Hot");
}
There are some good/bad things related to using this approach:
  • It allows more rapid image processing code development (you don't have to have a cRIO to develop your code).
  • It consumes WIFI bandwidth if you run your image processing code on your driver station (there may be a 7Mbps limit this year). Some teams will put a computer on the robot to avoid this - our team has not gone to this extreme yet.
  • The NetworkTable approach is simple, but introduces it's own delay. If it's too much for your needs, you could alternatively use UDP or TCP to deliver th e information.
  • You get the diagnostic output on the Smart Dashboard for free.
  • You will keep a lot of the image processing load off of the cRIO CPU.

Hope that helps.
Paul
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 12:42.

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