Go to Post The most important piece of advice I can give is have someone assigned to pay attention to the batteries. You cannot imagine how many teams end up saying "I thought you were charging the batteries..." - RoboMom [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-01-2017, 21:48
Thardro Thardro is offline
Registered User
AKA: Ethan
FRC #3042 (Cobalt Catalysts)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Minnesota
Posts: 19
Thardro has a spectacular aura aboutThardro has a spectacular aura about
Connecting with roboRIO over TCP

This year we are attempting to do vision processing on an Android phone. We are creating a TCP connection over ADB, and then creating a ServerSocket on the roboRIO and a Socket on the phone, with each having a port 3042 and the hostname on the phone is roborio-3042-frc.local. When we try to accept the ServerSocket on the roboRIO, the program becomes stuck, indicating there is no connection. Has anyone else encountered this, and what can we do to fix the connection?
__________________


Reply With Quote
  #2   Spotlight this post!  
Unread 17-01-2017, 21:52
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 265
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Connecting with roboRIO over TCP

If it hangs, it generally means that the client socket isn't finding (or isn't trying to connect to) the host socket. Double check that your client phone is trying to connect to the host (i.e. it reaches the code that creates the connection), and that you're on the same network.

As a rule of thumb, for things like vision tracking that update on a periodic basis, UDP might be a better idea.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #3   Spotlight this post!  
Unread 17-01-2017, 22:15
Andrew Lobos Andrew Lobos is offline
Registered User
FRC #0225 (TechFire)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Lancaster, PA
Posts: 61
Andrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the rough
Re: Connecting with roboRIO over TCP

If you're using adb for network forwarding, it binds the port on localhost

So if you run "adb reverse tcp:3042 tcp:3042" to setup your port forward on the RIO, then the phone connecting to 127.0.0.1 port 3042 will be forwarded to port 3042 on the RIO - use this instead of the RIO's mDNS name.
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer

2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion
Reply With Quote
  #4   Spotlight this post!  
Unread 17-01-2017, 22:59
Thardro Thardro is offline
Registered User
AKA: Ethan
FRC #3042 (Cobalt Catalysts)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Minnesota
Posts: 19
Thardro has a spectacular aura aboutThardro has a spectacular aura about
Re: Connecting with roboRIO over TCP

Quote:
Originally Posted by Jaci View Post
If it hangs, it generally means that the client socket isn't finding (or isn't trying to connect to) the host socket. Double check that your client phone is trying to connect to the host (i.e. it reaches the code that creates the connection), and that you're on the same network.

As a rule of thumb, for things like vision tracking that update on a periodic basis, UDP might be a better idea.
We have confirmed that the phone is attempting the connection, and they should be on the same network as adb on the roboRIO is detecting the phone. Why would you recommend using UDP over TCP in this case?

Quote:
Originally Posted by Andrew Lobos View Post
If you're using adb for network forwarding, it binds the port on localhost

So if you run "adb reverse tcp:3042 tcp:3042" to setup your port forward on the RIO, then the phone connecting to 127.0.0.1 port 3042 will be forwarded to port 3042 on the RIO - use this instead of the RIO's mDNS name.
Thanks for pointing that out, I could not find which host to use so I assumed it was the mDNS name. I will try this as soon as I can get access to a robot again.
__________________


Reply With Quote
  #5   Spotlight this post!  
Unread 17-01-2017, 23:47
Andrew Lobos Andrew Lobos is offline
Registered User
FRC #0225 (TechFire)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Lancaster, PA
Posts: 61
Andrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the rough
Re: Connecting with roboRIO over TCP

Quote:
Originally Posted by Thardro View Post
We have confirmed that the phone is attempting the connection, and they should be on the same network as adb on the roboRIO is detecting the phone. Why would you recommend using UDP over TCP in this case?
UDP is nicer for an application like this because you don't really care about the advantages TCP provides. In a nutshell, TCP will guarantee delivery of packets as long as the socket is connected. UDP is just simply sending data without any guarantee or verification it will arrive intact.

This is great in the case of vision - you're likely going to be sending updates at a fairly fast rate, so if one packet gets lost you don't really want to care about retransmitting it.

Unfortunately, adb only supports bridging TCP and unix sockets as far as I've found



My team's implementation is similar to yours, except we're running the server on the phone side and the client on the RIO - but I can verify adb reverse works in the same way (binding to localhost).
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer

2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion
Reply With Quote
  #6   Spotlight this post!  
Unread 18-01-2017, 07:32
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 375
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Connecting with roboRIO over TCP

So instead of going through the pain of getting adb working on the rio, we went for a simpler route: USB tethering. With root, the vision app auto-enables it as soon as USB is connected. We've tested, and USB tethering works on the rio with no additional configuration required. It's very simple, and it also supports UDP.
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
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 23:54.

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