@@ -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
@@ -189,7 +190,7 @@ impl Node {
189190 Ok ( client)
190191 }
191192
192- /// Creates a [`Client `][1].
193+ /// Creates an [`ActionClient `][1].
193194 ///
194195 /// [1]: crate::ActionClient
195196 // TODO: make action client's lifetime depend on node's lifetime
@@ -200,13 +201,36 @@ impl Node {
200201 where
201202 T : rosidl_runtime_rs:: Action ,
202203 {
203- let client = Arc :: new ( ActionClient :: < T > :: new (
204+ let action_client = Arc :: new ( ActionClient :: < T > :: new (
204205 Arc :: clone ( & self . rcl_node_mtx ) ,
205206 topic,
206207 ) ?) ;
207208 // self.clients
208209 // .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)
210234 }
211235
212236 /// Creates a [`GuardCondition`][1] with no callback.
0 commit comments