View Single Post
  #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: 103
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