Publishing Messages

publish(topicName, message, options)

Publish a message to a ROS topic.

Parameters:

  • topicName (string) - Topic name to publish to
  • message (object) - Message data
  • options (object, optional) - Publishing options
    • messageType (string) - Message type (skips topic lookup if provided, auto-detected otherwise)

Returns: Promise - Resolves when message is published

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 publishing. You can also manually provide the messageType option to skip the topic lookup entirely.

JS
// Publish a string message await oloClient.core.publish('/test_topic', { data: 'Hello Robot!' }); // Publish with explicit message type await oloClient.core.publish('/custom_topic', { x: 1, y: 2 }, { messageType: 'geometry_msgs/Point' });