turtlebot_addr.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # warning: we don't express a rosdep on netifaces. This is part of the turtlebot image
3 import sys
4 import netifaces
5 
6 for inf in netifaces.interfaces():
7  if inf.startswith('wlan'):
8  addrs = netifaces.ifaddresses(inf)
9  if not netifaces.AF_INET in addrs:
10  continue
11  else:
12  print addrs[netifaces.AF_INET][0]['addr']
13  break
14 else:
15  print >> sys.stderr, "failed to determine IP address"
16  print "127.0.0.1" #bind to loopback for now
17  sys.exit(1)


turtlebot_bringup
Author(s): Tully Foote
autogenerated on Mon Jun 10 2019 15:41:51