Skip to content

Commit 402a9c9

Browse files
committed
Fix create_worker bug
Signed-off-by: Michael X. Grey <[email protected]>
1 parent a27bb89 commit 402a9c9

File tree

5 files changed

+13
-36
lines changed

5 files changed

+13
-36
lines changed

rclrs/package.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
<depend>builtin_interfaces</depend>
2020
<depend>rcl_interfaces</depend>
2121
<depend>rosgraph_msgs</depend>
22-
22+
2323
<test_depend>test_msgs</test_depend>
24+
<test_depend>example_interfaces</test_depend>
2425

2526
<export>
2627
<build_type>ament_cargo</build_type>

rclrs/src/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
Publisher, PublisherOptions, PublisherState, RclrsError, Service, IntoAsyncServiceCallback,
3535
IntoNodeServiceCallback, ServiceOptions, ServiceState, Subscription, IntoAsyncSubscriptionCallback,
3636
IntoNodeSubscriptionCallback, SubscriptionOptions, SubscriptionState, TimeSource, ToLogParams,
37-
ENTITY_LIFECYCLE_MUTEX, IntoWorkerOptions, Worker, WorkerState,
37+
ENTITY_LIFECYCLE_MUTEX, Worker, WorkerOptions, WorkerState,
3838
};
3939

4040
/// A processing unit that can communicate with other nodes. See the API of
@@ -293,12 +293,12 @@ impl NodeState {
293293
/// created later inside a subscription or service callback using the [`Node`].
294294
pub fn create_worker<'a, Payload>(
295295
self: &Arc<Self>,
296-
options: impl IntoWorkerOptions<Payload>,
296+
options: impl Into<WorkerOptions<Payload>>,
297297
) -> Worker<Payload>
298298
where
299299
Payload: 'static + Send + Sync,
300300
{
301-
let options = options.into_worker_options();
301+
let options = options.into();
302302
let commands = self.commands.create_worker_commands(Box::new(options.payload));
303303
WorkerState::create(Arc::clone(self), commands)
304304
}

rclrs/src/service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ impl<T: IdlService> ServiceState<T, Node> {
176176
/// If the `Scope` is [`Worker<Payload>`] then use [`Self::set_worker_callback`] instead.
177177
pub fn set_callback<Args>(&self, callback: impl IntoNodeServiceCallback<T, Args>) {
178178
let callback = callback.into_node_service_callback();
179-
// TODO(@mxgrey): Log any errors here when logging becomes available
180179
*self.callback.lock().unwrap() = callback;
181180
}
182181

rclrs/src/wait_set.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1-
// Copyright 2020 DCS Corporation, All Rights Reserved.
2-
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
15-
// DISTRIBUTION A. Approved for public release; distribution unlimited.
16-
// OPSEC #4584.
17-
181
use std::{collections::HashMap, sync::Arc, time::Duration, vec::Vec};
192

203
use crate::{
214
error::{to_rclrs_result, RclReturnCode, RclrsError, ToResult},
225
rcl_bindings::*,
23-
Context, ContextHandle,
6+
Context, ContextHandle, log_error,
247
};
258

269
mod guard_condition;
@@ -170,8 +153,10 @@ impl WaitSet {
170153
// the rcl entities.
171154
self.rcl_clear();
172155
if let Err(err) = self.register_rcl_primitives() {
173-
// TODO(@mxgrey): Log this error when logging is available
174-
eprintln!("Error while registering rcl primitives: {err}");
156+
log_error!(
157+
"rclrs.WaitSet.wait",
158+
"Error while registering rcl primitives: {err}",
159+
);
175160
}
176161

177162
Ok(())

rclrs/src/worker.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,9 @@ impl<Payload> WorkerOptions<Payload> {
218218
}
219219
}
220220

221-
/// Implicitly convert something into [`WorkerOptions`].
222-
pub trait IntoWorkerOptions<Payload> {
223-
/// Convert an object into [`WorkerOptions`]. Users do not need to call this.
224-
fn into_worker_options(self) -> WorkerOptions<Payload>;
225-
// TODO(@mxgrey): Check what happens when a user passes in an actual
226-
// WorkerOptions... it might create a WorkerOptions<WorkerOptions<T>>.
227-
}
228-
229-
impl<Payload> IntoWorkerOptions<Payload> for Payload {
230-
fn into_worker_options(self) -> WorkerOptions<Payload> {
231-
WorkerOptions::new(self)
221+
impl<T> From<T> for WorkerOptions<T> {
222+
fn from(value: T) -> Self {
223+
WorkerOptions::new(value)
232224
}
233225
}
234226

0 commit comments

Comments
 (0)