Fix linting errors
This commit is contained in:
parent
6cce113f04
commit
33f227b772
27 changed files with 668 additions and 563 deletions
|
@ -5,8 +5,8 @@
|
|||
<version>0.0.1</version>
|
||||
<description>Separate test package for tracetools</description>
|
||||
<maintainer email="fixed-term.christophe.bourquebedard@de.bosch.com">Christophe Bedard</maintainer>
|
||||
<author email="fixed-term.christophe.bourquebedard@de.bosch.com">Christophe Bedard</author>
|
||||
<license>APLv2</license>
|
||||
<author email="fixed-term.christophe.bourquebedard@de.bosch.com">Christophe Bedard</author>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<buildtool_depend>pkg-config</buildtool_depend>
|
||||
|
|
|
@ -6,56 +6,55 @@
|
|||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
class PingNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
PingNode(rclcpp::NodeOptions options) : Node("ping_node", options)
|
||||
{
|
||||
sub_ = this->create_subscription<std_msgs::msg::String>(
|
||||
"pong",
|
||||
rclcpp::QoS(10),
|
||||
std::bind(&PingNode::callback, this, std::placeholders::_1));
|
||||
pub_ = this->create_publisher<std_msgs::msg::String>(
|
||||
"ping",
|
||||
rclcpp::QoS(10));
|
||||
timer_ = this->create_wall_timer(
|
||||
500ms,
|
||||
std::bind(&PingNode::timer_callback, this));
|
||||
}
|
||||
|
||||
explicit PingNode(rclcpp::NodeOptions options)
|
||||
: Node("ping_node", options)
|
||||
{
|
||||
sub_ = this->create_subscription<std_msgs::msg::String>(
|
||||
"pong",
|
||||
rclcpp::QoS(10),
|
||||
std::bind(&PingNode::callback, this, std::placeholders::_1));
|
||||
pub_ = this->create_publisher<std_msgs::msg::String>(
|
||||
"ping",
|
||||
rclcpp::QoS(10));
|
||||
timer_ = this->create_wall_timer(
|
||||
500ms,
|
||||
std::bind(&PingNode::timer_callback, this));
|
||||
}
|
||||
|
||||
private:
|
||||
void callback(const std_msgs::msg::String::SharedPtr msg)
|
||||
{
|
||||
RCLCPP_INFO(this->get_logger(), "[output] %s", msg->data.c_str());
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
void callback(const std_msgs::msg::String::SharedPtr msg)
|
||||
{
|
||||
RCLCPP_INFO(this->get_logger(), "[output] %s", msg->data.c_str());
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
|
||||
void timer_callback()
|
||||
{
|
||||
auto msg = std::make_shared<std_msgs::msg::String>();
|
||||
msg->data = "some random ping string";
|
||||
pub_->publish(*msg);
|
||||
}
|
||||
void timer_callback()
|
||||
{
|
||||
auto msg = std::make_shared<std_msgs::msg::String>();
|
||||
msg->data = "some random ping string";
|
||||
pub_->publish(*msg);
|
||||
}
|
||||
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto ping_node = std::make_shared<PingNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(ping_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto ping_node = std::make_shared<PingNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(ping_node);
|
||||
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
|
||||
// Will actually be called inside the node's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
// Will actually be called inside the node's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,47 +3,47 @@
|
|||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "std_msgs/msg/string.hpp"
|
||||
|
||||
|
||||
class PongNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
PongNode(rclcpp::NodeOptions options) : Node("pong_node", options)
|
||||
{
|
||||
sub_ = this->create_subscription<std_msgs::msg::String>(
|
||||
"ping",
|
||||
rclcpp::QoS(10),
|
||||
std::bind(&PongNode::callback, this, std::placeholders::_1));
|
||||
pub_ = this->create_publisher<std_msgs::msg::String>(
|
||||
"pong",
|
||||
rclcpp::QoS(10));
|
||||
}
|
||||
explicit PongNode(rclcpp::NodeOptions options)
|
||||
: Node("pong_node", options)
|
||||
{
|
||||
sub_ = this->create_subscription<std_msgs::msg::String>(
|
||||
"ping",
|
||||
rclcpp::QoS(10),
|
||||
std::bind(&PongNode::callback, this, std::placeholders::_1));
|
||||
pub_ = this->create_publisher<std_msgs::msg::String>(
|
||||
"pong",
|
||||
rclcpp::QoS(10));
|
||||
}
|
||||
|
||||
private:
|
||||
void callback(const std_msgs::msg::String::SharedPtr msg)
|
||||
{
|
||||
RCLCPP_INFO(this->get_logger(), "[output] %s", msg->data.c_str());
|
||||
auto next_msg = std::make_shared<std_msgs::msg::String>();
|
||||
next_msg->data = "some random pong string";
|
||||
pub_->publish(*next_msg);
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
void callback(const std_msgs::msg::String::SharedPtr msg)
|
||||
{
|
||||
RCLCPP_INFO(this->get_logger(), "[output] %s", msg->data.c_str());
|
||||
auto next_msg = std::make_shared<std_msgs::msg::String>();
|
||||
next_msg->data = "some random pong string";
|
||||
pub_->publish(*next_msg);
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto pong_node = std::make_shared<PongNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(pong_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto pong_node = std::make_shared<PongNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(pong_node);
|
||||
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
|
||||
// Will actually be called inside the node's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
// Will actually be called inside the node's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,34 @@
|
|||
#include <memory>
|
||||
|
||||
#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));
|
||||
}
|
||||
explicit 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_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto pub_node = std::make_shared<PubNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(pub_node);
|
||||
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();
|
||||
printf("spinning once\n");
|
||||
exec.spin_once();
|
||||
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,43 +6,45 @@
|
|||
class ServiceNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
ServiceNode(rclcpp::NodeOptions options) : Node("service_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"service",
|
||||
std::bind(&ServiceNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
explicit ServiceNode(rclcpp::NodeOptions options)
|
||||
: Node("service_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"service",
|
||||
std::bind(
|
||||
&ServiceNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
|
||||
private:
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
// Nothing
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
}
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
// Nothing
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
}
|
||||
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto service_node = std::make_shared<ServiceNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(service_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto service_node = std::make_shared<ServiceNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(service_node);
|
||||
|
||||
printf("spinning once\n");
|
||||
exec.spin_once();
|
||||
printf("spinning once\n");
|
||||
exec.spin_once();
|
||||
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,63 +6,63 @@
|
|||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
class PingNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
PingNode(rclcpp::NodeOptions options) : Node("ping_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"pong",
|
||||
std::bind(&PingNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
client_ = this->create_client<std_srvs::srv::Empty>(
|
||||
"ping");
|
||||
timer_ = this->create_wall_timer(
|
||||
500ms,
|
||||
std::bind(&PingNode::timer_callback, this));
|
||||
}
|
||||
|
||||
explicit PingNode(rclcpp::NodeOptions options)
|
||||
: Node("ping_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"pong",
|
||||
std::bind(
|
||||
&PingNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
client_ = this->create_client<std_srvs::srv::Empty>(
|
||||
"ping");
|
||||
timer_ = this->create_wall_timer(
|
||||
500ms,
|
||||
std::bind(&PingNode::timer_callback, this));
|
||||
}
|
||||
|
||||
private:
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
RCLCPP_INFO(this->get_logger(), "got request");
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
RCLCPP_INFO(this->get_logger(), "got request");
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
|
||||
void timer_callback()
|
||||
{
|
||||
auto req = std::make_shared<std_srvs::srv::Empty::Request>();
|
||||
client_->async_send_request(req);
|
||||
}
|
||||
void timer_callback()
|
||||
{
|
||||
auto req = std::make_shared<std_srvs::srv::Empty::Request>();
|
||||
client_->async_send_request(req);
|
||||
}
|
||||
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr client_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr client_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto ping_node = std::make_shared<PingNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(ping_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto ping_node = std::make_shared<PingNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(ping_node);
|
||||
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
|
||||
// Will actually be called inside the node's service callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
// Will actually be called inside the node's service callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,55 +3,54 @@
|
|||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "std_srvs/srv/empty.hpp"
|
||||
|
||||
|
||||
class PongNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
PongNode(rclcpp::NodeOptions options) : Node("pong_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"ping",
|
||||
std::bind(&PongNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
client_ = this->create_client<std_srvs::srv::Empty>(
|
||||
"pong");
|
||||
}
|
||||
|
||||
explicit PongNode(rclcpp::NodeOptions options)
|
||||
: Node("pong_node", options)
|
||||
{
|
||||
srv_ = this->create_service<std_srvs::srv::Empty>(
|
||||
"ping",
|
||||
std::bind(
|
||||
&PongNode::service_callback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
client_ = this->create_client<std_srvs::srv::Empty>("pong");
|
||||
}
|
||||
|
||||
private:
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
RCLCPP_INFO(this->get_logger(), "got request");
|
||||
auto req = std::make_shared<std_srvs::srv::Empty::Request>();
|
||||
client_->async_send_request(req);
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
void service_callback(
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Request> request,
|
||||
const std::shared_ptr<std_srvs::srv::Empty::Response> response)
|
||||
{
|
||||
(void)request_header;
|
||||
(void)request;
|
||||
(void)response;
|
||||
RCLCPP_INFO(this->get_logger(), "got request");
|
||||
auto req = std::make_shared<std_srvs::srv::Empty::Request>();
|
||||
client_->async_send_request(req);
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr client_;
|
||||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr srv_;
|
||||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr client_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto pong_node = std::make_shared<PongNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(pong_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto pong_node = std::make_shared<PongNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(pong_node);
|
||||
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
|
||||
// Will actually be called inside the node's service callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
// Will actually be called inside the node's service callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,39 +3,39 @@
|
|||
#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));
|
||||
}
|
||||
explicit 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;
|
||||
}
|
||||
void callback(const std_msgs::msg::String::SharedPtr msg)
|
||||
{
|
||||
// Nothing
|
||||
(void)msg;
|
||||
}
|
||||
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto sub_node = std::make_shared<SubNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(sub_node);
|
||||
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();
|
||||
printf("spinning once\n");
|
||||
exec.spin_once();
|
||||
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,47 +1,48 @@
|
|||
#include <memory>
|
||||
#include <chrono>
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
class TimerNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
TimerNode(rclcpp::NodeOptions options) : Node("timer_node", options)
|
||||
{
|
||||
is_done_ = false;
|
||||
timer_ = this->create_wall_timer(
|
||||
1ms,
|
||||
std::bind(&TimerNode::timer_callback, this));
|
||||
}
|
||||
explicit TimerNode(rclcpp::NodeOptions options)
|
||||
: Node("timer_node", options)
|
||||
{
|
||||
is_done_ = false;
|
||||
timer_ = this->create_wall_timer(
|
||||
1ms,
|
||||
std::bind(&TimerNode::timer_callback, this));
|
||||
}
|
||||
|
||||
private:
|
||||
void timer_callback()
|
||||
{
|
||||
if (is_done_) {
|
||||
rclcpp::shutdown();
|
||||
} else {
|
||||
is_done_ = true;
|
||||
}
|
||||
void timer_callback()
|
||||
{
|
||||
if (is_done_) {
|
||||
rclcpp::shutdown();
|
||||
} else {
|
||||
is_done_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
bool is_done_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
bool is_done_;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto timer_node = std::make_shared<TimerNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(timer_node);
|
||||
rclcpp::executors::SingleThreadedExecutor exec;
|
||||
auto timer_node = std::make_shared<TimerNode>(rclcpp::NodeOptions());
|
||||
exec.add_node(timer_node);
|
||||
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
printf("spinning\n");
|
||||
exec.spin();
|
||||
|
||||
// Will actually be called inside the timer's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
// Will actually be called inside the timer's callback
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -12,6 +13,7 @@ node_creation_events = [
|
|||
'ros2:rcl_node_init',
|
||||
]
|
||||
|
||||
|
||||
class TestNode(unittest.TestCase):
|
||||
|
||||
def test_creation(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -11,6 +12,7 @@ publisher_creation_events = [
|
|||
'ros2:rcl_publisher_init',
|
||||
]
|
||||
|
||||
|
||||
class TestPublisher(unittest.TestCase):
|
||||
|
||||
def test_creation(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -12,6 +13,7 @@ service_creation_events = [
|
|||
'ros2:rclcpp_service_callback_added',
|
||||
]
|
||||
|
||||
|
||||
class TestService(unittest.TestCase):
|
||||
|
||||
def test_creation(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -12,6 +13,7 @@ service_callback_events = [
|
|||
'ros2:rclcpp_service_callback_end',
|
||||
]
|
||||
|
||||
|
||||
class TestServiceCallback(unittest.TestCase):
|
||||
|
||||
def test_callback(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -12,6 +13,7 @@ subscription_creation_events = [
|
|||
'ros2:rclcpp_subscription_callback_added',
|
||||
]
|
||||
|
||||
|
||||
class TestSubscription(unittest.TestCase):
|
||||
|
||||
def test_creation(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -12,6 +13,7 @@ subscription_callback_events = [
|
|||
'ros2:rclcpp_subscription_callback_end',
|
||||
]
|
||||
|
||||
|
||||
class TestSubscriptionCallback(unittest.TestCase):
|
||||
|
||||
def test_callback(self):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import unittest
|
||||
|
||||
from tracetools_test.utils import (
|
||||
cleanup_trace,
|
||||
get_trace_event_names,
|
||||
run_and_trace,
|
||||
cleanup_trace,
|
||||
)
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
|
@ -14,6 +15,7 @@ timer_events = [
|
|||
'ros2:rclcpp_timer_callback_end',
|
||||
]
|
||||
|
||||
|
||||
class TestTimer(unittest.TestCase):
|
||||
|
||||
def test_all(self):
|
||||
|
|
|
@ -1,23 +1,30 @@
|
|||
# Utils for tracetools_test
|
||||
|
||||
import time
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import babeltrace
|
||||
from launch import LaunchDescription
|
||||
from launch import LaunchService
|
||||
from launch_ros import get_default_launch_description
|
||||
import launch_ros.actions
|
||||
from tracetools_trace.tools.lttng import (
|
||||
lttng_destroy,
|
||||
lttng_setup,
|
||||
lttng_start,
|
||||
lttng_stop,
|
||||
lttng_destroy,
|
||||
)
|
||||
|
||||
def run_and_trace(base_path, session_name_prefix, ros_events, kernel_events, package_name, node_names):
|
||||
|
||||
def run_and_trace(base_path,
|
||||
session_name_prefix,
|
||||
ros_events,
|
||||
kernel_events,
|
||||
package_name,
|
||||
node_names):
|
||||
"""
|
||||
Run a node while tracing
|
||||
Run a node while tracing.
|
||||
|
||||
:param base_path (str): the base path where to put the trace directory
|
||||
:param session_name_prefix (str): the session name prefix for the trace directory
|
||||
:param ros_events (list(str)): the list of ROS UST events to enable
|
||||
|
@ -53,7 +60,8 @@ def run_and_trace(base_path, session_name_prefix, ros_events, kernel_events, pac
|
|||
|
||||
def cleanup_trace(full_path):
|
||||
"""
|
||||
Cleanup trace data
|
||||
Cleanup trace data.
|
||||
|
||||
:param full_path (str): the full path to the main trace directory
|
||||
"""
|
||||
shutil.rmtree(full_path)
|
||||
|
@ -61,7 +69,8 @@ def cleanup_trace(full_path):
|
|||
|
||||
def get_trace_event_names(trace_directory):
|
||||
"""
|
||||
Get a set of event names in a trace
|
||||
Get a set of event names in a trace.
|
||||
|
||||
:param trace_directory (str): the path to the main/top trace directory
|
||||
:return: event names (set(str))
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue