File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
examples/minimal_action_server/src Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,36 @@ fn handle_cancel(_goal_handle: Arc<GoalHandleFibonacci>) -> rclrs::CancelRespons
2626
2727fn execute ( goal_handle : Arc < GoalHandleFibonacci > ) {
2828 println ! ( "Executing goal" ) ;
29- thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
29+ let feedback = example_interfaces:: action:: Fibonacci_Feedback {
30+ sequence : Vec :: new ( ) ,
31+ } ;
32+ feedback. sequence . push ( 0 ) ;
33+ feedback. sequence . push ( 1 ) ;
34+ let result = example_interfaces:: action:: Fibonacci_Result {
35+ sequence : Vec :: new ( ) ,
36+ } ;
37+
38+ let mut i = 1 ;
39+ while i < goal_handle. goal ( ) . unwrap ( ) . order && rclrs:: ok ( ) {
40+ if goal_handle. is_canceling ( ) {
41+ result. sequence = feedback. sequence . clone ( ) ;
42+ goal_handle. canceled ( & result) ;
43+ println ! ( "Goal canceled" ) ;
44+ return ;
45+ }
46+ // Update sequence
47+ feedback. sequence . push ( feedback. sequence [ i as usize ] + feedback. sequence [ ( i - 1 ) as usize ] ) ;
48+ // Publish feedback
49+ goal_handle. publish_feedback ( & feedback) ;
50+ println ! ( "Publishing feedback" ) ;
51+ thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
52+ }
53+ // Check if goal is done
54+ if rclrs:: ok ( ) {
55+ result. sequence = feedback. sequence . clone ( ) ;
56+ goal_handle. succeed ( & result) ;
57+ println ! ( "Goal succeeded" ) ;
58+ }
3059}
3160
3261fn handle_accepted ( goal_handle : Arc < GoalHandleFibonacci > ) {
Original file line number Diff line number Diff line change @@ -80,15 +80,15 @@ where
8080{
8181 pub ( crate ) fn new ( rcl_handle : Arc < rcl_action_goal_handle_t > ) { }
8282
83- pub ( crate ) fn is_canceling ( ) -> bool {
83+ pub ( crate ) fn is_canceling ( & self ) -> bool {
8484 false
8585 }
8686
87- pub ( crate ) fn is_active ( ) -> bool {
87+ pub ( crate ) fn is_active ( & self ) -> bool {
8888 false
8989 }
9090
91- pub ( crate ) fn is_executing ( ) -> bool {
91+ pub ( crate ) fn is_executing ( & self ) -> bool {
9292 false
9393 }
9494}
You can’t perform that action at this time.
0 commit comments