#![allow(unused_variables)]
#![allow(clippy::useless_conversion, clippy::unit_arg)]
use abi_stable::StableAbi;
use arci::{
gamepad::GamepadEvent, BaseVelocity, Error, Isometry2, Isometry3, Scan2D,
TrajectoryPoint, WaitFuture,
};
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_laser_scan2_d(
&self,
args: String,
) -> Result<Option<Box<dyn arci::LaserScan2D>>, 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_motor_drive_position(
&self,
args: String,
) -> Result<Option<Box<dyn arci::MotorDrivePosition>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_motor_drive_velocity(
&self,
args: String,
) -> Result<Option<Box<dyn arci::MotorDriveVelocity>>, arci::Error> {
let _ = args;
Ok(None)
}
fn new_motor_drive_effort(
&self,
args: String,
) -> Result<Option<Box<dyn arci::MotorDriveEffort>>, 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_laser_scan2_d(
&self,
args: String,
) -> Result<Option<LaserScan2DProxy>, arci::Error> {
Ok(self.0.new_laser_scan2_d(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_motor_drive_position(
&self,
args: String,
) -> Result<Option<MotorDrivePositionProxy>, arci::Error> {
Ok(self.0.new_motor_drive_position(args.into()).into_result()?.into_option())
}
pub fn new_motor_drive_velocity(
&self,
args: String,
) -> Result<Option<MotorDriveVelocityProxy>, arci::Error> {
Ok(self.0.new_motor_drive_velocity(args.into()).into_result()?.into_option())
}
pub fn new_motor_drive_effort(
&self,
args: String,
) -> Result<Option<MotorDriveEffortProxy>, arci::Error> {
Ok(self.0.new_motor_drive_effort(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 GamepadProxy(pub(crate) crate::proxy::GamepadTraitObject);
impl GamepadProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::Gamepad + 'static,
{
Self(
crate::proxy::GamepadTraitObject::from_value(
Arc::new(inner),
abi_stable::erased_types::TD_Opaque,
),
)
}
}
#[arci::async_trait]
impl arci::Gamepad for GamepadProxy {
async fn next_event(&self) -> GamepadEvent {
self.0.next_event().await.into()
}
fn stop(&self) {
self.0.stop().into()
}
}
impl std::fmt::Debug for GamepadProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GamepadProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct JointTrajectoryClientProxy(
pub(crate) crate::proxy::JointTrajectoryClientTraitObject,
);
impl JointTrajectoryClientProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::JointTrajectoryClient + 'static,
{
Self(
crate::proxy::JointTrajectoryClientTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::JointTrajectoryClient for JointTrajectoryClientProxy {
fn joint_names(&self) -> Vec<String> {
self.0.joint_names().into_iter().map(Into::into).collect()
}
fn current_joint_positions(&self) -> Result<Vec<f64>, Error> {
Ok(self.0.current_joint_positions().into_result()?.into())
}
fn send_joint_positions(
&self,
positions: Vec<f64>,
duration: std::time::Duration,
) -> Result<WaitFuture, Error> {
Ok(
self
.0
.send_joint_positions(positions.into(), duration.into())
.into_result()?
.into(),
)
}
fn send_joint_trajectory(
&self,
trajectory: Vec<TrajectoryPoint>,
) -> Result<WaitFuture, Error> {
Ok(
self
.0
.send_joint_trajectory(trajectory.into_iter().map(Into::into).collect())
.into_result()?
.into(),
)
}
}
impl std::fmt::Debug for JointTrajectoryClientProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("JointTrajectoryClientProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct LaserScan2DProxy(pub(crate) crate::proxy::LaserScan2DTraitObject);
impl LaserScan2DProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::LaserScan2D + 'static,
{
Self(
crate::proxy::LaserScan2DTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::LaserScan2D for LaserScan2DProxy {
fn current_scan(&self) -> Result<Scan2D, Error> {
Ok(self.0.current_scan().into_result()?.into())
}
}
impl std::fmt::Debug for LaserScan2DProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LaserScan2DProxy").finish()
}
}
#[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 MotorDrivePositionProxy(
pub(crate) crate::proxy::MotorDrivePositionTraitObject,
);
impl MotorDrivePositionProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::MotorDrivePosition + 'static,
{
Self(
crate::proxy::MotorDrivePositionTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::MotorDrivePosition for MotorDrivePositionProxy {
fn set_motor_position(&self, position: f64) -> Result<(), Error> {
Ok(self.0.set_motor_position(position.into()).into_result()?.into())
}
fn get_motor_position(&self) -> Result<f64, Error> {
Ok(self.0.get_motor_position().into_result()?.into())
}
}
impl std::fmt::Debug for MotorDrivePositionProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MotorDrivePositionProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct MotorDriveVelocityProxy(
pub(crate) crate::proxy::MotorDriveVelocityTraitObject,
);
impl MotorDriveVelocityProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::MotorDriveVelocity + 'static,
{
Self(
crate::proxy::MotorDriveVelocityTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::MotorDriveVelocity for MotorDriveVelocityProxy {
fn set_motor_velocity(&self, velocity: f64) -> Result<(), Error> {
Ok(self.0.set_motor_velocity(velocity.into()).into_result()?.into())
}
fn get_motor_velocity(&self) -> Result<f64, Error> {
Ok(self.0.get_motor_velocity().into_result()?.into())
}
}
impl std::fmt::Debug for MotorDriveVelocityProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MotorDriveVelocityProxy").finish()
}
}
#[derive(StableAbi)]
#[repr(C)]
pub struct MotorDriveEffortProxy(pub(crate) crate::proxy::MotorDriveEffortTraitObject);
impl MotorDriveEffortProxy {
pub fn new<T>(inner: T) -> Self
where
T: arci::MotorDriveEffort + 'static,
{
Self(
crate::proxy::MotorDriveEffortTraitObject::from_value(
inner,
abi_stable::erased_types::TD_Opaque,
),
)
}
}
impl arci::MotorDriveEffort for MotorDriveEffortProxy {
fn set_motor_effort(&self, effort: f64) -> Result<(), Error> {
Ok(self.0.set_motor_effort(effort.into()).into_result()?.into())
}
fn get_motor_effort(&self) -> Result<f64, Error> {
Ok(self.0.get_motor_effort().into_result()?.into())
}
}
impl std::fmt::Debug for MotorDriveEffortProxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MotorDriveEffortProxy").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()
}
}