Class CallbackQueue
Callback queue to handle the callbacks within ROS
Metamethods
CallbackQueue:__init ([enabled=true]) | Constructor |
Methods
CallbackQueue:cdata () | Get the underlying c++ instance |
CallbackQueue:registerSpinCallback (fn[, Prioriy=1]) | Register a function for callback |
CallbackQueue:unregisterSpinCallback (fn[, round=1]) | Remove a function from the callback list |
CallbackQueue:callSpinCallbacks () | Trigger all callbacks one time |
CallbackQueue:callOne (timeout) | Pop a single callback off the front of the queue and invoke it. |
CallbackQueue:callAvailable (timeout, no_spin_callbacks) | Invoke all callbacks currently in the queue. |
CallbackQueue:waitCallAvailable (timeout) | Waits until the next callback is enqueued or the timeout is expired |
CallbackQueue:isEmpty () | Returns whether or not the queue is empty |
CallbackQueue:clear () | Removes all callbacks from the queue. |
CallbackQueue:enable () | Enable the queue |
CallbackQueue:disable () | Disable the queue, meaning any calls to addCallback() will have no effect. |
CallbackQueue:isEnabled () | Returns whether or not this queue is enabled. |
Metamethods
- CallbackQueue:__init ([enabled=true])
-
Constructor
Parameters:
- enabled bool indicating if the queue is enabled or disabled after construction (default true)
Methods
- CallbackQueue:cdata ()
-
Get the underlying c++ instance
Returns:
-
pointer to the c++ instance
- CallbackQueue:registerSpinCallback (fn[, Prioriy=1])
-
Register a function for callback
Parameters:
- fn func The function to execute as callback function
- Prioriy int /order of the callback. If unsure which value to use, omit the parameter (default 1)
- CallbackQueue:unregisterSpinCallback (fn[, round=1])
-
Remove a function from the callback list
Parameters:
- fn func The function to be removed
- round int ; Prioriy/order of the when added. Has to be the same value as used for registerSpinCallback() (default 1)
- CallbackQueue:callSpinCallbacks ()
- Trigger all callbacks one time
- CallbackQueue:callOne (timeout)
-
Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be called, pushes it back onto the queue.
Parameters:
- timeout number or ros:Duration Timeout for the callback, either in seconds (fractional numbers like 1.5 possible) or as an instance of ros:Duration
- CallbackQueue:callAvailable (timeout, no_spin_callbacks)
-
Invoke all callbacks currently in the queue.
If a callback was not ready to be called, pushes it back onto the queue.
Parameters:
- timeout number or ros:Duration Timeout for the callback, either in seconds (fractional numbers like 1.5 possible) or as an instance of ros:Duration
- no_spin_callbacks bool
- CallbackQueue:waitCallAvailable (timeout)
-
Waits until the next callback is enqueued or the timeout is expired
Parameters:
- timeout number or ros:Duration Timeout for the callback, either in seconds (fractional numbers like 1.5 possible) or as an instance of ros:Duration
Returns:
-
bool
true if a callback is enqueued, false if the queue is disabled or the timeout expired
- CallbackQueue:isEmpty ()
-
Returns whether or not the queue is empty
Returns:
-
bool
true if queue is empty, false otherwise
- CallbackQueue:clear ()
- Removes all callbacks from the queue. Does not wait for calls currently in progress to finish.
- CallbackQueue:enable ()
- Enable the queue
- CallbackQueue:disable ()
- Disable the queue, meaning any calls to addCallback() will have no effect.
- CallbackQueue:isEnabled ()
-
Returns whether or not this queue is enabled.
Returns:
-
bool
true if the queue is empty