@@ -13,8 +13,9 @@ pub use self::builder::*;
1313pub use self :: graph:: * ;
1414use crate :: rcl_bindings:: * ;
1515use 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 ,
1819 SubscriptionCallback , ToResult ,
1920} ;
2021
@@ -190,7 +191,7 @@ impl Node {
190191 Ok ( client)
191192 }
192193
193- /// Creates a [`Client `][1].
194+ /// Creates an [`ActionClient `][1].
194195 ///
195196 /// [1]: crate::ActionClient
196197 // TODO: make action client's lifetime depend on node's lifetime
@@ -201,13 +202,36 @@ impl Node {
201202 where
202203 T : rosidl_runtime_rs:: Action ,
203204 {
204- let client = Arc :: new ( ActionClient :: < T > :: new (
205+ let action_client = Arc :: new ( ActionClient :: < T > :: new (
205206 Arc :: clone ( & self . rcl_node_mtx ) ,
206207 topic,
207208 ) ?) ;
208209 // self.clients
209210 // .push(Arc::downgrade(&client) as Weak<dyn ClientBase>);
210- Ok ( client)
211+ Ok ( action_client)
212+ }
213+
214+ /// Creates an [`ActionServer`][1].
215+ ///
216+ /// [1]: crate::ActionServer
217+ // TODO: make action server's lifetime depend on node's lifetime
218+ pub fn create_action_server < T > (
219+ & mut self ,
220+ topic : & str ,
221+ handle_goal : fn ( & crate :: action:: GoalUUID , Arc < T :: Goal > ) -> GoalResponse ,
222+ handle_cancel : fn ( Arc < ServerGoalHandle < T > > ) -> CancelResponse ,
223+ handle_accepted : fn ( Arc < ServerGoalHandle < T > > ) ,
224+ ) -> Result < Arc < ActionServer < T > > , RclrsError >
225+ where
226+ T : rosidl_runtime_rs:: Action ,
227+ {
228+ let action_server = Arc :: new ( ActionServer :: < T > :: new (
229+ Arc :: clone ( & self . rcl_node_mtx ) ,
230+ topic,
231+ ) ?) ;
232+ // self.servers
233+ // .push(Arc::downgrade(&server) as Weak<dyn ClientBase>);
234+ Ok ( action_server)
211235 }
212236
213237 /// Creates a [`GuardCondition`][1] with no callback.
0 commit comments