#![allow(unused_variables)]
#![allow(clippy::useless_conversion, clippy::unit_arg)]
use arci::{BaseVelocity, Error, Isometry2, Isometry3, WaitFuture};
use abi_stable::StableAbi;
use super::*;
pub trait Plugin: Send + Sync + 'static {
fn new_gamepad(
&self,
args: String,
) -> Result<Option<Box<dyn arci::Gamepad>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_joint_trajectory_client(
&self,
args: String,
) -> Result<Option<Box<dyn arci::JointTrajectoryClient>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_localization(
&self,
args: String,
) -> Result<Option<Box<dyn arci::Localization>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_move_base(
&self,
args: String,
) -> Result<Option<Box<dyn arci::MoveBase>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_navigation(
&self,
args: String,
) -> Result<Option<Box<dyn arci::Navigation>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_speaker(
&self,
args: String,
) -> Result<Option<Box<dyn arci::Speaker>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_transform_resolver(
&self,
args: String,
) -> Result<Option<Box<dyn arci::TransformResolver>>, arci::Error> {
let _ = args;
Ok(None)
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct PluginProxy(pub(crate) crate::proxy::PluginTraitObject);
impl PluginProxy {
pub fn new<T>(inner: T) -> Self
where
T: Plugin + 'static,
{
Self(
crate::proxy::PluginTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl PluginProxy {
pub fn new_gamepad(
&self,
args: String,
) -> Result<Option<GamepadProxy>, arci::Error> {
Ok(self.0.new_gamepad(args.into()).into_result()?.into_option())
}
pub fn new_joint_trajectory_client(
&self,
args: String,
) -> Result<Option<JointTrajectoryClientProxy>, arci::Error> {
Ok(self.0.new_joint_trajectory_client(args.into()).into_result()?.into_option())
}
pub fn new_localization(
&self,
args: String,
) -> Result<Option<LocalizationProxy>, arci::Error> {
Ok(self.0.new_localization(args.into()).into_result()?.into_option())
}
pub fn new_move_base(
&self,
args: String,
) -> Result<Option<MoveBaseProxy>, arci::Error> {
Ok(self.0.new_move_base(args.into()).into_result()?.into_option())
}
pub fn new_navigation(
&self,
args: String,
) -> Result<Option<NavigationProxy>, arci::Error> {
Ok(self.0.new_navigation(args.into()).into_result()?.into_option())
}
pub fn new_speaker(
&self,
args: String,
) -> Result<Option<SpeakerProxy>, arci::Error> {
Ok(self.0.new_speaker(args.into()).into_result()?.into_option())
}
pub fn new_transform_resolver(
&self,
args: String,
) -> Result<Option<TransformResolverProxy>, arci::Error> {
Ok(self.0.new_transform_resolver(args.into()).into_result()?.into_option())
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct LocalizationProxy(pub(crate) crate::proxy::LocalizationTraitObject);
impl LocalizationProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::Localization + 'static,
{
Self(
crate::proxy::LocalizationTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::Localization for LocalizationProxy {
fn current_pose(&self, frame_id: &str) -> Result<Isometry2<f64>, Error> {
Ok(self.0.current_pose(frame_id.into()).into_result()?.into())
}
}
impl std::fmt::Debug for LocalizationProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LocalizationProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct MoveBaseProxy(pub(crate) crate::proxy::MoveBaseTraitObject);
impl MoveBaseProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::MoveBase + 'static,
{
Self(
crate::proxy::MoveBaseTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::MoveBase for MoveBaseProxy {
fn send_velocity(&self, velocity: &BaseVelocity) -> Result<(), Error> {
Ok(self.0.send_velocity((*velocity).into()).into_result()?.into())
}
fn current_velocity(&self) -> Result<BaseVelocity, Error> {
Ok(self.0.current_velocity().into_result()?.into())
}
}
impl std::fmt::Debug for MoveBaseProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MoveBaseProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct NavigationProxy(pub(crate) crate::proxy::NavigationTraitObject);
impl NavigationProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::Navigation + 'static,
{
Self(
crate::proxy::NavigationTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::Navigation for NavigationProxy {
fn send_goal_pose(
&self,
goal: Isometry2<f64>,
frame_id: &str,
timeout: std::time::Duration,
) -> Result<WaitFuture, Error> {
Ok(
self
.0
.send_goal_pose(goal.into(), frame_id.into(), timeout.into())
.into_result()?
.into(),
)
}
fn cancel(&self) -> Result<(), Error> {
Ok(self.0.cancel().into_result()?.into())
}
}
impl std::fmt::Debug for NavigationProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("NavigationProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct SpeakerProxy(pub(crate) crate::proxy::SpeakerTraitObject);
impl SpeakerProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::Speaker + 'static,
{
Self(
crate::proxy::SpeakerTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::Speaker for SpeakerProxy {
fn speak(&self, message: &str) -> Result<WaitFuture, Error> {
Ok(self.0.speak(message.into()).into_result()?.into())
}
}
impl std::fmt::Debug for SpeakerProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SpeakerProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct TransformResolverProxy(pub(crate) crate::proxy::TransformResolverTraitObject);
impl TransformResolverProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::TransformResolver + 'static,
{
Self(
crate::proxy::TransformResolverTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::TransformResolver for TransformResolverProxy {
fn resolve_transformation(
&self,
from: &str,
to: &str,
time: std::time::SystemTime,
) -> Result<Isometry3<f64>, Error> {
Ok(
self
.0
.resolve_transformation(from.into(), to.into(), time.try_into()?)
.into_result()?
.into(),
)
}
}
impl std::fmt::Debug for TransformResolverProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TransformResolverProxy").finish()
}
}