Move test nodes to src/

This commit is contained in:
Christophe Bedard 2019-06-03 10:02:03 +02:00
parent 82ef066b16
commit 198fa8b039
3 changed files with 2 additions and 2 deletions

View file

@ -1,32 +0,0 @@
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
class PubNode : public rclcpp::Node
{
public:
PubNode(rclcpp::NodeOptions options) : Node("pub_node", options)
{
pub_ = this->create_publisher<std_msgs::msg::String>(
"the_topic",
rclcpp::QoS(10));
}
private:
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
};
int main(int argc, char* argv[])
{
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor exec;
auto pub_node = std::make_shared<PubNode>(rclcpp::NodeOptions());
exec.add_node(pub_node);
printf("spinning once\n");
exec.spin_once();
rclcpp::shutdown();
return 0;
}

View file

@ -1,41 +0,0 @@
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
class SubNode : public rclcpp::Node
{
public:
SubNode(rclcpp::NodeOptions options) : Node("sub_node", options)
{
sub_ = this->create_subscription<std_msgs::msg::String>(
"the_topic",
rclcpp::QoS(10),
std::bind(&SubNode::callback, this, std::placeholders::_1));
}
private:
void callback(const std_msgs::msg::String::SharedPtr msg)
{
// Nothing
(void)msg;
}
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
};
int main(int argc, char* argv[])
{
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor exec;
auto sub_node = std::make_shared<SubNode>(rclcpp::NodeOptions());
exec.add_node(sub_node);
printf("spinning once\n");
exec.spin_once();
rclcpp::shutdown();
return 0;
}