Skip to content

Commit 780ab41

Browse files
authored
Split lambda and subscriber def in minimal example (#363)
Signed-off-by: Felipe Gomes de Melo <[email protected]>
1 parent 66c7121 commit 780ab41

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

rclcpp/topics/minimal_subscriber/lambda.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class MinimalSubscriber : public rclcpp::Node
2323
MinimalSubscriber()
2424
: Node("minimal_subscriber")
2525
{
26-
subscription_ = this->create_subscription<std_msgs::msg::String>(
27-
"topic",
28-
10,
29-
[this](std_msgs::msg::String::UniquePtr msg) {
26+
auto topic_callback =
27+
[this](std_msgs::msg::String::UniquePtr msg) -> void {
3028
RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str());
31-
});
29+
};
30+
subscription_ =
31+
this->create_subscription<std_msgs::msg::String>("topic", 10, topic_callback);
3232
}
3333

3434
private:

0 commit comments

Comments
 (0)