module documentation

Network APIs for ROS-based systems, including IP address and ROS TCP header libraries. Because ROS-based runtimes must respect the ROS_IP and ROS_HOSTNAME environment variables, ROS-specific APIs are necessary for correctly retrieving local IP address information.

Exception ROSHandshakeException Exception to represent errors decoding handshake
Function create_local_xmlrpc_uri Determine the XMLRPC URI for local servers. This handles the search logic of checking ROS environment variables, the known hostname, and local interface IP addresses to determine the best possible URI.
Function decode_ros_handshake_header Decode serialized ROS handshake header into a Python dictionary
Function encode_ros_handshake_header Encode ROS handshake header as a byte string. Each header field is a string key value pair. The encoded header is prefixed by a length field, as is each field key/value pair. key/value pairs a separated by a '=' equals sign.
Function get_address_override No summary
Function get_bind_address No summary
Function get_host_name if ROS_IP/ROS_HOSTNAME is set, use that address
Function get_local_address No summary
Function get_local_addresses No summary
Function is_local_address No summary
Function parse_http_host_and_port Convenience routine to handle parsing and validation of HTTP URL port due to the fact that Python only provides easy accessors in Python 2.5 and later. Validation checks that the protocol and host are set.
Function read_ros_handshake_header Read in tcpros header off the socket \x07 sock using buffer \x07 b.
Function use_ipv6 Undocumented
Function write_ros_handshake_header Write ROS handshake header header to socket sock
Variable logger Undocumented
Variable python3 Undocumented
Variable SIOCGIFADDR Undocumented
Variable SIOCGIFCONF Undocumented
Function _is_unix_like_platform @rtype: bool
Variable _local_addrs Undocumented
def create_local_xmlrpc_uri(port):

Determine the XMLRPC URI for local servers. This handles the search logic of checking ROS environment variables, the known hostname, and local interface IP addresses to determine the best possible URI.

Parameters
portport that server is running on, int
Returns
XMLRPC URI, str
def decode_ros_handshake_header(header_str):

Decode serialized ROS handshake header into a Python dictionary

header is a list of string key=value pairs, each prefixed by a 4-byte length field. It is preceded by a 4-byte length field for the entire header.

Parameters
header_strencoded header string. May contain extra data at the end, str
Returns
key value pairs encoded in \x07 header_str, {str: str}
def encode_ros_handshake_header(header):

Encode ROS handshake header as a byte string. Each header field is a string key value pair. The encoded header is prefixed by a length field, as is each field key/value pair. key/value pairs a separated by a '=' equals sign.

FORMAT: (4-byte length + [4-byte field length + field=value ]*)

Parameters
headerheader field keys/values, dict
Returns
header encoded as byte string, bytes
def get_address_override():
Returns
ROS_IP/ROS_HOSTNAME override or None, str
Raises
Unknown exceptionValueError If ROS_IP/ROS_HOSTNAME/__ip/__hostname are invalidly specified
def get_bind_address(address=None):
Parameters
address(optional) address to compare against, str
Returns
address TCP/IP sockets should use for binding. This is generally 0.0.0.0, but if \x07 address or ROS_IP/ROS_HOSTNAME is set to localhost it will return 127.0.0.1, str
def get_host_name():

Determine host-name for use in host-name-based addressing (e.g. XML-RPC URIs):
  • if ROS_IP/ROS_HOSTNAME is set, use that address
  • if the hostname returns a non-localhost value, use that
  • use whatever L{get_local_address()} returns

def get_local_address():
Returns
default local IP address (e.g. eth0). May be overridden by ROS_IP/ROS_HOSTNAME/__ip/__hostname, str
def get_local_addresses():
Returns
known local addresses. Not affected by ROS_IP/ROS_HOSTNAME, [str]
def is_local_address(hostname):
Parameters
hostnamehost name/address, str
Returns
if hostname maps to a local address, False otherwise. False conditions include invalid hostnames.
def parse_http_host_and_port(url):

Convenience routine to handle parsing and validation of HTTP URL port due to the fact that Python only provides easy accessors in Python 2.5 and later. Validation checks that the protocol and host are set.

Parameters
urlURL to parse, str
Returns
hostname and port number in URL or 80 (default), (str, int)
Raises
Unknown exceptionValueError If the url does not validate
def read_ros_handshake_header(sock, b, buff_size):

Read in tcpros header off the socket \x07 sock using buffer \x07 b.

Parameters
socksocket must be in blocking mode, socket
bbuffer to use, StringIO for Python2, BytesIO for Python 3
buff_sizeincoming buffer size to use, int
Returns
key value pairs encoded in handshake, {str: str}
Raises
Unknown exceptionROSHandshakeException If header format does not match expected
def use_ipv6():

Undocumented

def write_ros_handshake_header(sock, header):

Write ROS handshake header header to socket sock

Parameters
socksocket to write to (must be in blocking mode), socket.socket
headerheader field keys/values, {str : str}
Returns
Number of bytes sent (for statistics), int
logger =

Undocumented

python3: int =

Undocumented

SIOCGIFADDR: int =

Undocumented

SIOCGIFCONF: int =

Undocumented

def _is_unix_like_platform():

@rtype: bool

Returns
true if the platform conforms to UNIX/POSIX-style APIs
_local_addrs =

Undocumented