Skip to content

Commit

Permalink
Split lambda and subscriber def in minimal example
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Gomes de Melo <felipegmelo.42@gmail.com>
  • Loading branch information
FelipeGdM committed May 29, 2023
1 parent 66c7121 commit 6cda17d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rclcpp/topics/minimal_subscriber/lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class MinimalSubscriber : public rclcpp::Node
MinimalSubscriber()
: Node("minimal_subscriber")
{
subscription_ = this->create_subscription<std_msgs::msg::String>(
"topic",
10,
[this](std_msgs::msg::String::UniquePtr msg) {
auto topic_callback =
[this](std_msgs::msg::String::UniquePtr msg) -> void {
RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str());
});
};
subscription_ =
this->create_subscription<std_msgs::msg::String>("topic", 10, topic_callback);
}

private:
Expand Down

0 comments on commit 6cda17d

Please sign in to comment.