Last active
June 5, 2017 22:08
-
-
Save youtalk/6b9110647785f309a49aba5ff8a15197 to your computer and use it in GitHub Desktop.
two_node_pipeline.cpp 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// メッセージをSubscribeするSubscriberクラス | |
struct Consumer : public rclcpp::Node | |
{ | |
Consumer(const std::string & name, const std::string & input) | |
: Node(name, "", true) | |
{ | |
// input名のトピックをSubscribeするSubscriberを作成 | |
sub_ = this->create_subscription<std_msgs::msg::Int32>( | |
input, [](std_msgs::msg::Int32::UniquePtr msg) { // std::unique_ptr<std_msgs::msg::Int32>の別名 | |
printf( | |
" Received message with value: %d, and address: 0x%" PRIXPTR "\n", msg->data, | |
reinterpret_cast<std::uintptr_t>(msg.get())); // メッセージのポインタ・アドレスを整数表示 | |
}, rmw_qos_profile_default); | |
} | |
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr sub_; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment