1#![allow(unused_variables)]
5#![allow(clippy::useless_conversion, clippy::unit_arg)]
6
7use abi_stable::StableAbi;
8use arci::{
9 gamepad::GamepadEvent, BaseVelocity, Error, Isometry2, Isometry3, Scan2D,
10 TrajectoryPoint, WaitFuture,
11};
12use super::*;
13pub trait Plugin: Send + Sync + 'static {
15 fn new_gamepad(
17 &self,
18 args: String,
19 ) -> Result<Option<Box<dyn arci::Gamepad>>, arci::Error> {
20 let _ = args;
21 Ok(None)
22 }
23 fn new_joint_trajectory_client(
25 &self,
26 args: String,
27 ) -> Result<Option<Box<dyn arci::JointTrajectoryClient>>, arci::Error> {
28 let _ = args;
29 Ok(None)
30 }
31 fn new_laser_scan2_d(
33 &self,
34 args: String,
35 ) -> Result<Option<Box<dyn arci::LaserScan2D>>, arci::Error> {
36 let _ = args;
37 Ok(None)
38 }
39 fn new_localization(
41 &self,
42 args: String,
43 ) -> Result<Option<Box<dyn arci::Localization>>, arci::Error> {
44 let _ = args;
45 Ok(None)
46 }
47 fn new_motor_drive_position(
49 &self,
50 args: String,
51 ) -> Result<Option<Box<dyn arci::MotorDrivePosition>>, arci::Error> {
52 let _ = args;
53 Ok(None)
54 }
55 fn new_motor_drive_velocity(
57 &self,
58 args: String,
59 ) -> Result<Option<Box<dyn arci::MotorDriveVelocity>>, arci::Error> {
60 let _ = args;
61 Ok(None)
62 }
63 fn new_motor_drive_effort(
65 &self,
66 args: String,
67 ) -> Result<Option<Box<dyn arci::MotorDriveEffort>>, arci::Error> {
68 let _ = args;
69 Ok(None)
70 }
71 fn new_move_base(
73 &self,
74 args: String,
75 ) -> Result<Option<Box<dyn arci::MoveBase>>, arci::Error> {
76 let _ = args;
77 Ok(None)
78 }
79 fn new_navigation(
81 &self,
82 args: String,
83 ) -> Result<Option<Box<dyn arci::Navigation>>, arci::Error> {
84 let _ = args;
85 Ok(None)
86 }
87 fn new_speaker(
89 &self,
90 args: String,
91 ) -> Result<Option<Box<dyn arci::Speaker>>, arci::Error> {
92 let _ = args;
93 Ok(None)
94 }
95 fn new_transform_resolver(
97 &self,
98 args: String,
99 ) -> Result<Option<Box<dyn arci::TransformResolver>>, arci::Error> {
100 let _ = args;
101 Ok(None)
102 }
103}
104#[derive(StableAbi)]
106#[repr(C)]
107pub struct PluginProxy(pub(crate) crate::proxy::PluginTraitObject);
108impl PluginProxy {
109 pub fn new<T>(inner: T) -> Self
111 where
112 T: Plugin + 'static,
113 {
114 Self(
115 crate::proxy::PluginTraitObject::from_value(
116 inner,
117 abi_stable::erased_types::TD_Opaque,
118 ),
119 )
120 }
121}
122impl PluginProxy {
123 pub fn new_gamepad(
125 &self,
126 args: String,
127 ) -> Result<Option<GamepadProxy>, arci::Error> {
128 Ok(self.0.new_gamepad(args.into()).into_result()?.into_option())
129 }
130 pub fn new_joint_trajectory_client(
132 &self,
133 args: String,
134 ) -> Result<Option<JointTrajectoryClientProxy>, arci::Error> {
135 Ok(self.0.new_joint_trajectory_client(args.into()).into_result()?.into_option())
136 }
137 pub fn new_laser_scan2_d(
139 &self,
140 args: String,
141 ) -> Result<Option<LaserScan2DProxy>, arci::Error> {
142 Ok(self.0.new_laser_scan2_d(args.into()).into_result()?.into_option())
143 }
144 pub fn new_localization(
146 &self,
147 args: String,
148 ) -> Result<Option<LocalizationProxy>, arci::Error> {
149 Ok(self.0.new_localization(args.into()).into_result()?.into_option())
150 }
151 pub fn new_motor_drive_position(
153 &self,
154 args: String,
155 ) -> Result<Option<MotorDrivePositionProxy>, arci::Error> {
156 Ok(self.0.new_motor_drive_position(args.into()).into_result()?.into_option())
157 }
158 pub fn new_motor_drive_velocity(
160 &self,
161 args: String,
162 ) -> Result<Option<MotorDriveVelocityProxy>, arci::Error> {
163 Ok(self.0.new_motor_drive_velocity(args.into()).into_result()?.into_option())
164 }
165 pub fn new_motor_drive_effort(
167 &self,
168 args: String,
169 ) -> Result<Option<MotorDriveEffortProxy>, arci::Error> {
170 Ok(self.0.new_motor_drive_effort(args.into()).into_result()?.into_option())
171 }
172 pub fn new_move_base(
174 &self,
175 args: String,
176 ) -> Result<Option<MoveBaseProxy>, arci::Error> {
177 Ok(self.0.new_move_base(args.into()).into_result()?.into_option())
178 }
179 pub fn new_navigation(
181 &self,
182 args: String,
183 ) -> Result<Option<NavigationProxy>, arci::Error> {
184 Ok(self.0.new_navigation(args.into()).into_result()?.into_option())
185 }
186 pub fn new_speaker(
188 &self,
189 args: String,
190 ) -> Result<Option<SpeakerProxy>, arci::Error> {
191 Ok(self.0.new_speaker(args.into()).into_result()?.into_option())
192 }
193 pub fn new_transform_resolver(
195 &self,
196 args: String,
197 ) -> Result<Option<TransformResolverProxy>, arci::Error> {
198 Ok(self.0.new_transform_resolver(args.into()).into_result()?.into_option())
199 }
200}
201#[derive(StableAbi)]
203#[repr(C)]
204pub struct GamepadProxy(pub(crate) crate::proxy::GamepadTraitObject);
205impl GamepadProxy {
206 pub fn new<T>(inner: T) -> Self
208 where
209 T: arci::Gamepad + 'static,
210 {
211 Self(
212 crate::proxy::GamepadTraitObject::from_value(
213 Arc::new(inner),
214 abi_stable::erased_types::TD_Opaque,
215 ),
216 )
217 }
218}
219#[arci::async_trait]
220impl arci::Gamepad for GamepadProxy {
221 async fn next_event(&self) -> GamepadEvent {
222 self.0.next_event().await.into()
223 }
224 fn stop(&self) {
225 self.0.stop().into()
226 }
227}
228impl std::fmt::Debug for GamepadProxy {
229 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
230 f.debug_struct("GamepadProxy").finish()
231 }
232}
233#[derive(StableAbi)]
235#[repr(C)]
236pub struct JointTrajectoryClientProxy(
237 pub(crate) crate::proxy::JointTrajectoryClientTraitObject,
238);
239impl JointTrajectoryClientProxy {
240 pub fn new<T>(inner: T) -> Self
242 where
243 T: arci::JointTrajectoryClient + 'static,
244 {
245 Self(
246 crate::proxy::JointTrajectoryClientTraitObject::from_value(
247 inner,
248 abi_stable::erased_types::TD_Opaque,
249 ),
250 )
251 }
252}
253impl arci::JointTrajectoryClient for JointTrajectoryClientProxy {
254 fn joint_names(&self) -> Vec<String> {
255 self.0.joint_names().into_iter().map(Into::into).collect()
256 }
257 fn current_joint_positions(&self) -> Result<Vec<f64>, Error> {
258 Ok(self.0.current_joint_positions().into_result()?.into())
259 }
260 fn send_joint_positions(
261 &self,
262 positions: Vec<f64>,
263 duration: std::time::Duration,
264 ) -> Result<WaitFuture, Error> {
265 Ok(
266 self
267 .0
268 .send_joint_positions(positions.into(), duration.into())
269 .into_result()?
270 .into(),
271 )
272 }
273 fn send_joint_trajectory(
274 &self,
275 trajectory: Vec<TrajectoryPoint>,
276 ) -> Result<WaitFuture, Error> {
277 Ok(
278 self
279 .0
280 .send_joint_trajectory(trajectory.into_iter().map(Into::into).collect())
281 .into_result()?
282 .into(),
283 )
284 }
285}
286impl std::fmt::Debug for JointTrajectoryClientProxy {
287 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
288 f.debug_struct("JointTrajectoryClientProxy").finish()
289 }
290}
291#[derive(StableAbi)]
293#[repr(C)]
294pub struct LaserScan2DProxy(pub(crate) crate::proxy::LaserScan2DTraitObject);
295impl LaserScan2DProxy {
296 pub fn new<T>(inner: T) -> Self
298 where
299 T: arci::LaserScan2D + 'static,
300 {
301 Self(
302 crate::proxy::LaserScan2DTraitObject::from_value(
303 inner,
304 abi_stable::erased_types::TD_Opaque,
305 ),
306 )
307 }
308}
309impl arci::LaserScan2D for LaserScan2DProxy {
310 fn current_scan(&self) -> Result<Scan2D, Error> {
311 Ok(self.0.current_scan().into_result()?.into())
312 }
313}
314impl std::fmt::Debug for LaserScan2DProxy {
315 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
316 f.debug_struct("LaserScan2DProxy").finish()
317 }
318}
319#[derive(StableAbi)]
321#[repr(C)]
322pub struct LocalizationProxy(pub(crate) crate::proxy::LocalizationTraitObject);
323impl LocalizationProxy {
324 pub fn new<T>(inner: T) -> Self
326 where
327 T: arci::Localization + 'static,
328 {
329 Self(
330 crate::proxy::LocalizationTraitObject::from_value(
331 inner,
332 abi_stable::erased_types::TD_Opaque,
333 ),
334 )
335 }
336}
337impl arci::Localization for LocalizationProxy {
338 fn current_pose(&self, frame_id: &str) -> Result<Isometry2<f64>, Error> {
339 Ok(self.0.current_pose(frame_id.into()).into_result()?.into())
340 }
341}
342impl std::fmt::Debug for LocalizationProxy {
343 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
344 f.debug_struct("LocalizationProxy").finish()
345 }
346}
347#[derive(StableAbi)]
349#[repr(C)]
350pub struct MotorDrivePositionProxy(
351 pub(crate) crate::proxy::MotorDrivePositionTraitObject,
352);
353impl MotorDrivePositionProxy {
354 pub fn new<T>(inner: T) -> Self
356 where
357 T: arci::MotorDrivePosition + 'static,
358 {
359 Self(
360 crate::proxy::MotorDrivePositionTraitObject::from_value(
361 inner,
362 abi_stable::erased_types::TD_Opaque,
363 ),
364 )
365 }
366}
367impl arci::MotorDrivePosition for MotorDrivePositionProxy {
368 fn set_motor_position(&self, position: f64) -> Result<(), Error> {
369 Ok(self.0.set_motor_position(position.into()).into_result()?.into())
370 }
371 fn get_motor_position(&self) -> Result<f64, Error> {
372 Ok(self.0.get_motor_position().into_result()?.into())
373 }
374}
375impl std::fmt::Debug for MotorDrivePositionProxy {
376 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
377 f.debug_struct("MotorDrivePositionProxy").finish()
378 }
379}
380#[derive(StableAbi)]
382#[repr(C)]
383pub struct MotorDriveVelocityProxy(
384 pub(crate) crate::proxy::MotorDriveVelocityTraitObject,
385);
386impl MotorDriveVelocityProxy {
387 pub fn new<T>(inner: T) -> Self
389 where
390 T: arci::MotorDriveVelocity + 'static,
391 {
392 Self(
393 crate::proxy::MotorDriveVelocityTraitObject::from_value(
394 inner,
395 abi_stable::erased_types::TD_Opaque,
396 ),
397 )
398 }
399}
400impl arci::MotorDriveVelocity for MotorDriveVelocityProxy {
401 fn set_motor_velocity(&self, velocity: f64) -> Result<(), Error> {
402 Ok(self.0.set_motor_velocity(velocity.into()).into_result()?.into())
403 }
404 fn get_motor_velocity(&self) -> Result<f64, Error> {
405 Ok(self.0.get_motor_velocity().into_result()?.into())
406 }
407}
408impl std::fmt::Debug for MotorDriveVelocityProxy {
409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
410 f.debug_struct("MotorDriveVelocityProxy").finish()
411 }
412}
413#[derive(StableAbi)]
415#[repr(C)]
416pub struct MotorDriveEffortProxy(pub(crate) crate::proxy::MotorDriveEffortTraitObject);
417impl MotorDriveEffortProxy {
418 pub fn new<T>(inner: T) -> Self
420 where
421 T: arci::MotorDriveEffort + 'static,
422 {
423 Self(
424 crate::proxy::MotorDriveEffortTraitObject::from_value(
425 inner,
426 abi_stable::erased_types::TD_Opaque,
427 ),
428 )
429 }
430}
431impl arci::MotorDriveEffort for MotorDriveEffortProxy {
432 fn set_motor_effort(&self, effort: f64) -> Result<(), Error> {
433 Ok(self.0.set_motor_effort(effort.into()).into_result()?.into())
434 }
435 fn get_motor_effort(&self) -> Result<f64, Error> {
436 Ok(self.0.get_motor_effort().into_result()?.into())
437 }
438}
439impl std::fmt::Debug for MotorDriveEffortProxy {
440 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
441 f.debug_struct("MotorDriveEffortProxy").finish()
442 }
443}
444#[derive(StableAbi)]
446#[repr(C)]
447pub struct MoveBaseProxy(pub(crate) crate::proxy::MoveBaseTraitObject);
448impl MoveBaseProxy {
449 pub fn new<T>(inner: T) -> Self
451 where
452 T: arci::MoveBase + 'static,
453 {
454 Self(
455 crate::proxy::MoveBaseTraitObject::from_value(
456 inner,
457 abi_stable::erased_types::TD_Opaque,
458 ),
459 )
460 }
461}
462impl arci::MoveBase for MoveBaseProxy {
463 fn send_velocity(&self, velocity: &BaseVelocity) -> Result<(), Error> {
464 Ok(self.0.send_velocity((*velocity).into()).into_result()?.into())
465 }
466 fn current_velocity(&self) -> Result<BaseVelocity, Error> {
467 Ok(self.0.current_velocity().into_result()?.into())
468 }
469}
470impl std::fmt::Debug for MoveBaseProxy {
471 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
472 f.debug_struct("MoveBaseProxy").finish()
473 }
474}
475#[derive(StableAbi)]
477#[repr(C)]
478pub struct NavigationProxy(pub(crate) crate::proxy::NavigationTraitObject);
479impl NavigationProxy {
480 pub fn new<T>(inner: T) -> Self
482 where
483 T: arci::Navigation + 'static,
484 {
485 Self(
486 crate::proxy::NavigationTraitObject::from_value(
487 inner,
488 abi_stable::erased_types::TD_Opaque,
489 ),
490 )
491 }
492}
493impl arci::Navigation for NavigationProxy {
494 fn send_goal_pose(
495 &self,
496 goal: Isometry2<f64>,
497 frame_id: &str,
498 timeout: std::time::Duration,
499 ) -> Result<WaitFuture, Error> {
500 Ok(
501 self
502 .0
503 .send_goal_pose(goal.into(), frame_id.into(), timeout.into())
504 .into_result()?
505 .into(),
506 )
507 }
508 fn cancel(&self) -> Result<(), Error> {
509 Ok(self.0.cancel().into_result()?.into())
510 }
511}
512impl std::fmt::Debug for NavigationProxy {
513 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
514 f.debug_struct("NavigationProxy").finish()
515 }
516}
517#[derive(StableAbi)]
519#[repr(C)]
520pub struct SpeakerProxy(pub(crate) crate::proxy::SpeakerTraitObject);
521impl SpeakerProxy {
522 pub fn new<T>(inner: T) -> Self
524 where
525 T: arci::Speaker + 'static,
526 {
527 Self(
528 crate::proxy::SpeakerTraitObject::from_value(
529 inner,
530 abi_stable::erased_types::TD_Opaque,
531 ),
532 )
533 }
534}
535impl arci::Speaker for SpeakerProxy {
536 fn speak(&self, message: &str) -> Result<WaitFuture, Error> {
537 Ok(self.0.speak(message.into()).into_result()?.into())
538 }
539}
540impl std::fmt::Debug for SpeakerProxy {
541 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
542 f.debug_struct("SpeakerProxy").finish()
543 }
544}
545#[derive(StableAbi)]
547#[repr(C)]
548pub struct TransformResolverProxy(pub(crate) crate::proxy::TransformResolverTraitObject);
549impl TransformResolverProxy {
550 pub fn new<T>(inner: T) -> Self
552 where
553 T: arci::TransformResolver + 'static,
554 {
555 Self(
556 crate::proxy::TransformResolverTraitObject::from_value(
557 inner,
558 abi_stable::erased_types::TD_Opaque,
559 ),
560 )
561 }
562}
563impl arci::TransformResolver for TransformResolverProxy {
564 fn resolve_transformation(
565 &self,
566 from: &str,
567 to: &str,
568 time: std::time::SystemTime,
569 ) -> Result<Isometry3<f64>, Error> {
570 Ok(
571 self
572 .0
573 .resolve_transformation(from.into(), to.into(), time.try_into()?)
574 .into_result()?
575 .into(),
576 )
577 }
578}
579impl std::fmt::Debug for TransformResolverProxy {
580 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
581 f.debug_struct("TransformResolverProxy").finish()
582 }
583}