roslua: ROS client library for Lua

Module roslua.service_client

Service client. This module contains the ServiceClient class to access services provided by other ROS nodes. It is created using the function roslua.service_client().

The service client employs the __call() meta method, such that the service can be called just as service_client(...). As arguments you must pass the exact number of fields required for the request message in the exact order and of the proper type as they are defined in the service description file.

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

Release: Released under BSD license

Functions

ServiceClient:concexec_abort () Abort the execution.
ServiceClient:concexec_failed () Check if execution has failed.
ServiceClient:concexec_finished () Check if execution has failed or succeeded
ServiceClient:concexec_result () Get execution result.
ServiceClient:concexec_start (args) Initiate service execution.
ServiceClient:concexec_succeeded () Check if execution is finished successfully.
ServiceClient:concexec_wait () Wait for the execution to finish.
ServiceClient:connect () Connect to service provider.
ServiceClient:execute (args) Execute service.
ServiceClient:finalize () Finalize instance.
ServiceClient:new (args_or_service, srvtype) Constructor.


Functions

ServiceClient:concexec_abort ()
Abort the execution. Note that this does not actually stop the execution on the server side, rather we just close the connection as to not receive the result. The connection will be closed even if it is marked persistent. It will be reopened on the next call.
ServiceClient:concexec_failed ()
Check if execution has failed. Precondition is that the service is being concurrently executed.

Return value:

true if the execution is finished and a result has been received, false otherwise
ServiceClient:concexec_finished ()
Check if execution has failed or succeeded

Return value:

true if the execution is finished, false otherwise
ServiceClient:concexec_result ()
Get execution result. Precondition is that the service is being concurrently executed and has finished.

Return value:

service return value
ServiceClient:concexec_start (args)
Initiate service execution. This starts the execution of the service in a way it can be handled concurrently. The request will be sent, afterwards the concexec_finished(), concexec_result(), and concexec_wait() methods can be used.

Parameters

  • args: argument array
ServiceClient:concexec_succeeded ()
Check if execution is finished successfully. Precondition is that the service is being concurrently executed.

Return value:

true if the execution is finished and a result has been received, false otherwise
ServiceClient:concexec_wait ()
Wait for the execution to finish.
ServiceClient:connect ()
Connect to service provider.
ServiceClient:execute (args)
Execute service. This method is set as __call entry in the meta table. See the module documentation on the passed arguments. The method will return only after it has received a reply from the service provider!

Parameters

  • args: argument array
ServiceClient:finalize ()
Finalize instance.
ServiceClient:new (args_or_service, srvtype)
Constructor. The constructor can be called in two ways, either with positional or named arguments. The latter form allows to set additional parameters. In the positional form the ctor takes two arguments, the name and the type of the service. For named parameters the parameter names are service (for the name), type (service type) and persistent. If the latter is set to true the connection to the service provider ROS node will not be closed after one service call. This is beneficial when issuing many service calls in a row, but no guarantee is made that the connection is re-opened if it fails.

Examples:
Positional: ServiceClient:new("/myservice", "myservice/MyType") Named: ServiceClient:new{service="/myservice", type="myservice/MyType",persistent=true} (mind the curly braces instead of round brackets!)

Parameters

  • args_or_service: argument table or service name, see above
  • srvtype: service type, only used in positional case

Valid XHTML 1.0!