@@ -13,8 +13,9 @@ pub use self::builder::*;
13
13
pub use self :: graph:: * ;
14
14
use crate :: rcl_bindings:: * ;
15
15
use crate :: {
16
- ActionClient , Client , ClientBase , Context , GuardCondition , ParameterOverrideMap , Publisher ,
17
- QoSProfile , RclrsError , Service , ServiceBase , Subscription , SubscriptionBase ,
16
+ ActionClient , ActionServer , CancelResponse , Client , ClientBase , Context ,
17
+ GoalResponse , GoalUUID , GuardCondition , ParameterOverrideMap , Publisher , QoSProfile ,
18
+ RclrsError , ServerGoalHandle , Service , ServiceBase , Subscription , SubscriptionBase ,
18
19
SubscriptionCallback , ToResult ,
19
20
} ;
20
21
@@ -189,7 +190,7 @@ impl Node {
189
190
Ok ( client)
190
191
}
191
192
192
- /// Creates a [`Client `][1].
193
+ /// Creates an [`ActionClient `][1].
193
194
///
194
195
/// [1]: crate::ActionClient
195
196
// TODO: make action client's lifetime depend on node's lifetime
@@ -200,13 +201,36 @@ impl Node {
200
201
where
201
202
T : rosidl_runtime_rs:: Action ,
202
203
{
203
- let client = Arc :: new ( ActionClient :: < T > :: new (
204
+ let action_client = Arc :: new ( ActionClient :: < T > :: new (
204
205
Arc :: clone ( & self . rcl_node_mtx ) ,
205
206
topic,
206
207
) ?) ;
207
208
// self.clients
208
209
// .push(Arc::downgrade(&client) as Weak<dyn ClientBase>);
209
- Ok ( client)
210
+ Ok ( action_client)
211
+ }
212
+
213
+ /// Creates an [`ActionServer`][1].
214
+ ///
215
+ /// [1]: crate::ActionServer
216
+ // TODO: make action server's lifetime depend on node's lifetime
217
+ pub fn create_action_server < T > (
218
+ & mut self ,
219
+ topic : & str ,
220
+ handle_goal : fn ( & crate :: action:: GoalUUID , Arc < T :: Goal > ) -> GoalResponse ,
221
+ handle_cancel : fn ( Arc < ServerGoalHandle < T > > ) -> CancelResponse ,
222
+ handle_accepted : fn ( Arc < ServerGoalHandle < T > > ) ,
223
+ ) -> Result < Arc < ActionServer < T > > , RclrsError >
224
+ where
225
+ T : rosidl_runtime_rs:: Action ,
226
+ {
227
+ let action_server = Arc :: new ( ActionServer :: < T > :: new (
228
+ Arc :: clone ( & self . rcl_node_mtx ) ,
229
+ topic,
230
+ ) ?) ;
231
+ // self.servers
232
+ // .push(Arc::downgrade(&server) as Weak<dyn ClientBase>);
233
+ Ok ( action_server)
210
234
}
211
235
212
236
/// Creates a [`GuardCondition`][1] with no callback.
0 commit comments