Hello @mbzuaimbzirc ,
one way to stop your publisher from publishing is by using a boolean flag. You can evaluate if your boolean variable is True
or False
and based on that you publish a message or not. This can be done for instance inside your timer_callback
function before executing the publish()
method.
You are also asking how to publish just one message but I think this is already answered in the previous question that you posted: How to publish a msg one time using ros2 in python - #2 by rzegers
Cheers,
Roberto