Class Talker

Inheritance Relationships

Base Type

  • public rclcpp::Node

Class Documentation

class Talker : public rclcpp::Node

Node class to publish data at a specified rate, optionally pausing to test liveliness.

Public Functions

explicit Talker(const rclcpp::QoS &qos_profile, const std::string &topic_name = DEFAULT_TOPIC_NAME, size_t publish_count = 0, std::chrono::milliseconds publish_period = std::chrono::milliseconds(500), std::chrono::milliseconds assert_topic_period = std::chrono::milliseconds(0))

Standard Constructor.

Parameters:
  • qos_profile[in] QoS profile for Publisher.

  • topic_name[in] Topic to publish to.

  • publish_count[in] (Optional) Number of messages to publish before stopping. 0 (default) means publish forever.

  • publish_period[in] (Optional) How often to publish

  • assert_topic_period[in] (Optional) How often to manually assert Publisher liveliness. 0 (default) means never.

void initialize()

Initialize the publisher.

void publish()

Publish a single message.

Counts towards the total message count that will be published.

size_t get_published_count() const

Get the number of messages that have been published by this publisher.

bool assert_publisher_liveliness() const

Assert the liveliness of the publisher.

void toggle_publish()

Start/Stop publishing for a while.

void pause_publish_for(std::chrono::milliseconds pause_duration)

Stop publishing for a while.

Stops the publisher for the specified amount of time. A message will be published immediately on the expiration of pause_duration. The regular publishing interval will resume at that point. If publishing is already paused, this call will be ignored. The remaining pause duration will not be affected.

Parameters:

pause_duration[in] Amount of time to pause for.

void stop_publish_and_assert_liveliness()

Cancel publishing, and any manual liveliness assertions this node was configured to do.

inline rclcpp::PublisherOptions &get_options()

Get the publisher’s settings options.

void print_qos() const

Print the QoS settings of the publisher.