Assertions
roboticks.assertions ships five rclpy-aware assertion helpers. Each one spins a node briefly, evaluates a predicate, and raises AssertionError (or TimeoutError) with an informative message on failure.
assert_topic_published
Wait until a message matching the predicate is published on topic.
Signature
Raises
TimeoutError— no matching message inwithinseconds.RuntimeError— rclpy not initialised, topic type mismatch.
Returns
The first message matching the predicate, as a deserialised Python object ofmsg_type.
Example
assert_service_response
Send a request, wait for the response.
Signature
Raises
TimeoutError— service unavailable or response not received inwithinseconds.RuntimeError— rclpy not initialised, service type mismatch.
Returns
The deserialised response object.Example
assert_action_result
Send a goal, wait for the terminal result (success or failure).
Signature
Raises
TimeoutError— no terminal result inwithinseconds.AssertionError— goal rejected by action server.RuntimeError— rclpy not initialised.
Returns
The completedClientGoalHandle. Access .result() for the action-specific result.
Example
assert_param_equals
Read a parameter from a node and assert its value.
Signature
Raises
TimeoutError— parameter service unavailable.AssertionError— parameter value doesn’t matchexpected.RuntimeError— node doesn’t exist, parameter not declared.
Example
assert_tf_transform
Wait until a TF transform from source_frame to target_frame is available, then assert on its components.
Signature
Raises
TimeoutError— TF transform not available.AssertionError— translation/rotation deviates beyondtol.
Returns
Thegeometry_msgs/msg/TransformStamped object.
Example
Shared semantics
Next
Fault injection
Pair assertions with fault injection for negative tests.
Writing tests in pytest
Worked examples that put these helpers in context.
MCAP capture
Record bag files when assertions fail.
Launch testing
System-test patterns that use these helpers across processes.