- Source:
Example
async function run() {
await rclnodejs.init();
const node = rclnodejs.createNode('mynode');
const rate = node.createRate(1); // 1 hz
while (true) {
doSomeStuff();
await rate.sleep();
rclnodejs.spinOnce(node);
}
}
Members
member
frequency
Get the frequency in hertz (hz) of this timer.
- Source:
Methods
function
cancel() → {undefined}
Permanently stops the timing behavior.
- Source:
Returns:
Type
undefined
function
isCanceled() → {boolean}
Determine if this rate has been cancelled.
- Source:
Returns:
- True when cancel() has been called; False otherwise.
Type
boolean
function
(async) sleep() → {Promise}
Returns a Promise that when waited on, will block the sender
until the end of the current timer cycle.
If the Rate has been cancelled, calling this method will
result in an error.
- Source:
Returns:
- Waiting on the promise will delay the sender
(not the Node event-loop) until the end of the current timer cycle.
Type
Promise
Example
(async () => {
await rate.sleep();
})();