1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ from typing import Union
16+
1517from rclpy .impl .implementation_singleton import rclpy_implementation as _rclpy
1618from rclpy .node import Node
19+ from rclpy .qos import QoSProfile
1720from rclpy .signals import SignalHandlerGuardCondition
1821from rclpy .utilities import timeout_sec_to_nsec
1922
@@ -22,6 +25,8 @@ def wait_for_message(
2225 msg_type ,
2326 node : 'Node' ,
2427 topic : str ,
28+ * ,
29+ qos_profile : Union [QoSProfile , int ] = 1 ,
2530 time_to_wait = - 1
2631):
2732 """
@@ -30,6 +35,7 @@ def wait_for_message(
3035 :param msg_type: message type
3136 :param node: node to initialize the subscription on
3237 :param topic: topic name to wait for message
38+ :param qos_profile: QoS profile to use for the subscription
3339 :param time_to_wait: seconds to wait before returning
3440 :returns: (True, msg) if a message was successfully received, (False, None) if message
3541 could not be obtained or shutdown was triggered asynchronously on the context.
@@ -38,7 +44,7 @@ def wait_for_message(
3844 wait_set = _rclpy .WaitSet (1 , 1 , 0 , 0 , 0 , 0 , context .handle )
3945 wait_set .clear_entities ()
4046
41- sub = node .create_subscription (msg_type , topic , lambda _ : None , 1 )
47+ sub = node .create_subscription (msg_type , topic , lambda _ : None , qos_profile = qos_profile )
4248 try :
4349 wait_set .add_subscription (sub .handle )
4450 sigint_gc = SignalHandlerGuardCondition (context = context )
0 commit comments