diff --git a/.gitignore b/.gitignore index 6101271..d44b693 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ log build install .vscode -.cache \ No newline at end of file +.cache +compile_commands.json \ No newline at end of file diff --git a/src/TODO_NODE_NAME.cpp b/src/TODO_NODE_NAME.cpp index d84a1b4..9ec0141 100644 --- a/src/TODO_NODE_NAME.cpp +++ b/src/TODO_NODE_NAME.cpp @@ -1,13 +1,16 @@ -#include - -#include "TODO_NODE_NAME/TODO_NODE_NAME_node.hpp" +#include "TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp" int main(int argc, char** argv) { + // Setup runtime rclcpp::init(argc, argv); rclcpp::executors::MultiThreadedExecutor exec; rclcpp::NodeOptions options; + + // Add nodes to executor auto node = std::make_shared(options); exec.add_node(node); + + // Run exec.spin(); rclcpp::shutdown(); return 0; diff --git a/src/TODO_NODE_NAME_node.cpp b/src/TODO_NODE_NAME_node.cpp index c05aeba..3f7bc6e 100644 --- a/src/TODO_NODE_NAME_node.cpp +++ b/src/TODO_NODE_NAME_node.cpp @@ -1,12 +1,16 @@ #include "TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp" +// For _1 +using namespace std::placeholders; + TODO_NODE_NAME::TODO_NODE_NAME(const rclcpp::NodeOptions& options) : Node("TODO_NODE_NAME", options) { // Parameters float x = this->declare_parameter("foo", -10.0); // Pub Sub - this->sub = this->create_subscription("/str", std::bind(&TODO_NODE_NAME::sub_cb, this, _1)); - this->path_pub = this->create_publisher("/run_folder"); + this->sub = + this->create_subscription("/str", 1, std::bind(&TODO_NODE_NAME::sub_cb, this, _1)); + this->pub = this->create_publisher("/run_folder", 1); // Log a sample log RCLCPP_INFO(this->get_logger(), "You passed %f", x); @@ -14,10 +18,10 @@ TODO_NODE_NAME::TODO_NODE_NAME(const rclcpp::NodeOptions& options) : Node("TODO_ // Send a sample message std_msgs::msg::String msg{}; msg.data = std::string{"Hello World!"}; - path_pub->publish(msg); + pub->publish(msg); } void TODO_NODE_NAME::sub_cb(const std_msgs::msg::String::SharedPtr msg) { // Echo message - this->pub.publish(msg); + this->pub->publish(*msg); }