-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Labels
Description
The Problem
Currently, to watch parameters on a remote node, you have to:
- Subscribe to
/parameter_eventstopic - Filter events by node name manually
- Filter by parameter names manually
- Handle all the event filtering logic
Solution
Implemented ParameterWatcher - an event-driven class that automatically monitors parameter changes on remote nodes.
// Create watcher for specific parameters
const watcher = node.createParameterWatcher('turtlesim', [
'background_r',
'background_g'
]);
// Listen for changes
watcher.on('change', (params) => {
params.forEach(p => console.log(`${p.name} changed to ${p.value}`));
});
await watcher.start();
// Dynamically add/remove parameters
watcher.addParameter('background_b');
watcher.removeParameter('background_g');
// Get current values anytime
const current = await watcher.getCurrentValues();