Go to Post "There's plenty of room on the top for everyone" ... it's not a top if everyone is there. - Alyssa [more]
Home
Go Back   Chief Delphi > Technical > Control System
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 17-01-2017, 20:21
Daltz3's Avatar
Daltz3 Daltz3 is offline
Registered User
AKA: Dalton Smith
FRC #0066 (Grizzly Robotics)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ypsilanti, Michigan
Posts: 1
Daltz3 is an unknown quantity at this point
Raspberry Pi as Coprocessor

We plan on using the Raspberry Pi to do our vision processing. How would we output Python script results (after processing) and receive on RoboRio (Java)? I looked into pynetworktables and am confused on how to receive the data from the RoboRio.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-01-2017, 20:28
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 151
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Raspberry Pi as Coprocessor

GRIP has some examples. Specifically samples/frc_find_red_areas.

Basically, you just publish your results to NetworkTables with the pi connected to the roborio/radio/switch with an ethernet cable, then you can read that from your robot program.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2017, 09:49
ryan.mitchell ryan.mitchell is offline
Registered User
FRC #1512 (Big Red)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Middletown, Delaware
Posts: 14
ryan.mitchell is an unknown quantity at this point
Re: Raspberry Pi as Coprocessor

Quote:
Originally Posted by SamCarlberg View Post
GRIP has some examples. Specifically samples/frc_find_red_areas.

Basically, you just publish your results to NetworkTables with the pi connected to the roborio/radio/switch with an ethernet cable, then you can read that from your robot program.
Hi, I am working on the same thing, but in Java. Is there documentation for Network tables in java?
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2017, 09:57
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 151
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Raspberry Pi as Coprocessor

Javadocs here
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2017, 09:59
ryan.mitchell ryan.mitchell is offline
Registered User
FRC #1512 (Big Red)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Middletown, Delaware
Posts: 14
ryan.mitchell is an unknown quantity at this point
Re: Raspberry Pi as Coprocessor

Quote:
Originally Posted by SamCarlberg View Post
Thanks, could you take a look at this code I found on another thread:

Code:
//========================================
//Robot Code
// declare object
NetworkTable cameraTable;

// getinstance (table is a singleton, if one does not exist then one will
// be created otherwise returns reference to existing instance
cameraTable = NetworkTable.getTable("camera");

// get data element from the table
// default values returned if no data has been provided from another source yet

cameraTable.beginTransaction();
Boolean imageFound = cameraTable.getBoolean("found", false );
Double imageOffset = cameraTable.getDouble("offset", -1.0);
Double imageDistance = cameraTable.getDouble("distance", -1.0);
cameraTable.endTransaction();

System.out.println( "found = " + imageFound);
System.out.println( "offset = " + imageOffset);
System.out.println( "distance = " + imageDistance);

//=======================================
// Driver Station PC
// camera image processing is done in C# application on DS

// declare it
private NetworkTable table;

// Init NetworkTable
NetworkTable.setIPAddress("10.6.23.2");  // ip of crio
table = NetworkTable.getTable("camera");


// in the image processing loop

table.beginTransaction();
table.putBoolean("found", true);
table.putDouble("distance", distance);
table.putDouble("offset", offset);
table.endTransaction();
[/quote]

Looks like what I need, but is it missing something (ie setTeam, etc.)?
Reply With Quote
  #6   Spotlight this post!  
Unread 24-01-2017, 10:24
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 151
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Raspberry Pi as Coprocessor

That example is 4 years old. All you have to do on the pi:

Code:
NetworkTable.setClientMode();
NetworkTable.setTeamNumber(1512);
ITable visionTable = NetworkTable.getTable("vision");
That'll set up the pi and a table specifically for vision. If you launch OutlineViewer from Eclipse (WPILib > Launch OutlineViewer), you'll be able to see the values update in realtime.

Then to publish the results from the vision processing

Code:
visionTable.putBoolean("Have target", haveTarget);
visionTable.putNumber("Angle to target", angleToTarget);
...

In your robot program, you'd also declare a table for vision just like we did on the pi. To read the values the pi is publishing, use the corresponding 'get' methods

Code:
haveTarget = visionTable.getBoolean("Have target", false); // default to false
targetAngle = visionTable.getNumber("Angle to target", 0); // default to 0
...
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #7   Spotlight this post!  
Unread 24-01-2017, 10:26
ryan.mitchell ryan.mitchell is offline
Registered User
FRC #1512 (Big Red)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Middletown, Delaware
Posts: 14
ryan.mitchell is an unknown quantity at this point
Re: Raspberry Pi as Coprocessor

Thank you so much!
Reply With Quote
  #8   Spotlight this post!  
Unread 29-01-2017, 23:23
zeldathegood zeldathegood is offline
Registered User
FRC #4277
 
Join Date: Jan 2013
Location: United States
Posts: 33
zeldathegood is an unknown quantity at this point
Quote:
Originally Posted by SamCarlberg View Post
That example is 4 years old. All you have to do on the pi:

Code:
NetworkTable.setClientMode();
NetworkTable.setTeamNumber(1512);
ITable visionTable = NetworkTable.getTable("vision");
That'll set up the pi and a table specifically for vision. If you launch OutlineViewer from Eclipse (WPILib > Launch OutlineViewer), you'll be able to see the values update in realtime.

Then to publish the results from the vision processing

Code:
visionTable.putBoolean("Have target", haveTarget);
visionTable.putNumber("Angle to target", angleToTarget);
...

In your robot program, you'd also declare a table for vision just like we did on the pi. To read the values the pi is publishing, use the corresponding 'get' methods

Code:
haveTarget = visionTable.getBoolean("Have target", false); // default to false
targetAngle = visionTable.getNumber("Angle to target", 0); // default to 0
...
Does anyone know of a vision processing tutorial?


Sent from my Pixel using Tapatalk
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 11:29.

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