File tree 2 files changed +33
-4
lines changed
examples/minimal_action_server/src
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
26
26
27
27
fn execute ( goal_handle : Arc < GoalHandleFibonacci > ) {
28
28
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
+ }
30
59
}
31
60
32
61
fn handle_accepted ( goal_handle : Arc < GoalHandleFibonacci > ) {
Original file line number Diff line number Diff line change @@ -80,15 +80,15 @@ where
80
80
{
81
81
pub ( crate ) fn new ( rcl_handle : Arc < rcl_action_goal_handle_t > ) { }
82
82
83
- pub ( crate ) fn is_canceling ( ) -> bool {
83
+ pub ( crate ) fn is_canceling ( & self ) -> bool {
84
84
false
85
85
}
86
86
87
- pub ( crate ) fn is_active ( ) -> bool {
87
+ pub ( crate ) fn is_active ( & self ) -> bool {
88
88
false
89
89
}
90
90
91
- pub ( crate ) fn is_executing ( ) -> bool {
91
+ pub ( crate ) fn is_executing ( & self ) -> bool {
92
92
false
93
93
}
94
94
}
You can’t perform that action at this time.
0 commit comments