ROS v0.1.0 ROS.Service.Proxy View Source
Service Proxies allow you to make requests to services.
All requests to services are blocking. Such is the nature of ROS Service calls. If you have a service running, you can use a service proxy like so:
iex> import ROS.Node.Spec
iex> alias ROS.Service.Proxy, as: SrvPrx
iex> children = [
...> node(:mynode, [
...> service_proxy(:myproxy, "/add_two_ints", "rospy_tutorials/AddTwoInts")
...> ]
...> ]
iex> Supervisor.start_link(children, strategy: :one_for_one)
iex> SrvPrx.request(:myproxy, %RospyTutorials.AddTwoInts.Request{a: 3, b: 4})
{:ok, %RospyTutorials.AddTwoInts.Response{sum: 7}}
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
Makes a request to a service
Makes a request to a service
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Makes a request to a service.
If the request is not successful, a ROS.Service.Error
is raised.
Examples
iex> alias ROS.Service.Proxy, as: SrvPrx
iex> SrvPrx.request!(:myproxy, %RospyTutorials.AddTwoInts.Request{a: 3, b: 4})
%RospyTutorials.AddTwoInts.Response{sum: 7}
iex> SrvPrx.request!(:ididntmakethisserviceproxy, %StdSrv.Empty{})
(** ROS.Service.Error) ...
Makes a request to a service.
Returns a tuple {:ok, %ServiceType.Response{}}
if the service call is
successful and a {:error, "reason"}
tuple if the service call fails.
Examples
iex> alias ROS.Service.Proxy, as: SrvPrx
iex> SrvPrx.request(:myproxy, %RospyTutorials.AddTwoInts.Request{a: 3, b: 4})
{:ok, %RospyTutorials.AddTwoInts.Response{sum: 7}}