Skip to content

Commit 98efb4c

Browse files
author
Mauro Passerino
committed
Merge branch 'master' into mauro/clean-events-executor
2 parents f9457a2 + b1ff2d5 commit 98efb4c

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed

rclcpp/include/rclcpp/time_source.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ namespace rclcpp
3232
{
3333
class Clock;
3434

35+
/**
36+
* Time source that will drive the attached clocks.
37+
*
38+
* If the attached node `use_sim_time` parameter is `true`, the attached clocks will
39+
* be updated based on messages received.
40+
*
41+
* The subscription to the clock topic created by the time source can have it's qos reconfigured
42+
* using parameter overrides, particularly the following ones are accepted:
43+
*
44+
* - qos_overrides./clock.depth
45+
* - qos_overrides./clock.durability
46+
* - qos_overrides./clock.history
47+
* - qos_overrides./clock.reliability
48+
*/
3549
class TimeSource
3650
{
3751
public:

rclcpp/src/rclcpp/executors/static_executor_entities_collector.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ StaticExecutorEntitiesCollector::add_callback_group(
323323
throw std::runtime_error("Callback group was already added to executor.");
324324
}
325325
if (is_new_node) {
326-
rclcpp::node_interfaces::NodeBaseInterface::WeakPtr node_weak_ptr(node_ptr);
327-
weak_nodes_to_guard_conditions_[node_weak_ptr] = node_ptr->get_notify_guard_condition();
326+
weak_nodes_to_guard_conditions_[node_ptr] = node_ptr->get_notify_guard_condition();
328327
return true;
329328
}
330329
return false;

rclcpp/src/rclcpp/executors/static_single_threaded_executor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ StaticSingleThreadedExecutor::execute_ready_executables()
175175
}
176176
// Execute all the ready waitables
177177
for (size_t i = 0; i < entities_collector_->get_number_of_waitables(); ++i) {
178-
if (entities_collector_->get_waitable(i)->is_ready(&wait_set_)) {
179-
std::shared_ptr<void> shared_ptr;
180-
entities_collector_->get_waitable(i)->execute(shared_ptr);
178+
auto waitable = entities_collector_->get_waitable(i);
179+
if (waitable->is_ready(&wait_set_)) {
180+
auto data = waitable->take_data();
181+
waitable->execute(data);
181182
}
182183
}
183184
}

rclcpp/src/rclcpp/node_interfaces/node_timers.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <string>
1818

19+
#include "tracetools/tracetools.h"
20+
1921
using rclcpp::node_interfaces::NodeTimers;
2022

2123
NodeTimers::NodeTimers(rclcpp::node_interfaces::NodeBaseInterface * node_base)
@@ -44,4 +46,8 @@ NodeTimers::add_timer(
4446
std::string("Failed to notify wait set on timer creation: ") +
4547
rmw_get_error_string().str);
4648
}
49+
TRACEPOINT(
50+
rclcpp_timer_link_node,
51+
static_cast<const void *>(timer->get_timer_handle().get()),
52+
static_cast<const void *>(node_base_->get_rcl_node_handle()));
4753
}

rclcpp/src/rclcpp/time_source.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,22 @@ void TimeSource::create_clock_sub()
233233
return;
234234
}
235235

236+
rclcpp::SubscriptionOptions options;
237+
options.qos_overriding_options = rclcpp::QosOverridingOptions(
238+
{
239+
rclcpp::QosPolicyKind::Depth,
240+
rclcpp::QosPolicyKind::Durability,
241+
rclcpp::QosPolicyKind::History,
242+
rclcpp::QosPolicyKind::Reliability,
243+
});
244+
236245
clock_subscription_ = rclcpp::create_subscription<rosgraph_msgs::msg::Clock>(
246+
node_parameters_,
237247
node_topics_,
238248
"/clock",
239249
rclcpp::QoS(KeepLast(1)).best_effort(),
240-
std::bind(&TimeSource::clock_cb, this, std::placeholders::_1)
250+
std::bind(&TimeSource::clock_cb, this, std::placeholders::_1),
251+
options
241252
);
242253
}
243254

rclcpp/test/rclcpp/test_executor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ TEST_F(TestExecutor, constructor_bad_guard_condition_init) {
122122
auto mock = mocking_utils::patch_and_return(
123123
"lib:rclcpp", rcl_guard_condition_init, RCL_RET_ERROR);
124124
EXPECT_THROW(
125-
new DummyExecutor(),
125+
static_cast<void>(std::make_unique<DummyExecutor>()),
126126
rclcpp::exceptions::RCLError);
127127
}
128128

129129
TEST_F(TestExecutor, constructor_bad_wait_set_init) {
130130
auto mock = mocking_utils::patch_and_return("lib:rclcpp", rcl_wait_set_init, RCL_RET_ERROR);
131131
RCLCPP_EXPECT_THROW_EQ(
132-
new DummyExecutor(),
132+
static_cast<void>(std::make_unique<DummyExecutor>()),
133133
std::runtime_error("Failed to create wait set in Executor constructor: error not set"));
134134
}
135135

0 commit comments

Comments
 (0)