Go to Post "Field orientation is like a homing pidgeon that can fly backwards." - LostWolf [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 16-10-2014, 19:44
matan129 matan129 is offline
Registered User
FRC #4757 (Talos)
Team Role: Programmer
 
Join Date: Oct 2014
Rookie Year: 2015
Location: Israel
Posts: 19
matan129 is an unknown quantity at this point
Vision Processing with Raspberry Pi

So, after reading through your suggestions here and consulting with my programming team , we have decided to try developing a vision system for our robot with Raspberry Pi, mainly because we already have one (also, if we wanted to port the code elsewhere afterwards it would be pretty easy).

We are struggling how to start the developing - I have suggested using OpenCV and C++ (.Net implementations are not relevant because they are a pain to compile to ARM, even with Mono).

I just wanted to see if there are any other possibilities/recommendations for developing on the RPi.
Also, how does the communication between the board and the RoboRio/cRio work?

Last edited by matan129 : 16-10-2014 at 19:57.
  #2   Spotlight this post!  
Unread 16-10-2014, 20:03
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by matan129 View Post
Also, how does the communication between the board and the RoboRio/cRio work?
The R-PI UART pins should plug directly into the RoboRio MXP ports' UART pins. I don't know if level shifting is required between those UARTs. On the CRio you need to plug the R-PI UART into a RS-232 to UART converter. Conversely you should try to look at what you can get away with by using just GPIO. Just remember you need to use some sort of level shifting between the R-PI and CRio/RoboRio GPIO.
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #3   Spotlight this post!  
Unread 16-10-2014, 20:15
matan129 matan129 is offline
Registered User
FRC #4757 (Talos)
Team Role: Programmer
 
Join Date: Oct 2014
Rookie Year: 2015
Location: Israel
Posts: 19
matan129 is an unknown quantity at this point
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by jman4747 View Post
The R-PI UART pins should plug directly into the RoboRio MXP ports' UART pins. I don't know if level shifting is required between those UARTs. On the CRio you need to plug the R-PI UART into a RS-232 to UART converter. Conversely you should try to look at what you can get away with by using just GPIO. Just remember you need to use some sort of level shifting between the R-PI and CRio/RoboRio GPIO.
Alright, thanks. And programmatically-wise, how can I output command from the RPi to the RoboRio (and make the RoboRio "understand" them)?

Although I have some programming experience, I have never done anything like this before, and the same goes for the other programmers in my team. So we are starting from scratch.

Last edited by matan129 : 16-10-2014 at 20:17.
  #4   Spotlight this post!  
Unread 16-10-2014, 20:25
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by jman4747 View Post
The R-PI UART pins should plug directly into the RoboRio MXP ports' UART pins. I don't know if level shifting is required between those UARTs. On the CRio you need to plug the R-PI UART into a RS-232 to UART converter. Conversely you should try to look at what you can get away with by using just GPIO. Just remember you need to use some sort of level shifting between the R-PI and CRio/RoboRio GPIO.
The roboRIO serial port on the main board is RS232 levels. The serial port on the MXP is LVTTL levels (5v compatible).
  #5   Spotlight this post!  
Unread 16-10-2014, 20:49
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by matan129 View Post
Alright, thanks. And programmatically-wise, how can I output command from the RPi to the RoboRio (and make the RoboRio "understand" them)?

Although I have some programming experience, I have never done anything like this before, and the same goes for the other programmers in my team. So we are starting from scratch.
Unfortunately I have only done this in LabView and I believe you mentioned using C++. I never did find an example of how to utilize the RS-232 port on the C-Rio and had to ask around here (CD) and experiment which I imagine you will have to do. I could post some LV examples so you can get an idea of the algorithm at least. Also I didn't do much of the work with the R-PI so I can't advise as much there though there are way more tutorials on using the UART on the PI.

Basically UART and RS-232 allow you to send ascii characters over the bus. This makes it very easy to come up with your own command set for your system. You can basically tell the PI to write "SHOOT" or "stop" to the UART and the RIO will see the characters "SHOOT" or "STOP" on the other end and vise versa. You can for instance use an equal to comparator to check if what is in the input buffer is "SHOOT" or not and if it is output a TRUE to be used by some other part of the code.
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #6   Spotlight this post!  
Unread 16-10-2014, 20:58
matan129 matan129 is offline
Registered User
FRC #4757 (Talos)
Team Role: Programmer
 
Join Date: Oct 2014
Rookie Year: 2015
Location: Israel
Posts: 19
matan129 is an unknown quantity at this point
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by jman4747 View Post
Unfortunately I have only done this in LabView and I believe you mentioned using C++. I never did find an example of how to utilize the RS-232 port on the C-Rio and had to ask around here (CD) and experiment which I imagine you will have to do. I could post some LV examples so you can get an idea of the algorithm at least. Also I didn't do much of the work with the R-PI so I can't advise as much there though there are way more tutorials on using the UART on the PI.

Basically UART and RS-232 allow you to send ascii characters over the bus. This makes it very easy to come up with your own command set for your system. You can basically tell the PI to write "SHOOT" or "stop" to the UART and the RIO will see the characters "SHOOT" or "STOP" on the other end and vise versa. You can for instance use an equal to comparator to check if what is in the input buffer is "SHOOT" or not and if it is output a TRUE to be used by some other part of the code.
Alright, I start to get the idea of how this works. So, generally speaking, I should check for UART input (somehow) on the robot side. If I get a predefined command from the RPi (like "Shoot", or "move X degrees left") I should interrupt the currently running command / add a command in the scheduler and so on.
In addition, you have mentioned differences between the cRio (which I have now and I can test on before the kickoff) and the new RoboRio - are these changes going to affect dramatically the code? (I mean more then just changing the line that reads the UART input to the new one, for example)
  #7   Spotlight this post!  
Unread 16-10-2014, 21:10
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by matan129 View Post
In addition, you have mentioned differences between the cRio (which I have now and I can test on before the kickoff) and the new RoboRio - are these changes going to affect dramatically the code? (I mean more then just changing the line that reads the UART input to the new one, for example)
Most likely not. According to the guys who wrote the libraries they are trying to keep them as close to before as possible. In fact if you use the RS-232 port on the RoboRio with the R-PI and a UART to RS-232 converter it may be nearly identical.

A note on the differences between TTL UART and RS-232. RS-232 will likely be more reliable than UART due to the differences in how they signal and I would suggest using UART to 232 conversion.
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #8   Spotlight this post!  
Unread 17-10-2014, 17:10
phurley67 phurley67 is offline
Programming Mentor
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 73
phurley67 is an unknown quantity at this point
Re: Vision Processing with Raspberry Pi

This is a question, not an answer :-)

Is it possible to use networking (TCP/UDP) on the robot when using a co-processor? I know how to do all the networking stuff, but am unsure as to the rules regarding IP addressing, field management, etc.
  #9   Spotlight this post!  
Unread 17-10-2014, 17:32
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by phurley67 View Post
This is a question, not an answer :-)

Is it possible to use networking (TCP/UDP) on the robot when using a co-processor? I know how to do all the networking stuff, but am unsure as to the rules regarding IP addressing, field management, etc.
Are you asking if it is ok to send a udp message from, say a PI, to the roboRIO?

Here is a crude diagram of how we do it:
http://ratchetrockers1706.org/team/t...robot-control/
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
  #10   Spotlight this post!  
Unread 17-10-2014, 17:34
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,624
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Quote:
Originally Posted by phurley67 View Post
This is a question, not an answer :-)

Is it possible to use networking (TCP/UDP) on the robot when using a co-processor? I know how to do all the networking stuff, but am unsure as to the rules regarding IP addressing, field management, etc.
If you are asking if it is legal then the answer is yes it has been legal.
Quite a few robots have been fielded like that.

Just do it properly so you do not shoot yourself in the foot.
Remember that if you miss enough FMS packets at the cRIO/RoboRio your robot will get disabled until you get an FMS packet.
Per the linked topic there's lots of good information in the Einstein report that will help you if you want to try it.
NotInControl's post in the linked topic also seems to be fine advice.

Last edited by techhelpbb : 17-10-2014 at 17:40.
  #11   Spotlight this post!  
Unread 19-10-2014, 08:46
StevenCain's Avatar
StevenCain StevenCain is offline
$@#$@#$@#. coach/ elec. technical adviser
FRC #3865 (Riley Wildbots)
Team Role: Coach
 
Join Date: Sep 2012
Rookie Year: 2012
Location: South Bend, IN
Posts: 3
StevenCain is an unknown quantity at this point
Vision Processing with Raspberry Pi

One word of caution on pi side. Pi can only except 3.3v signals . Most definitely going to need level shifting.GPIO and uart.
How about a FTDI cable between pi USB and use TTL end (seems that everyone is thinking roboRio is TTL at expansion connection - I would want to check this before proceeding) and connect other end to expansion connection. Make sure Tx connected to Rx. And Rx connected to Tx,
Communication flow will have to be handled with xon or xoff (or simply put well thought out timing delays in the code) will probably want to flush the buffer at start of serial initiation. Both processors are capable of multitasking so any lag in image processing may cause some difficulty for the pi.
__________________
Steve Cain - Assistant coach/ electronic tech adviser
Riley Wildbots - Team 3865

2011 Boilermaker Regional Highest Rookie Seed
2012 Boilermaker Regional Regional Finalists
2015 IN District - Kokomo City of Firsts Event
sponsored by AndyMark District Event Winner

Last edited by StevenCain : 19-10-2014 at 08:58.
  #12   Spotlight this post!  
Unread 19-10-2014, 09:17
StevenCain's Avatar
StevenCain StevenCain is offline
$@#$@#$@#. coach/ elec. technical adviser
FRC #3865 (Riley Wildbots)
Team Role: Coach
 
Join Date: Sep 2012
Rookie Year: 2012
Location: South Bend, IN
Posts: 3
StevenCain is an unknown quantity at this point
I wanted to add that Penn robotics implemented a pi vision system (or was working on one). The student's name I remember was Brian contact Jim at team135.
__________________
Steve Cain - Assistant coach/ electronic tech adviser
Riley Wildbots - Team 3865

2011 Boilermaker Regional Highest Rookie Seed
2012 Boilermaker Regional Regional Finalists
2015 IN District - Kokomo City of Firsts Event
sponsored by AndyMark District Event Winner
  #13   Spotlight this post!  
Unread 19-10-2014, 18:22
phurley67 phurley67 is offline
Programming Mentor
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 73
phurley67 is an unknown quantity at this point
Re: Vision Processing with Raspberry Pi

Given that there are no rules against using TCP/IP I would personally tend toward that over the RS-232 route. It will be much faster, more modern examples and easier to test off robot.

If you do decide to use TCP/IP and have questions regarding C/C++ or Labview and network programming feel free to ask, I have been hacking that stuff out for longer than I care to admit.
  #14   Spotlight this post!  
Unread 19-10-2014, 19:39
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Vision Processing with Raspberry Pi

Team Spectrum 3847 has put up a fantastic resource on Vision processing using the RPi. It is the basis for our object recognition software.

It is written in Python, but it makes the entire process easy to understand.
They have set up a TCP socket request receiver to communicate with the cRio/RoboRio.

We have modified this socket receiver to make TCP communication with the cRio easy and stable. We even were able to modify CheesyVision to work with the cRio and LabView with a modified version of the Socket Request Receiver.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
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 03:02.

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