1#![allow(unused_variables)]
5#![allow(clippy::useless_conversion, clippy::unit_arg)]
6
7use arci::{BaseVelocity, Error, Isometry2, Isometry3, WaitFuture};
8use abi_stable::StableAbi;
9use super::*;
10pub trait Plugin: Send + Sync + 'static {
12 fn new_gamepad(
14 &self,
15 args: String,
16 ) -> Result<Option<Box<dyn arci::Gamepad>>, arci::Error> {
17 let _ = args;
18 Ok(None)
19 }
20 fn new_joint_trajectory_client(
22 &self,
23 args: String,
24 ) -> Result<Option<Box<dyn arci::JointTrajectoryClient>>, arci::Error> {
25 let _ = args;
26 Ok(None)
27 }
28 fn new_localization(
30 &self,
31 args: String,
32 ) -> Result<Option<Box<dyn arci::Localization>>, arci::Error> {
33 let _ = args;
34 Ok(None)
35 }
36 fn new_motor_drive_position(
38 &self,
39 args: String,
40 ) -> Result<Option<Box<dyn arci::MotorDrivePosition>>, arci::Error> {
41 let _ = args;
42 Ok(None)
43 }
44 fn new_motor_drive_velocity(
46 &self,
47 args: String,
48 ) -> Result<Option<Box<dyn arci::MotorDriveVelocity>>, arci::Error> {
49 let _ = args;
50 Ok(None)
51 }
52 fn new_motor_drive_effort(
54 &self,
55 args: String,
56 ) -> Result<Option<Box<dyn arci::MotorDriveEffort>>, arci::Error> {
57 let _ = args;
58 Ok(None)
59 }
60 fn new_move_base(
62 &self,
63 args: String,
64 ) -> Result<Option<Box<dyn arci::MoveBase>>, arci::Error> {
65 let _ = args;
66 Ok(None)
67 }
68 fn new_navigation(
70 &self,
71 args: String,
72 ) -> Result<Option<Box<dyn arci::Navigation>>, arci::Error> {
73 let _ = args;
74 Ok(None)
75 }
76 fn new_speaker(
78 &self,
79 args: String,
80 ) -> Result<Option<Box<dyn arci::Speaker>>, arci::Error> {
81 let _ = args;
82 Ok(None)
83 }
84 fn new_transform_resolver(
86 &self,
87 args: String,
88 ) -> Result<Option<Box<dyn arci::TransformResolver>>, arci::Error> {
89 let _ = args;
90 Ok(None)
91 }
92}
93#[derive(StableAbi)]
95#[repr(C)]
96pub struct PluginProxy(pub(crate) crate::proxy::PluginTraitObject);
97impl PluginProxy {
98 pub fn new<T>(inner: T) -> Self
100 where
101 T: Plugin + 'static,
102 {
103 Self(
104 crate::proxy::PluginTraitObject::from_value(
105 inner,
106 abi_stable::erased_types::TD_Opaque,
107 ),
108 )
109 }
110}
111impl PluginProxy {
112 pub fn new_gamepad(
114 &self,
115 args: String,
116 ) -> Result<Option<GamepadProxy>, arci::Error> {
117 Ok(self.0.new_gamepad(args.into()).into_result()?.into_option())
118 }
119 pub fn new_joint_trajectory_client(
121 &self,
122 args: String,
123 ) -> Result<Option<JointTrajectoryClientProxy>, arci::Error> {
124 Ok(self.0.new_joint_trajectory_client(args.into()).into_result()?.into_option())
125 }
126 pub fn new_localization(
128 &self,
129 args: String,
130 ) -> Result<Option<LocalizationProxy>, arci::Error> {
131 Ok(self.0.new_localization(args.into()).into_result()?.into_option())
132 }
133 pub fn new_motor_drive_position(
135 &self,
136 args: String,
137 ) -> Result<Option<MotorDrivePositionProxy>, arci::Error> {
138 Ok(self.0.new_motor_drive_position(args.into()).into_result()?.into_option())
139 }
140 pub fn new_motor_drive_velocity(
142 &self,
143 args: String,
144 ) -> Result<Option<MotorDriveVelocityProxy>, arci::Error> {
145 Ok(self.0.new_motor_drive_velocity(args.into()).into_result()?.into_option())
146 }
147 pub fn new_motor_drive_effort(
149 &self,
150 args: String,
151 ) -> Result<Option<MotorDriveEffortProxy>, arci::Error> {
152 Ok(self.0.new_motor_drive_effort(args.into()).into_result()?.into_option())
153 }
154 pub fn new_move_base(
156 &self,
157 args: String,
158 ) -> Result<Option<MoveBaseProxy>, arci::Error> {
159 Ok(self.0.new_move_base(args.into()).into_result()?.into_option())
160 }
161 pub fn new_navigation(
163 &self,
164 args: String,
165 ) -> Result<Option<NavigationProxy>, arci::Error> {
166 Ok(self.0.new_navigation(args.into()).into_result()?.into_option())
167 }
168 pub fn new_speaker(
170 &self,
171 args: String,
172 ) -> Result<Option<SpeakerProxy>, arci::Error> {
173 Ok(self.0.new_speaker(args.into()).into_result()?.into_option())
174 }
175 pub fn new_transform_resolver(
177 &self,
178 args: String,
179 ) -> Result<Option<TransformResolverProxy>, arci::Error> {
180 Ok(self.0.new_transform_resolver(args.into()).into_result()?.into_option())
181 }
182}
183#[derive(StableAbi)]
185#[repr(C)]
186pub struct LocalizationProxy(pub(crate) crate::proxy::LocalizationTraitObject);
187impl LocalizationProxy {
188 pub fn new<T>(inner: T) -> Self
190 where
191 T: arci::Localization + 'static,
192 {
193 Self(
194 crate::proxy::LocalizationTraitObject::from_value(
195 inner,
196 abi_stable::erased_types::TD_Opaque,
197 ),
198 )
199 }
200}
201impl arci::Localization for LocalizationProxy {
202 fn current_pose(&self, frame_id: &str) -> Result<Isometry2<f64>, Error> {
203 Ok(self.0.current_pose(frame_id.into()).into_result()?.into())
204 }
205}
206impl std::fmt::Debug for LocalizationProxy {
207 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
208 f.debug_struct("LocalizationProxy").finish()
209 }
210}
211#[derive(StableAbi)]
213#[repr(C)]
214pub struct MotorDrivePositionProxy(
215 pub(crate) crate::proxy::MotorDrivePositionTraitObject,
216);
217impl MotorDrivePositionProxy {
218 pub fn new<T>(inner: T) -> Self
220 where
221 T: arci::MotorDrivePosition + 'static,
222 {
223 Self(
224 crate::proxy::MotorDrivePositionTraitObject::from_value(
225 inner,
226 abi_stable::erased_types::TD_Opaque,
227 ),
228 )
229 }
230}
231impl arci::MotorDrivePosition for MotorDrivePositionProxy {
232 fn set_motor_position(&self, position: f64) -> Result<(), Error> {
233 Ok(self.0.set_motor_position(position.into()).into_result()?.into())
234 }
235 fn get_motor_position(&self) -> Result<f64, Error> {
236 Ok(self.0.get_motor_position().into_result()?.into())
237 }
238}
239impl std::fmt::Debug for MotorDrivePositionProxy {
240 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
241 f.debug_struct("MotorDrivePositionProxy").finish()
242 }
243}
244#[derive(StableAbi)]
246#[repr(C)]
247pub struct MotorDriveVelocityProxy(
248 pub(crate) crate::proxy::MotorDriveVelocityTraitObject,
249);
250impl MotorDriveVelocityProxy {
251 pub fn new<T>(inner: T) -> Self
253 where
254 T: arci::MotorDriveVelocity + 'static,
255 {
256 Self(
257 crate::proxy::MotorDriveVelocityTraitObject::from_value(
258 inner,
259 abi_stable::erased_types::TD_Opaque,
260 ),
261 )
262 }
263}
264impl arci::MotorDriveVelocity for MotorDriveVelocityProxy {
265 fn set_motor_velocity(&self, velocity: f64) -> Result<(), Error> {
266 Ok(self.0.set_motor_velocity(velocity.into()).into_result()?.into())
267 }
268 fn get_motor_velocity(&self) -> Result<f64, Error> {
269 Ok(self.0.get_motor_velocity().into_result()?.into())
270 }
271}
272impl std::fmt::Debug for MotorDriveVelocityProxy {
273 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
274 f.debug_struct("MotorDriveVelocityProxy").finish()
275 }
276}
277#[derive(StableAbi)]
279#[repr(C)]
280pub struct MotorDriveEffortProxy(pub(crate) crate::proxy::MotorDriveEffortTraitObject);
281impl MotorDriveEffortProxy {
282 pub fn new<T>(inner: T) -> Self
284 where
285 T: arci::MotorDriveEffort + 'static,
286 {
287 Self(
288 crate::proxy::MotorDriveEffortTraitObject::from_value(
289 inner,
290 abi_stable::erased_types::TD_Opaque,
291 ),
292 )
293 }
294}
295impl arci::MotorDriveEffort for MotorDriveEffortProxy {
296 fn set_motor_effort(&self, effort: f64) -> Result<(), Error> {
297 Ok(self.0.set_motor_effort(effort.into()).into_result()?.into())
298 }
299 fn get_motor_effort(&self) -> Result<f64, Error> {
300 Ok(self.0.get_motor_effort().into_result()?.into())
301 }
302}
303impl std::fmt::Debug for MotorDriveEffortProxy {
304 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
305 f.debug_struct("MotorDriveEffortProxy").finish()
306 }
307}
308#[derive(StableAbi)]
310#[repr(C)]
311pub struct MoveBaseProxy(pub(crate) crate::proxy::MoveBaseTraitObject);
312impl MoveBaseProxy {
313 pub fn new<T>(inner: T) -> Self
315 where
316 T: arci::MoveBase + 'static,
317 {
318 Self(
319 crate::proxy::MoveBaseTraitObject::from_value(
320 inner,
321 abi_stable::erased_types::TD_Opaque,
322 ),
323 )
324 }
325}
326impl arci::MoveBase for MoveBaseProxy {
327 fn send_velocity(&self, velocity: &BaseVelocity) -> Result<(), Error> {
328 Ok(self.0.send_velocity((*velocity).into()).into_result()?.into())
329 }
330 fn current_velocity(&self) -> Result<BaseVelocity, Error> {
331 Ok(self.0.current_velocity().into_result()?.into())
332 }
333}
334impl std::fmt::Debug for MoveBaseProxy {
335 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
336 f.debug_struct("MoveBaseProxy").finish()
337 }
338}
339#[derive(StableAbi)]
341#[repr(C)]
342pub struct NavigationProxy(pub(crate) crate::proxy::NavigationTraitObject);
343impl NavigationProxy {
344 pub fn new<T>(inner: T) -> Self
346 where
347 T: arci::Navigation + 'static,
348 {
349 Self(
350 crate::proxy::NavigationTraitObject::from_value(
351 inner,
352 abi_stable::erased_types::TD_Opaque,
353 ),
354 )
355 }
356}
357impl arci::Navigation for NavigationProxy {
358 fn send_goal_pose(
359 &self,
360 goal: Isometry2<f64>,
361 frame_id: &str,
362 timeout: std::time::Duration,
363 ) -> Result<WaitFuture, Error> {
364 Ok(
365 self
366 .0
367 .send_goal_pose(goal.into(), frame_id.into(), timeout.into())
368 .into_result()?
369 .into(),
370 )
371 }
372 fn cancel(&self) -> Result<(), Error> {
373 Ok(self.0.cancel().into_result()?.into())
374 }
375}
376impl std::fmt::Debug for NavigationProxy {
377 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
378 f.debug_struct("NavigationProxy").finish()
379 }
380}
381#[derive(StableAbi)]
383#[repr(C)]
384pub struct SpeakerProxy(pub(crate) crate::proxy::SpeakerTraitObject);
385impl SpeakerProxy {
386 pub fn new<T>(inner: T) -> Self
388 where
389 T: arci::Speaker + 'static,
390 {
391 Self(
392 crate::proxy::SpeakerTraitObject::from_value(
393 inner,
394 abi_stable::erased_types::TD_Opaque,
395 ),
396 )
397 }
398}
399impl arci::Speaker for SpeakerProxy {
400 fn speak(&self, message: &str) -> Result<WaitFuture, Error> {
401 Ok(self.0.speak(message.into()).into_result()?.into())
402 }
403}
404impl std::fmt::Debug for SpeakerProxy {
405 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
406 f.debug_struct("SpeakerProxy").finish()
407 }
408}
409#[derive(StableAbi)]
411#[repr(C)]
412pub struct TransformResolverProxy(pub(crate) crate::proxy::TransformResolverTraitObject);
413impl TransformResolverProxy {
414 pub fn new<T>(inner: T) -> Self
416 where
417 T: arci::TransformResolver + 'static,
418 {
419 Self(
420 crate::proxy::TransformResolverTraitObject::from_value(
421 inner,
422 abi_stable::erased_types::TD_Opaque,
423 ),
424 )
425 }
426}
427impl arci::TransformResolver for TransformResolverProxy {
428 fn resolve_transformation(
429 &self,
430 from: &str,
431 to: &str,
432 time: std::time::SystemTime,
433 ) -> Result<Isometry3<f64>, Error> {
434 Ok(
435 self
436 .0
437 .resolve_transformation(from.into(), to.into(), time.try_into()?)
438 .into_result()?
439 .into(),
440 )
441 }
442}
443impl std::fmt::Debug for TransformResolverProxy {
444 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
445 f.debug_struct("TransformResolverProxy").finish()
446 }
447}