Skip to content

Commit

Permalink
Make it actually compile
Browse files Browse the repository at this point in the history
  • Loading branch information
andyblarblar committed Oct 1, 2023
1 parent ba6cbbe commit 32053b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ log
build
install
.vscode
.cache
.cache
compile_commands.json
9 changes: 6 additions & 3 deletions src/TODO_NODE_NAME.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <cstdio>

#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<TODO_NODE_NAME>(options);
exec.add_node(node);

// Run
exec.spin();
rclcpp::shutdown();
return 0;
Expand Down
12 changes: 8 additions & 4 deletions src/TODO_NODE_NAME_node.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#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<float>("foo", -10.0);

// Pub Sub
this->sub = this->create_subscription<std_msgs::msg::String>("/str", std::bind(&TODO_NODE_NAME::sub_cb, this, _1));
this->path_pub = this->create_publisher<std_msgs::msg::String>("/run_folder");
this->sub =
this->create_subscription<std_msgs::msg::String>("/str", 1, std::bind(&TODO_NODE_NAME::sub_cb, this, _1));
this->pub = this->create_publisher<std_msgs::msg::String>("/run_folder", 1);

// Log a sample log
RCLCPP_INFO(this->get_logger(), "You passed %f", x);

// 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);
}

0 comments on commit 32053b8

Please sign in to comment.