Topic Management
listTopics(refresh = false)
Get list of available ROS topics.
Parameters:
refresh(boolean) - Force refresh from server
Returns: Promise<Array> - Array of topic objects with name, type, and throttling info
JS
const topics = await oloClient.core.listTopics();
// Returns: [{ name: '/cmd_vel', type: 'geometry_msgs/Twist', throttling: null }, ...]getTopicInfo(topicName)
Get information about a specific topic.
Parameters:
topicName(string) - Topic name
Returns: Object|null - Topic information or null if not found
subscribe(topicName, callback, options)
Subscribe to a ROS topic.
Parameters:
topicName(string) - Topic name to subscribe tocallback(function) - Callback function for received messagesoptions(object, optional) - Subscription optionsmessageType(string) - Override message type (skips topic lookup if provided)throttleRate(number) - Throttle rate in millisecondsqueueLength(number) - Queue length
Returns: Promise<string> - Subscription ID (topic name)
Note: If messageType is not provided, the function will automatically look up the topic type. If the topics cache is empty (e.g., after a reconnection), the function will automatically fetch topics before subscribing. You can also manually provide the messageType option to skip the topic lookup entirely.
JS
await oloClient.core.subscribe('/sensor_data', (message) => {
console.log('Received:', message);
}, {
throttleRate: 100, // Limit to 10 messages per second
queueLength: 1 // Only keep latest message
});unsubscribe(topicName)
Unsubscribe from a topic.
Parameters:
topicName(string) - Topic name to unsubscribe from
unsubscribeAll()
Unsubscribe from all topics.
