forked from nachovizzo/cyclone_dds_leak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaky_node.cpp
35 lines (29 loc) · 926 Bytes
/
leaky_node.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cstdio>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
//
#include <rclcpp/executors/single_threaded_executor.hpp>
#include <rclcpp/node.hpp>
class LeakyNode : public rclcpp::Node {
public:
explicit LeakyNode(const std::string &name) : Node(name) {
this->declare_parameter("my_parameter", "world");
}
};
int main(int argc, char **argv) {
rclcpp::init(argc, argv);
const size_t N_NODES = 10;
std::vector<std::shared_ptr<LeakyNode>> nodes;
std::cerr << "Creating " << N_NODES << " nodes" << std::endl;
for (int i = 0; i < N_NODES; ++i) {
nodes.push_back(std::make_shared<LeakyNode>(("leaky_node" + std::to_string(i))));
}
std::cerr << "Adding to executor now" << std::endl;
rclcpp::executors::SingleThreadedExecutor exec;
for (auto &node : nodes) exec.add_node(node);
exec.spin();
rclcpp::shutdown();
return 0;
}