Go to Post A well-working FIRST robot can be charismatic. People are attracted to it. Teams rally behind it. Little kids stare with wide eyes. Relatives say to their friends "look at what my niece helped invent". This is an awesome thing. - Andy Baker [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 15-01-2016, 16:46
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
I2C read from Raspberry Pi to RoboRio

Hi fellow programmers,

We've decided to use a raspberry pi for some side processing on our robot this year. We've got all the code in python on the Raspberry Pi done now all we have to do is get it to the roboRIO somehow. We've been playing with the I2C bus port off of the roboRIO's mxp port and running i2cdetect on the Pi comes up with an address of 32 for the roboRIO. Awesome. That's the address we can send data to, from the Pi. Receiving the data on the end of the roboRIO is the difficult part. The I2C library for Java requires a device address in the parameters of the constructor. For the life of me, and my team, we can't find the address of raspberry pi's I2C port. Could someone help us out or devise a way to find the address?

-Cinnamon Toast
  #2   Spotlight this post!  
Unread 15-01-2016, 16:50
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,106
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: I2C read from Raspberry Pi to RoboRio

The issue that you are running into is that both the RoboRIO and the Pi are I2C masters. I'm pretty sure that the RoboRIO can't be run in slave mode, and doing a bit of research it looks like the Pi has trouble being a slave. It looks like the Pi 2 has the pins to be a slave, but I couldn't find any instructions on how to set it up. You might be able to with more research time however.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
  #3   Spotlight this post!  
Unread 15-01-2016, 16:54
dkavanagh dkavanagh is offline
Registered User
FRC #0578 (Red Raider Robotics)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Rochester, NY
Posts: 23
dkavanagh is an unknown quantity at this point
Re: I2C read from Raspberry Pi to RoboRio

I thought about something similar. If you used ethernet on the pi, you could run a web service on the Pi that the Rio could call to get information. If you wanted more of a Push going on, try long polling.
  #4   Spotlight this post!  
Unread 15-01-2016, 16:57
rzoeller rzoeller is offline
MN GOFIRST Recruitment Officer
AKA: Ryan Zoeller
FRC #2169 (RI3D 'Snow Problem; KING TeC)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2007
Location: Savage, MN
Posts: 111
rzoeller is a jewel in the roughrzoeller is a jewel in the roughrzoeller is a jewel in the rough
Re: I2C read from Raspberry Pi to RoboRio

Quote:
Originally Posted by dkavanagh View Post
I thought about something similar. If you used ethernet on the pi, you could run a web service on the Pi that the Rio could call to get information. If you wanted more of a Push going on, try long polling.
Could they hook it into NetworkTables?
__________________
Ri3D - 'Snow Problem Programmer
MN GOFIRST Recruitment Officer
FRC 2169 Alumni
  #5   Spotlight this post!  
Unread 15-01-2016, 17:00
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,106
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: I2C read from Raspberry Pi to RoboRio

Quote:
Originally Posted by rzoeller View Post
Could they hook it into NetworkTables?
It's possible to run NetworkTables on a Raspberry Pi, and currently pynetworktables should work for that and be able to connect to your robot. https://github.com/robotpy/pynetworktables

Using NetworkTables from another language on a Raspberry Pi is harder, as it now uses a native library, however its not too difficult to compile it.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
  #6   Spotlight this post!  
Unread 16-01-2016, 08:22
sraque's Avatar
sraque sraque is offline
Registered User
AKA: Steve Raque
FRC #2614 (MARS)
Team Role: Mentor
 
Join Date: Jun 2012
Rookie Year: 2009
Location: Morgantown, WV
Posts: 84
sraque is on a distinguished road
Re: I2C read from Raspberry Pi to RoboRio

I think I2C is not the best choice for this task, even if you could get the Pi to be the slave.

Consider a Serial UART between the two.
  #7   Spotlight this post!  
Unread 24-01-2016, 09:42
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: I2C read from Raspberry Pi to RoboRio

Thanks for all the replies,

As of right now we are looking into using the serial over the RS-232 port on the roboRIO. All I've got to do is pick up some bi-directional logic level converters. Sparkfun looks like they make some good ones. I'm interested on how I'd set up the communication with pi network tables though. I assume there wouldn't be any interference between basic robot control and the transmission of data. Also, are we allowed to put an ethernet splitter on the new routers? I'm using one port obviously to connect to the roboRIO and the other for the ethernet based axis camera (just to get a field view for orientation when I'm driving). This doesn't exactly leave me any ports for the pi to connect to the router. Any ideas?

-Cinnamon Toast
  #8   Spotlight this post!  
Unread 24-01-2016, 09:50
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 336
fovea1959 will become famous soon enough
Re: I2C read from Raspberry Pi to RoboRio

If you want to run Ethernet between the roboRIO and the rPi, it's straightfoward. Our code to do that from last year is posted. It's for a roboRIO running Java. We didn't post the rPi code (Python), but UDP and JSON from Python are very straightforward....

http://www.chiefdelphi.com/media/papers/3189
  #9   Spotlight this post!  
Unread 28-01-2016, 08:27
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: I2C read from Raspberry Pi to RoboRio

Quote:
Originally Posted by fovea1959 View Post
If you want to run Ethernet between the roboRIO and the rPi, it's straightfoward. Our code to do that from last year is posted. It's for a roboRIO running Java. We didn't post the rPi code (Python), but UDP and JSON from Python are very straightforward....

http://www.chiefdelphi.com/media/papers/3189
Is there any particular reason that you encoded your information to JSON before sending it to the roboRIO over UDP? This looks like a good option to try too. I have zero experience in socket programming as it stands right now though, so I've got some reading to do. Any links on it would be helpful.
  #10   Spotlight this post!  
Unread 29-01-2016, 00:36
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: I2C read from Raspberry Pi to RoboRio

Quote:
Originally Posted by Thad House View Post
The issue that you are running into is that both the RoboRIO and the Pi are I2C masters. I'm pretty sure that the RoboRIO can't be run in slave mode, and doing a bit of research it looks like the Pi has trouble being a slave. It looks like the Pi 2 has the pins to be a slave, but I couldn't find any instructions on how to set it up. You might be able to with more research time however.
Couldn't they technically use SPI then? It'd be faster anyways
__________________
  #11   Spotlight this post!  
Unread 29-01-2016, 14:19
lalondma lalondma is offline
Registered User
AKA: Marc Lalonde
FRC #3990 (Tech for Kids)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Montreal
Posts: 5
lalondma is an unknown quantity at this point
Re: I2C read from Raspberry Pi to RoboRio

Hi,
A few days ago I released code that handles communication between roboRio and RaspberryPi / Odroid over TCP. It's based on the zeromq library, for which a python binding exists I believe. The code itself (C++, for vision tasks) may not be useful but it could give some ideas. And I also provide libmzq.a builds for RaspberryPi, odroid, roborio...
https://github.com/team3990/TechVisionCoproc
  #12   Spotlight this post!  
Unread 30-01-2016, 12:45
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: I2C read from Raspberry Pi to RoboRio

Thanks for all the help so far guys,

Here's what we have so far in terms of UDP programming.

https://github.com/bigbrain890/FlyingToaster2016

UDP transmission does work on the PI end of the programming. We had it sending data over Ethernet to a laptop and the laptop was receiving it with some basic python script. For some reason we can't get the receiving end of the code to work in Java on the robrio. We've got a basic UDP class that should receive data when the getData method is called. Based on just a simple 1 or 0, we should be running our drive chassis forward or backwards in teleop. When we deploy and run the code a couple of weird things happen. First of all, there's no response from the talon srx. It just stays yellow, indicating that it's receiving a value of 0 for drive. Also, any data that we normally write out to the smart dashboard in our teleop section of the Robot.java class ceases to update. Since the runDriver method is called before the SmartDashboard writes out it's value, I wonder if it's getting hung up on the UDP receiving part of the program. We don't get the tell tale error of "Robots don't stop" though, so I'm not inclined to believe that that's the case. Can anyone help us out?

-Cinnamon Toast
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 19:35.

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