Go to Post What can you do? The more time you waste here speculating the less time you have to work on the robot. Go! Build Robots! Now! - Jessica Boucher [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2014, 22:35
Merfoo's Avatar
Merfoo Merfoo is offline
Registered User
FRC #0955 (CV Robotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: America
Posts: 48
Merfoo is an unknown quantity at this point
Talk to rpi from crio

Hello, so we're using opencv python on the raspberry pi this year for vision process and we're wondering how we get/send data like booleans, doubles, ints, strings to the pi from the crio in java. I've seen posts talking about i2c and udp but they dont talk how to do it/show code examples. Are there any examples to help us get started?
  #2   Spotlight this post!  
Unread 25-01-2014, 00:04
daniel_dsouza daniel_dsouza is offline
does what needs to be done.
FRC #2449 (Out of Orbit Robotics)
Team Role: Alumni
 
Join Date: May 2011
Rookie Year: 2011
Location: Chandler, AZ
Posts: 231
daniel_dsouza has a spectacular aura aboutdaniel_dsouza has a spectacular aura about
Re: Talk to rpi from crio

i am working on pretty much the same idea. I don't have any code yet, as my past week has been spent dealing with team administration issues, but if you don't have something by the time I have finished mine, I would be happy to share what I will write with you!
  #3   Spotlight this post!  
Unread 25-01-2014, 00:28
bijan311 bijan311 is offline
Registered User
FRC #1714
Team Role: Alumni
 
Join Date: May 2013
Rookie Year: 2013
Location: Wisconsin
Posts: 11
bijan311 is an unknown quantity at this point
Re: Talk to rpi from crio

I'm not sure how much this will help you because it is written in C++ and not java, but my team has successfully created a camera tracking program on the raspberry pi that sends the data to the CRio via udp packets. The code can be found here (the code used on the raspberry pi is in the raspberry pi folder and the rest is robot code).

To send the integer values to the CRio, we just used a some if statements to convert them to strings, and when receiving the data we converted them back into integers.

I hope this helps. If you have any more questions I will try to respond to them as soon as possible.
  #4   Spotlight this post!  
Unread 27-01-2014, 11:34
amreuland's Avatar
amreuland amreuland is offline
Overworked Insomniac
AKA: Austin
FRC #2583 (Westwood Robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Austin TX
Posts: 18
amreuland is on a distinguished road
Re: Talk to rpi from crio

Since you are using python, you can use a NetTables implementation.
I found that Team 3574's try at it is pretty good.
https://github.com/Team3574/2013Visi...c/nt_client.py

To set values in python:
Code:
from nt_client import NetworkTableClient

nt = NetworkTableClient("Team Number")
nt.setValue("key name", data) # Data can be number, string, boolean
To get values in python:
Code:
value = nt.getValue("key name")
To get the value in java:
Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;

NetworkTable table = NetworkTable.getTable("Table Name");
table.putNumber("key name", double);
table.putBoolean("key name", boolean);
table.putString("key name", String);
To set values:
Code:
double number = table.getNumber("key name");
boolean bool = table.getBoolean("key name");
String str = table.getString("key name");
  #5   Spotlight this post!  
Unread 27-01-2014, 12:45
gluxon's Avatar
gluxon gluxon is offline
\n
AKA: Brandon Cheng
FRC #0178 (The 2nd Law Enforcers)
Team Role: Leadership
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Connecticut
Posts: 65
gluxon has a spectacular aura aboutgluxon has a spectacular aura aboutgluxon has a spectacular aura about
Re: Talk to rpi from crio

My question is, Why would you need to? For most vision processing configurations, the Raspberry Pi would talk directly with the camera, then send data to the cRIO one-way.

If you must go the other way, I would recommend the NetworkTables as well. Otherwise, a simple udp server and client should do it for C++.
  #6   Spotlight this post!  
Unread 27-01-2014, 14:59
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Talk to rpi from crio

Last year Team 3946 used a network Socket Connection to talk between the crio and rpi.

Basically we had a Socket Server running in Python on the RPI and a Socket Client in Java on the cRIO.

Here is the code we used:

Python Side:
PyGoalFinder

Java Side:

This is the code that actually ran the socket in a separate thread and parsed the data.
ThreadedPi.java

This is the Subsystem we used to Interface the system:
ThreadedberryPi.java
__________________
Programmer - A creature known for converting Caffeine into Code.
Studying Computer Science @ Louisiana Tech University
Associate Consultant @ Fenway Group

2012-13: 3946 - Head of Programming, Electrical and Web
2014 - 3468 - Programming Mentor
2015 - Present - Lurker
  #7   Spotlight this post!  
Unread 29-01-2014, 00:41
Merfoo's Avatar
Merfoo Merfoo is offline
Registered User
FRC #0955 (CV Robotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: America
Posts: 48
Merfoo is an unknown quantity at this point
Re: Talk to rpi from crio

So if I want to use the NetworkTable "tableData" in python using https://github.com/Team3574/2013Visi...c/nt_client.py it would be
Code:
client = NetworkTable("tableData")
and in java it would be
Code:
NetworkTable table = NetworkTable.getTable("tableData");
?
  #8   Spotlight this post!  
Unread 29-01-2014, 01:16
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,089
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Talk to rpi from crio

I would recommend using pynetworktables. It's a cross-platform python wrapper (so everything in NetworkTables is implemented) around the official WPILib implementation of NetworkTables, and has sample code that comes with it.

Github site: https://github.com/robotpy/pynetworktables
Samples: https://github.com/robotpy/pynetwork...master/samples
Windows binaries: http://firstforge.wpi.edu/sf/frs/do/...ktables.2014_1
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #9   Spotlight this post!  
Unread 29-01-2014, 13:05
sparkytwd's Avatar
sparkytwd sparkytwd is offline
Registered User
FRC #3574
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Seattle
Posts: 101
sparkytwd will become famous soon enough
Re: Talk to rpi from crio

Quote:
Originally Posted by Merfoo View Post
So if I want to use the NetworkTable "tableData" in python using https://github.com/Team3574/2013Visi...c/nt_client.py it would be
Code:
client = NetworkTable("tableData")
and in java it would be
Code:
NetworkTable table = NetworkTable.getTable("tableData");
?
For python it would be

client = NetworkTableClient("955")

You can run nt_client.py from the command line like so:

python nt_client.py 955 and it will set some test values for you.

Last edited by sparkytwd : 29-01-2014 at 13:46.
Closed Thread


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 16:17.

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