@@ -59,8 +59,6 @@ namespace executors
59
59
*/
60
60
class EventsExecutor : public rclcpp ::Executor
61
61
{
62
- friend class EventsExecutorEntitiesCollector ;
63
-
64
62
public:
65
63
RCLCPP_SMART_PTR_DEFINITIONS (EventsExecutor)
66
64
@@ -72,7 +70,7 @@ class EventsExecutor : public rclcpp::Executor
72
70
* \param[in] options Options used to configure the executor.
73
71
*/
74
72
RCLCPP_PUBLIC
75
- explicit EventsExecutor (
73
+ EventsExecutor (
76
74
rclcpp::experimental::executors::EventsQueue::UniquePtr events_queue = std::make_unique<
77
75
rclcpp::experimental::executors::SimpleEventsQueue>(),
78
76
bool execute_timers_separate_thread = false ,
@@ -128,87 +126,6 @@ class EventsExecutor : public rclcpp::Executor
128
126
void
129
127
spin_all (std::chrono::nanoseconds max_duration) override ;
130
128
131
- // / Add a node to the executor.
132
- /* *
133
- * \sa rclcpp::Executor::add_node
134
- */
135
- RCLCPP_PUBLIC
136
- void
137
- add_node (
138
- rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
139
- bool notify = true ) override ;
140
-
141
- // / Convenience function which takes Node and forwards NodeBaseInterface.
142
- /* *
143
- * \sa rclcpp::EventsExecutor::add_node
144
- */
145
- RCLCPP_PUBLIC
146
- void
147
- add_node (std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true ) override ;
148
-
149
- // / Remove a node from the executor.
150
- /* *
151
- * \sa rclcpp::Executor::remove_node
152
- */
153
- RCLCPP_PUBLIC
154
- void
155
- remove_node (
156
- rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
157
- bool notify = true ) override ;
158
-
159
- // / Convenience function which takes Node and forwards NodeBaseInterface.
160
- /* *
161
- * \sa rclcpp::Executor::remove_node
162
- */
163
- RCLCPP_PUBLIC
164
- void
165
- remove_node (std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true ) override ;
166
-
167
- // / Add a callback group to an executor.
168
- /* *
169
- * \sa rclcpp::Executor::add_callback_group
170
- */
171
- RCLCPP_PUBLIC
172
- void
173
- add_callback_group (
174
- rclcpp::CallbackGroup::SharedPtr group_ptr,
175
- rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
176
- bool notify = true ) override ;
177
-
178
- // / Remove callback group from the executor
179
- /* *
180
- * \sa rclcpp::Executor::remove_callback_group
181
- */
182
- RCLCPP_PUBLIC
183
- void
184
- remove_callback_group (
185
- rclcpp::CallbackGroup::SharedPtr group_ptr,
186
- bool notify = true ) override ;
187
-
188
- // / Get callback groups that belong to executor.
189
- /* *
190
- * \sa rclcpp::Executor::get_all_callback_groups()
191
- */
192
- RCLCPP_PUBLIC
193
- std::vector<rclcpp::CallbackGroup::WeakPtr>
194
- get_all_callback_groups () override ;
195
-
196
- // / Get callback groups that belong to executor.
197
- /* *
198
- * \sa rclcpp::Executor::get_manually_added_callback_groups()
199
- */
200
- RCLCPP_PUBLIC
201
- std::vector<rclcpp::CallbackGroup::WeakPtr>
202
- get_manually_added_callback_groups () override ;
203
-
204
- // / Get callback groups that belong to executor.
205
- /* *
206
- * \sa rclcpp::Executor::get_automatically_added_callback_groups_from_nodes()
207
- */
208
- RCLCPP_PUBLIC
209
- std::vector<rclcpp::CallbackGroup::WeakPtr>
210
- get_automatically_added_callback_groups_from_nodes () override ;
211
-
212
129
protected:
213
130
// / Internal implementation of spin_once
214
131
RCLCPP_PUBLIC
@@ -220,16 +137,21 @@ class EventsExecutor : public rclcpp::Executor
220
137
void
221
138
spin_some_impl (std::chrono::nanoseconds max_duration, bool exhaustive);
222
139
140
+ // / Collect entities from callback groups and refresh the current collection with them
141
+ RCLCPP_PUBLIC
142
+ void
143
+ handle_updated_entities (bool notify) override ;
144
+
223
145
private:
224
146
RCLCPP_DISABLE_COPY (EventsExecutor)
225
147
226
148
// / Execute a provided executor event if its associated entities are available
227
149
void
228
150
execute_event(const ExecutorEvent & event);
229
151
230
- // / Collect entities from callback groups and refresh the current collection with them
152
+ // / Rebuilds the executor's notify waitable, as we can't use the one built in the base class
231
153
void
232
- refresh_current_collection_from_callback_groups ();
154
+ setup_notify_waitable ();
233
155
234
156
// / Refresh the current collection using the provided new_collection
235
157
void
@@ -253,6 +175,11 @@ class EventsExecutor : public rclcpp::Executor
253
175
typename CollectionType::EntitySharedPtr
254
176
retrieve_entity (typename CollectionType::Key entity_id, CollectionType & collection)
255
177
{
178
+ // Note: we lock the mutex because we assume that you are trying to get an element from the
179
+ // current collection... If there will be a use-case to retrieve elements also from other
180
+ // collections, we can move the mutex back to the calling codes.
181
+ std::lock_guard<std::mutex> guard (mutex_);
182
+
256
183
// Check if the entity_id is in the collection
257
184
auto it = collection.find (entity_id);
258
185
if (it == collection.end ()) {
@@ -273,16 +200,6 @@ class EventsExecutor : public rclcpp::Executor
273
200
// / Queue where entities can push events
274
201
rclcpp::experimental::executors::EventsQueue::UniquePtr events_queue_;
275
202
276
- std::shared_ptr<rclcpp::executors::ExecutorEntitiesCollector> entities_collector_;
277
- std::shared_ptr<rclcpp::executors::ExecutorNotifyWaitable> notify_waitable_;
278
-
279
- // / Mutex to protect the current_entities_collection_
280
- std::recursive_mutex collection_mutex_;
281
- std::shared_ptr<rclcpp::executors::ExecutorEntitiesCollection> current_entities_collection_;
282
-
283
- // / Flag used to reduce the number of unnecessary waitable events
284
- std::atomic<bool > notify_waitable_event_pushed_ {false };
285
-
286
203
// / Timers manager used to track and/or execute associated timers
287
204
std::shared_ptr<rclcpp::experimental::TimersManager> timers_manager_;
288
205
};
0 commit comments