@@ -13,9 +13,10 @@ pub use self::builder::*;
1313pub use self :: graph:: * ;
1414use crate :: rcl_bindings:: * ;
1515use crate :: {
16- ActionClient , Client , ClientBase , Clock , Context , GuardCondition , ParameterBuilder ,
17- ParameterInterface , ParameterVariant , Parameters , Publisher , QoSProfile , RclrsError , Service ,
18- ServiceBase , Subscription , SubscriptionBase , SubscriptionCallback , TimeSource , ToResult ,
16+ ActionClient , ActionServer , CancelResponse , Client , ClientBase , Clock , Context , GoalResponse ,
17+ GoalUUID , GuardCondition , ParameterInterface , ParameterVariant , Parameters , Publisher ,
18+ QoSProfile , RclrsError , ServerGoalHandle , Service , ServiceBase , Subscription , SubscriptionBase ,
19+ SubscriptionCallback , TimeSource , ToResult ,
1920} ;
2021
2122impl Drop for rcl_node_t {
@@ -195,7 +196,7 @@ impl Node {
195196 Ok ( client)
196197 }
197198
198- /// Creates a [`Client `][1].
199+ /// Creates an [`ActionClient `][1].
199200 ///
200201 /// [1]: crate::ActionClient
201202 // TODO: make action client's lifetime depend on node's lifetime
@@ -206,13 +207,36 @@ impl Node {
206207 where
207208 T : rosidl_runtime_rs:: Action ,
208209 {
209- let client = Arc :: new ( ActionClient :: < T > :: new (
210+ let action_client = Arc :: new ( ActionClient :: < T > :: new (
210211 Arc :: clone ( & self . rcl_node_mtx ) ,
211212 topic,
212213 ) ?) ;
213214 // self.clients
214215 // .push(Arc::downgrade(&client) as Weak<dyn ClientBase>);
215- Ok ( client)
216+ Ok ( action_client)
217+ }
218+
219+ /// Creates an [`ActionServer`][1].
220+ ///
221+ /// [1]: crate::ActionServer
222+ // TODO: make action server's lifetime depend on node's lifetime
223+ pub fn create_action_server < T > (
224+ & mut self ,
225+ topic : & str ,
226+ handle_goal : fn ( & crate :: action:: GoalUUID , Arc < T :: Goal > ) -> GoalResponse ,
227+ handle_cancel : fn ( Arc < ServerGoalHandle < T > > ) -> CancelResponse ,
228+ handle_accepted : fn ( Arc < ServerGoalHandle < T > > ) ,
229+ ) -> Result < Arc < ActionServer < T > > , RclrsError >
230+ where
231+ T : rosidl_runtime_rs:: Action ,
232+ {
233+ let action_server = Arc :: new ( ActionServer :: < T > :: new (
234+ Arc :: clone ( & self . rcl_node_mtx ) ,
235+ topic,
236+ ) ?) ;
237+ // self.servers
238+ // .push(Arc::downgrade(&server) as Weak<dyn ClientBase>);
239+ Ok ( action_server)
216240 }
217241
218242 /// Creates a [`GuardCondition`][1] with no callback.
0 commit comments