RclexTesting.DSL.Graph (RclexTesting (Experimental) v0.12.4)

Copy Markdown View Source

Assert the live ROS graph topology visible from the scenario node.

Verify nodes, topics, publishers, subscribers, services, actions, and their providers with the expect_* and refute_* assertions. Use the eventually_* helpers when entities may appear asynchronously.

Summary

Functions

Wait (event-driven) until an action server for action_name appears.

Wait (event-driven) until a node named name appears in the ROS graph.

Wait (event-driven) until service_name appears in the ROS graph.

Wait (event-driven) until topic_name appears in the ROS graph.

Assert that an action server for action_name exists in the ROS graph.

Assert that node_name provides action_name.

Assert that a node named name (in namespace, default /) exists.

Assert that node_name provides all actions in action_list.

Assert that node_name publishes on all topics in topic_list.

Assert that node_name provides all services in service_list.

Assert that node_name subscribes to all topics in topic_list.

Assert that at least one publisher exists on topic_name.

Assert exactly expected publishers on topic_name.

Assert that node node_name publishes on topic_name.

Assert that service_name exists in the ROS graph.

Assert that at least one subscriber exists on topic_name.

Assert exactly expected subscribers on topic_name.

Assert that node node_name subscribes to topic_name.

Assert that topic_name exists in the ROS graph.

Assert that no action server for action_name exists in the ROS graph.

Assert that no node named name (in namespace, default /) exists.

Assert that service_name does not exist in the ROS graph.

Assert that topic_name does not exist in the ROS graph.

Return the name of the scenario's own ROS node.

Functions

eventually_action(action_name, opts \\ [])

@spec eventually_action(
  String.t(),
  keyword()
) :: :ok

Wait (event-driven) until an action server for action_name appears.

eventually_action "/navigate"

eventually_node(name, opts_or_ns \\ "/")

@spec eventually_node(String.t(), keyword() | String.t()) :: :ok

Wait (event-driven) until a node named name appears in the ROS graph.

Uses Rclex.GraphMonitor.on_entity/3 — no polling sleep. If the node is already present the function returns immediately.

eventually_node "navigation"
eventually_node "navigation", timeout: 10_000
eventually_node "navigation", "/"

eventually_node(name, namespace, opts)

@spec eventually_node(String.t(), String.t(), keyword()) :: :ok

eventually_service(service_name, opts \\ [])

@spec eventually_service(
  String.t(),
  keyword()
) :: :ok

Wait (event-driven) until service_name appears in the ROS graph.

eventually_service "/safety/check"

eventually_topic(topic_name, opts \\ [])

@spec eventually_topic(
  String.t(),
  keyword()
) :: :ok

Wait (event-driven) until topic_name appears in the ROS graph.

eventually_topic "/robot/state"
eventually_topic "/robot/state", timeout: 10_000

expect_action(action_name)

@spec expect_action(String.t()) :: :ok

Assert that an action server for action_name exists in the ROS graph.

expect_action "/navigate"

expect_action_provider(node_name, action_name, node_namespace \\ "/")

@spec expect_action_provider(String.t(), String.t(), String.t()) :: :ok

Assert that node_name provides action_name.

expect_action_provider "navigation", "/navigate"

expect_node(name, namespace \\ "/")

@spec expect_node(String.t(), String.t()) :: :ok

Assert that a node named name (in namespace, default /) exists.

Uses the GraphMonitor's live snapshot. For nodes that may not have appeared yet, use eventually_node/1,2.

expect_node "navigation"

expect_node_actions(node_name, action_list, node_namespace \\ "/")

@spec expect_node_actions(String.t(), [String.t()], String.t()) :: :ok

Assert that node_name provides all actions in action_list.

expect_node_actions "navigation", ["/navigate"]

expect_node_publishes(node_name, topic_list, node_namespace \\ "/")

@spec expect_node_publishes(String.t(), [String.t()], String.t()) :: :ok

Assert that node_name publishes on all topics in topic_list.

expect_node_publishes "navigation", ["/robot/state", "/path"]

expect_node_services(node_name, service_list, node_namespace \\ "/")

@spec expect_node_services(String.t(), [String.t()], String.t()) :: :ok

Assert that node_name provides all services in service_list.

expect_node_services "safety_manager", ["/safety/check"]

expect_node_subscribes(node_name, topic_list, node_namespace \\ "/")

@spec expect_node_subscribes(String.t(), [String.t()], String.t()) :: :ok

Assert that node_name subscribes to all topics in topic_list.

expect_node_subscribes "navigation", ["/goal", "/estop"]

expect_publisher(topic_name)

@spec expect_publisher(String.t()) :: :ok

Assert that at least one publisher exists on topic_name.

expect_publisher "/robot/state"

expect_publisher_count(topic_name, expected)

@spec expect_publisher_count(String.t(), non_neg_integer()) :: :ok

Assert exactly expected publishers on topic_name.

expect_publisher_count "/robot/state", 1

expect_publisher_node(node_name, topic_name)

@spec expect_publisher_node(String.t(), String.t()) :: :ok

Assert that node node_name publishes on topic_name.

expect_publisher_node "navigation", "/robot/state"

expect_service(service_name)

@spec expect_service(String.t()) :: :ok

Assert that service_name exists in the ROS graph.

expect_service "/safety/check"

expect_service_provider(node_name, service_name, node_namespace \\ "/")

@spec expect_service_provider(String.t(), String.t(), String.t()) :: :ok

Assert that node_name provides service_name.

expect_service_provider "safety_manager", "/safety/check"

expect_subscriber(topic_name)

@spec expect_subscriber(String.t()) :: :ok

Assert that at least one subscriber exists on topic_name.

expect_subscriber "/cmd_vel"

expect_subscriber_count(topic_name, expected)

@spec expect_subscriber_count(String.t(), non_neg_integer()) :: :ok

Assert exactly expected subscribers on topic_name.

expect_subscriber_count "/cmd_vel", 2

expect_subscriber_node(node_name, topic_name)

@spec expect_subscriber_node(String.t(), String.t()) :: :ok

Assert that node node_name subscribes to topic_name.

expect_subscriber_node "controller", "/cmd_vel"

expect_topic(topic_name)

@spec expect_topic(String.t()) :: :ok

Assert that topic_name exists in the ROS graph.

expect_topic "/robot/state"

refute_action(action_name)

@spec refute_action(String.t()) :: :ok

Assert that no action server for action_name exists in the ROS graph.

refute_action "/debug_action"

refute_node(name, namespace \\ "/")

@spec refute_node(String.t(), String.t()) :: :ok

Assert that no node named name (in namespace, default /) exists.

refute_node "debug_node"

refute_service(service_name)

@spec refute_service(String.t()) :: :ok

Assert that service_name does not exist in the ROS graph.

refute_service "/debug/reset"

refute_topic(topic_name)

@spec refute_topic(String.t()) :: :ok

Assert that topic_name does not exist in the ROS graph.

refute_topic "/debug/state"

scenario_node_name()

@spec scenario_node_name() :: String.t()

Return the name of the scenario's own ROS node.

node = scenario_node_name()
expect_node node