roslua: ROS client library for Lua

Module roslua.tcpros

TCPROS communication implementation. This module contains classes that implement the TCPROS communication protocol for topic as well as service communication. The user should not have to use these directly, rather they are encapsulated by the Publisher, Subscriber, Service, and ServiceClient classes.

Copyright© Tim Niemueller, Carnegie Mellon University, Intel Research Pittsburgh

Release: Released under BSD license

Functions

TcpRosConnection:accept () Accept new connections.
TcpRosConnection:bind () Bind to random port as server.
TcpRosConnection:close () Close connection.
TcpRosConnection:connect (host, port) Connect to given host and port.
TcpRosConnection:data_available () Check if data is available.
TcpRosConnection:data_received () Check if data has been received.
TcpRosConnection:get_ip_port () Get IP and port of socket.
TcpRosConnection:get_stats () Get connection statistics.
TcpRosConnection:new (socket) Constructor.
TcpRosConnection:receive () Receive data from the network.
TcpRosConnection:receive_header () Receive header.
TcpRosConnection:send (message) Send message.
TcpRosConnection:send_header (fields, header) Send out header.
TcpRosConnection:spin () Spin ros connection.
TcpRosConnection:wait_for_message () Wait for a message to arrive.
TcpRosPubSubConnection:new (socket) Publisher/Subscriber connection constructor.
TcpRosPubSubConnection:receive () Receive data from the network.
TcpRosPubSubConnection:receive_header () Receive header.
TcpRosServiceClientConnection:new (socket) Service client connection constructor.
TcpRosServiceClientConnection:receive () Receive data from the network.
TcpRosServiceProviderConnection:new (socket) Service provider connection constructor.
TcpRosServiceProviderConnection:receive () Receive data from the network.


Functions

TcpRosConnection:accept ()
Accept new connections.

Return value:

array of new connections, possibly empty
TcpRosConnection:bind ()
Bind to random port as server. This will transform the socket into a server socket allowing to accept connections. The socket will bind to a ephemeral port assigned by the operating system. It will set the timeout of the socket to zero to avoid locks on accepting new connections.

See also:

TcpRosConnection:close ()
Close connection.
TcpRosConnection:connect (host, port)
Connect to given host and port.

Parameters

  • host: hostname or IP address of remote side
  • port: port of remote side
TcpRosConnection:data_available ()
Check if data is available.

Return value:

true if data can be read, false otherwise
TcpRosConnection:data_received ()
Check if data has been received.

Return value:

true if data has been received, false otherwise. This method will return true only once if data has been received, consecutive calls will return false unless more data has been read with receive().
TcpRosConnection:get_ip_port ()
Get IP and port of socket.

Return value:

two values, IP and port of socket
TcpRosConnection:get_stats ()
Get connection statistics.

Return value:

six values: bytes received, bytes send, socket age in seconds, messages received, messages sent, total messages processed (sent + received)
TcpRosConnection:new (socket)
Constructor.

Parameters

  • socket: optionally a socket to use for communication
TcpRosConnection:receive ()
Receive data from the network. Upon return contains the new data in the payload field.
TcpRosConnection:receive_header ()
Receive header. This will read the header from the network connection and store it in the header field as well as return it.

Return value:

table of header fields
TcpRosConnection:send (message)
Send message.

Parameters

  • message: either a serialized message string or a Message class instance.
TcpRosConnection:send_header (fields, header)
Send out header.

Parameters

  • fields:
  • header: table with header fields to send
TcpRosConnection:spin ()
Spin ros connection. This will read messages from the wire when they become available. The field max_receives_per_spin is used to determine the maximum number of messages read per spin.
TcpRosConnection:wait_for_message ()
Wait for a message to arrive. This message blocks until a message has been received.
TcpRosPubSubConnection:new (socket)
Publisher/Subscriber connection constructor.

Parameters

  • socket: optionally a socket to use for communication
TcpRosPubSubConnection:receive ()
Receive data from the network. Upon return contains the new messages in the messages array field.
TcpRosPubSubConnection:receive_header ()
Receive header. This receives the header, asserts the type and loads the message specification into the msgspec field.

Return value:

table of headers
TcpRosServiceClientConnection:new (socket)
Service client connection constructor.

Parameters

  • socket: optionally a socket to use for communication
TcpRosServiceClientConnection:receive ()
Receive data from the network. Upon return contains the new message in the message field.
TcpRosServiceProviderConnection:new (socket)
Service provider connection constructor.

Parameters

  • socket: optionally a socket to use for communication
TcpRosServiceProviderConnection:receive ()
Receive data from the network. Upon return contains the new messages in the messages array field.

Valid XHTML 1.0!