View Source Rclex (Rclex v0.11.2)

User API for Elixir.Rclex.

Summary

Types

topic_name must lead with "/".

Types

@type topic_name() :: String.t()

topic_name must lead with "/".

Functions

Link to this function

publish(message, topic_name, node_name, opts \\ [])

View Source
@spec publish(
  message :: struct(),
  topic_name :: topic_name(),
  node_name :: String.t(),
  opts :: [{:namespace, String.t()}]
) :: :ok | {:error, :not_found}

Publish message.

  • topic_name must lead with "/"

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> alias Rclex.Pkgs.StdMsgs
iex> Rclex.publish(struct(StdMsgs.Msg.String, %{data: "hello"}), "/chatter", "node", namespace: "/example")
:ok
iex> Rclex.publish(struct(StdMsgs.Msg.String, %{data: "hello"}), "/chatter", "node")
{:error, :not_found}
Link to this function

start_node(name, opts \\ [])

View Source
@spec start_node(name :: String.t(), opts :: [{:namespace, String.t()}]) ::
  :ok | {:error, :already_started} | {:error, term()}

Start node.

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> Rclex.start_node("node", namespace: "/example")
:ok
iex> Rclex.start_node("node", namespace: "/example")
{:error, :already_started}
Link to this function

start_publisher(message_type, topic_name, node_name, opts \\ [])

View Source
@spec start_publisher(
  message_type :: module(),
  topic_name :: topic_name(),
  node_name :: String.t(),
  opts :: [namespace: String.t(), qos: Rclex.QoS.t()]
) :: :ok | {:error, :already_started} | {:error, term()}

Start publisher.

  • topic_name must lead with "/"

Examples

iex> alias Rclex.Pkgs.StdMsgs
iex> Rclex.start_publisher(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
:ok
iex> Rclex.start_publisher(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
{:error, :already_started}
Link to this function

start_subscription(callback, message_type, topic_name, node_name, opts \\ [])

View Source
@spec start_subscription(
  callback :: function(),
  message_type :: module(),
  topic_name :: topic_name(),
  node_name :: String.t(),
  opts :: [namespace: String.t(), qos: Rclex.QoS.t()]
) :: :ok | {:error, :already_started} | {:error, term()}

Start subscription.

  • topic_name must lead with "/"

opts

  • :namespace must lead with "/". if not specified, the default is "/"
  • :qos if not specified, applied the default which equals return of Rclex.QoS.profile_default/0

Examples

iex> alias Rclex.Pkgs.StdMsgs
iex> Rclex.start_subscription(&IO.inspect/1, StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
:ok
iex> Rclex.start_subscription(&IO.inspect/1, StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
{:error, :already_started}
Link to this function

start_timer(period_ms, callback, timer_name, node_name, opts \\ [])

View Source
@spec start_timer(
  period_ms :: non_neg_integer(),
  callback :: function(),
  timer_name :: String.t(),
  node_name :: String.t(),
  opts :: [{:namespace, String.t()}]
) :: :ok | {:error, :already_started} | {:error, term()}

Start timer.

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> Rclex.start_timer(1000, fn -> IO.inspect("tick") end, "tick", "node", namespace: "/example")
:ok
iex> Rclex.start_timer(1000, fn -> IO.inspect("tick") end, "tick", "node", namespace: "/example")
{:error, :already_started}
Link to this function

stop_node(name, opts \\ [])

View Source
@spec stop_node(name :: String.t(), opts :: [{:namespace, String.t()}]) ::
  :ok | {:error, :not_found}

Stop node. And also stop the entities on the node, publisher, subscription and timer.

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> Rclex.stop_node("node", namespace: "/example")
:ok
iex> Rclex.stop_node("node", namespace: "/example")
{:error, :not_found}
Link to this function

stop_publisher(message_type, topic_name, name, opts \\ [])

View Source
@spec stop_publisher(
  message_type :: module(),
  topic_name :: topic_name(),
  node_name :: String.t(),
  opts :: [{:namespace, String.t()}]
) :: :ok | {:error, :not_found}

Stop publisher.

  • topic_name must lead with "/"

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> alias Rclex.Pkgs.StdMsgs
iex> Rclex.stop_publisher(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
:ok
iex> Rclex.stop_publisher(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
{:error, :not_found}
Link to this function

stop_subscription(message_type, topic_name, node_name, opts \\ [])

View Source
@spec stop_subscription(
  message_type :: module(),
  topic_name :: topic_name(),
  node_name :: String.t(),
  opts :: [{:namespace, String.t()}]
) :: :ok | {:error, :not_found}

Stop subscription.

  • topic_name must lead with "/"

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> alias Rclex.Pkgs.StdMsgs
iex> Rclex.stop_subscription(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
:ok
iex> Rclex.stop_subscription(StdMsgs.Msg.String, "/chatter", "node", namespace: "/example")
{:error, :not_found}
Link to this function

stop_timer(timer_name, node_name, opts \\ [])

View Source
@spec stop_timer(
  timer_name :: String.t(),
  node_name :: String.t(),
  opts :: [{:namespace, String.t()}]
) :: :ok | {:error, :not_found}

Stop timer.

opts

  • :namespace must lead with "/". if not specified, the default is "/"

Examples

iex> Rclex.stop_timer("tick", "node", namespace: "/example")
:ok
iex> Rclex.stop_timer("tick", "node", namespace: "/example")
{:error, :not_found}