Go to Post Stacking totes on end; Gives you extra height, alas; Topples with a sneeze. - BethMo [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
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 12-05-2016, 21:28
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Python Network Tables Raspberry Pi 2

I am looking for some in-site on the python network tables. I am using the example code found here. I try to run it and I get and error stating that I need to set my ipadress. I read up on the error here. Where would you put the IP adress and what would it be? It doesn't seem to be that well explain for newbies. Thanks for any help ahead of time.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-05-2016, 21:42
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 217
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by tomy View Post
I am looking for some in-site on the python network tables. I am using the example code found here. I try to run it and I get and error stating that I need to set my ipadress. I read up on the error here. Where would you put the IP adress and what would it be? It doesn't seem to be that well explain for newbies. Thanks for any help ahead of time.
In the Driver Station example you linked, the IP is set through sys.arg. For me, I just skip that and set the IP directly like this:
Code:
NetworkTable.setIPAddress("10.XX.XX.XX")#Your IP goes here
So the entire code would look like this if you were using the example(This is untested but is similar to what I used before):
Code:
import time
from networktables import NetworkTable

# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)


NetworkTable.setIPAddress("10.XX.XX.XX")#Change the address to your own
NetworkTable.setClientMode()
NetworkTable.initialize()

sd = NetworkTable.getTable("SmartDashboard")

i = 0
while True:
    try:
        print('robotTime:', sd.getNumber('robotTime'))
    except KeyError:
        print('robotTime: N/A')

    sd.putNumber('dsTime', i)
    time.sleep(1)
    i += 1
Just makes sure to change IP address and that should be a working example. Let me know if it still doesn't work!
__________________
#Python4Life
Reply With Quote
  #3   Spotlight this post!  
Unread 12-05-2016, 22:08
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by team-4480 View Post
In the Driver Station example you linked, the IP is set through sys.arg. For me, I just skip that and set the IP directly like this:
Code:
NetworkTable.setIPAddress("10.XX.XX.XX")#Your IP goes here
So the entire code would look like this if you were using the example(This is untested but is similar to what I used before):
Code:
import time
from networktables import NetworkTable

# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)


NetworkTable.setIPAddress("10.XX.XX.XX")#Change the address to your own
NetworkTable.setClientMode()
NetworkTable.initialize()

sd = NetworkTable.getTable("SmartDashboard")

i = 0
while True:
    try:
        print('robotTime:', sd.getNumber('robotTime'))
    except KeyError:
        print('robotTime: N/A')

    sd.putNumber('dsTime', i)
    time.sleep(1)
    i += 1
Just makes sure to change IP address and that should be a working example. Let me know if it still doesn't work!
So if I am running this on a raspberry pi 2 I would put the ip adress of the roboRio? If so should I change the roboRio to a static IP address such as 10.xx.yy.?? --> xx.yy would be team name but what would the ?? be at the end?

Thanks for you help.
Reply With Quote
  #4   Spotlight this post!  
Unread 12-05-2016, 22:13
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 217
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by tomy View Post
So if I am running this on a raspberry pi 2 I would put the ip adress of the roboRio? If so should I change the roboRio to a static IP address such as 10.xx.yy.?? --> xx.yy would be team name but what would the ?? be at the end?

Thanks for you help.
Yes, you would put the address of the roboRio. It has been a while since I used networktables so I don't quite remember, but if I recall correctly, you can use roborio-xxxx-frc.local where xxxx is obviously your team number. If that doesn't work, you can use the 10.xx.xx.?? where the ?? is where the Rio is located on your network. To find this out, connect to the WiFi network and type "roborio-xxxx-frc.local" into your browser(again your team number) and the webpage for the Rio will pop up. There, you will see the exact address of the Rio.
__________________
#Python4Life

Last edited by team-4480 : 12-05-2016 at 22:16.
Reply With Quote
  #5   Spotlight this post!  
Unread 12-05-2016, 22:31
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by team-4480 View Post
Yes, you would put the address of the roboRio. It has been a while since I used networktables so I don't quite remember, but if I recall correctly, you can use roborio-xxxx-frc.local where xxxx is obviously your team number. If that doesn't work, you can use the 10.xx.xx.?? where the ?? is where the Rio is located on your network. To find this out, connect to the WiFi network and type "roborio-xxxx-frc.local" into your browser(again your team number) and the webpage for the Rio will pop up. There, you will see the exact address of the Rio.
On the trouble shooting link it states

Quote:
Yes, I know it says setIPAddress... it will accept a hostname also. If you are team 1234, then the hostname would be ‘roborio-1234.local’. Make sure you have an mDNS client installed on the coprocessor (like avahi)
Do you know how avahi works?
Reply With Quote
  #6   Spotlight this post!  
Unread 12-05-2016, 22:42
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 217
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by tomy View Post
Do you know how avahi works?
I haven't ever used it since I have always used the driver station for vision(which is what I assume the Pi is for). It appears that avahi is available through "apt-get" which would pretty easy to install then. Have you tried the script without installing avahi? Does it not work?
__________________
#Python4Life
Reply With Quote
  #7   Spotlight this post!  
Unread 12-05-2016, 22:52
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by team-4480 View Post
I haven't ever used it since I have always used the driver station for vision(which is what I assume the Pi is for). It appears that avahi is available through "apt-get" which would pretty easy to install then. Have you tried the script without installing avahi? Does it not work?
I haven't tried it yet. I'm just thinking ahead in case it doesn't work. Thanks again for you help I will let you know if it works tomorrow.
Reply With Quote
  #8   Spotlight this post!  
Unread 13-05-2016, 11:22
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,045
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: Python Network Tables Raspberry Pi 2

When using a coprocessor (at least this year), you're better off setting everything up with static IPs. There are issues connecting to the roborio when mDNS is used.
__________________
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
Reply With Quote
  #9   Spotlight this post!  
Unread 13-05-2016, 12:24
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: 317
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: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by virtuald View Post
There are issues connecting to the roborio when mDNS is used.
Quite unsurprisingly.
Reply With Quote
  #10   Spotlight this post!  
Unread 13-05-2016, 12:52
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by euhlmann View Post
Quite unsurprisingly.
Yeah my team had a plethora of issues in districts than worked totally fine at MICMP and CMP after switching to static. mDNS just isn't as battle tested as static ip
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #11   Spotlight this post!  
Unread 13-05-2016, 13:49
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by Arhowk View Post
Yeah my team had a plethora of issues in districts than worked totally fine at MICMP and CMP after switching to static. mDNS just isn't as battle tested as static ip

I've heard about people having troubles with mDNS but I dont know what it is or how to change it? Can someone explain it to me?
Reply With Quote
  #12   Spotlight this post!  
Unread 13-05-2016, 17:55
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: 317
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: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by tomy View Post
I've heard about people having troubles with mDNS but I dont know what it is or how to change it? Can someone explain it to me?
Assign a static IP (such as 10.te.am.2) for the roborio on the networking tab of its NI web dashboard.

Choose "static" in the dropdown and then enter the static IP you want.

Last edited by euhlmann : 13-05-2016 at 17:59.
Reply With Quote
  #13   Spotlight this post!  
Unread 13-05-2016, 18:10
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by euhlmann View Post
Assign a static IP (such as 10.te.am.2) for the roborio on the networking tab of its NI web dashboard.

Choose "static" in the dropdown and then enter the static IP you want.
Thank you! That helps a lot.

Last edited by tomy : 13-05-2016 at 21:23.
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 21:39.

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