ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

ROS2: What is the purpose of a guard condition?

asked 2021-10-27 02:10:43 -0500

Per Edwardsson gravatar image

I was browsing the rclpy repository the other day and found this example which implements something called a guard condition. What is the use case for something like this? Is this a single use branching statement? Is it a multi threading thing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-11 05:12:14 -0500

Deric gravatar image

updated 2023-03-15 09:34:20 -0500

The low level rcl functionality seems to be interrupting threads waiting on wait sets by allowing the guard condition to become ready when being triggered by another thread. The rclpy implementation seems to add a callback to be executed by the executor in this case.

I have seen guard conditions being used for implementing executors which can be interrupted while waiting for work to become ready, but not much else (maybe someone more experienced knows more use cases?).

I dont exactly know if triggering the guard condition works only if it is currently waited on or if the state is being stored and reset somehow.

Update: After some tests and looking at the rcl guard condition tests it seems that a guard condition remains triggered until it is waited on.

edit flag offensive delete link more

Question Tools

5 followers

Stats

Asked: 2021-10-27 02:10:43 -0500

Seen: 1,085 times

Last updated: Mar 15 '23