Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rclrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,5 @@ pub use time::*;
use time_source::*;
pub use wait_set::*;
pub use worker::*;

pub use rosidl_runtime_rs::{Message as MessageIDL, Service as ServiceIDL};
24 changes: 12 additions & 12 deletions rclrs/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
sync::{Arc, Mutex, MutexGuard},
};

use rosidl_runtime_rs::{Message, Service as IdlService};
use rosidl_runtime_rs::{Message, Service as ServiceIDL};

use crate::{
error::ToResult, rcl_bindings::*, IntoPrimitiveOptions, MessageCow, Node, NodeHandle,
Expand Down Expand Up @@ -71,7 +71,7 @@ pub type WorkerService<T, Payload> = Arc<ServiceState<T, Worker<Payload>>>;
/// [1]: std::sync::Weak
pub struct ServiceState<T, Scope>
where
T: IdlService,
T: ServiceIDL,
Scope: WorkScope,
{
/// This handle is used to access the data that rcl holds for this service.
Expand All @@ -86,7 +86,7 @@ where

impl<T, Scope> ServiceState<T, Scope>
where
T: IdlService,
T: ServiceIDL,
Scope: WorkScope + 'static,
{
/// Returns the name of the service.
Expand Down Expand Up @@ -166,7 +166,7 @@ where
}
}

impl<T: IdlService> ServiceState<T, Node> {
impl<T: ServiceIDL> ServiceState<T, Node> {
/// Set the callback of this service, replacing the callback that was
/// previously set.
///
Expand All @@ -192,7 +192,7 @@ impl<T: IdlService> ServiceState<T, Node> {
}
}

impl<T: IdlService, Payload: 'static + Send + Sync> ServiceState<T, Worker<Payload>> {
impl<T: ServiceIDL, Payload: 'static + Send + Sync> ServiceState<T, Worker<Payload>> {
/// Set the callback of this service, replacing the callback that was
/// previously set.
///
Expand Down Expand Up @@ -238,15 +238,15 @@ impl<'a, T: IntoPrimitiveOptions<'a>> From<T> for ServiceOptions<'a> {
}
}

struct ServiceExecutable<T: IdlService, Scope: WorkScope> {
struct ServiceExecutable<T: ServiceIDL, Scope: WorkScope> {
handle: Arc<ServiceHandle>,
callback: Arc<Mutex<AnyServiceCallback<T, Scope::Payload>>>,
commands: Arc<WorkerCommands>,
}

impl<T, Scope> RclPrimitive for ServiceExecutable<T, Scope>
where
T: IdlService,
T: ServiceIDL,
Scope: WorkScope,
{
unsafe fn execute(&mut self, payload: &mut dyn Any) -> Result<(), RclrsError> {
Expand Down Expand Up @@ -317,9 +317,9 @@ impl ServiceHandle {
// | rmw_take |
// +---------------------+
// ```
fn take_request<T: IdlService>(&self) -> Result<(T::Request, rmw_request_id_t), RclrsError> {
fn take_request<T: ServiceIDL>(&self) -> Result<(T::Request, rmw_request_id_t), RclrsError> {
let mut request_id_out = RequestId::zero_initialized_rmw();
type RmwMsg<T> = <<T as IdlService>::Request as Message>::RmwMsg;
type RmwMsg<T> = <<T as ServiceIDL>::Request as Message>::RmwMsg;
let mut request_out = RmwMsg::<T>::default();
let handle = &*self.lock();
unsafe {
Expand All @@ -335,11 +335,11 @@ impl ServiceHandle {
}

/// Same as [`Self::take_request`] but includes additional info about the service
fn take_request_with_info<T: IdlService>(
fn take_request_with_info<T: ServiceIDL>(
&self,
) -> Result<(T::Request, rmw_service_info_t), RclrsError> {
let mut service_info_out = ServiceInfo::zero_initialized_rmw();
type RmwMsg<T> = <<T as IdlService>::Request as Message>::RmwMsg;
type RmwMsg<T> = <<T as ServiceIDL>::Request as Message>::RmwMsg;
let mut request_out = RmwMsg::<T>::default();
let handle = &*self.lock();
unsafe {
Expand All @@ -354,7 +354,7 @@ impl ServiceHandle {
Ok((T::Request::from_rmw_message(request_out), service_info_out))
}

fn send_response<T: IdlService>(
fn send_response<T: ServiceIDL>(
self: &Arc<Self>,
request_id: &mut rmw_request_id_t,
response: T::Response,
Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
WorkerCommands, WorkerService, WorkerSubscription,
};
use futures::channel::oneshot;
use rosidl_runtime_rs::{Message, Service as IdlService};
use rosidl_runtime_rs::{Message, Service as ServiceIDL};
use std::{
any::Any,
sync::{Arc, Mutex, Weak},
Expand Down Expand Up @@ -360,7 +360,7 @@ impl<Payload: 'static + Send + Sync> WorkerState<Payload> {
callback: impl IntoWorkerServiceCallback<T, Payload, Args>,
) -> Result<WorkerService<T, Payload>, RclrsError>
where
T: IdlService,
T: ServiceIDL,
{
ServiceState::<T, Worker<Payload>>::create(
options,
Expand Down