Commit 29c3ef4
refactor(autoware_command_gate): extract ROS-free mode dispatch helper (#1145)
* refactor(autoware_command_gate): extract ROS-free mode dispatch helper
Move the request-to-mode dispatch (switch on the requested operation mode and
build the corresponding outputs) out of the node's service-callback lambda into a
ROS-free static helper CommandGateModeBuilder::dispatch_mode, which returns
std::optional<ModeOutputs> (std::nullopt for unknown/unsupported modes).
This makes the dispatch and its only error path (unknown mode -> PARAMETER_ERROR)
unit-testable with plain gtest, without spinning up rclcpp. Behavior is preserved:
the node still publishes outputs and sets status.success/code/message on the happy
path, and emits success=false with PARAMETER_ERROR on an unknown mode.
Add unit tests for dispatch_mode covering all four valid modes and the previously
untested unknown-mode nullopt branch.
The public node API is unchanged; dispatch_mode is an additive static method.
Refs: #1096
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
* refactor(autoware_command_gate): address review feedback
Move autoware_system_msgs/srv/change_operation_mode include from the
builder header to the .cpp where ChangeOperationMode::Request is used,
decoupling includers from the service definition.
Assert stamp propagation in DispatchModeAutonomous/Local/Remote tests
by passing non-zero stamps and checking outputs->state.stamp.
Refs: #1096
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
* refactor(autoware_command_gate): split mode-output and response builders (#80)
Make the ChangeOperationMode service callback route through two pure
message-in -> message-out builders: create_mode_output() builds the
messages to publish (std::nullopt for unknown modes) and create_response()
builds the service response. Both are ROS-node-free static functions that
take the request, so they are unit-testable in isolation. Behavior is
preserved; the publish-only ModeOutputs no longer carries response status.
Refs: #1096
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
---------
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Co-authored-by: Junya Sasaki <j2sasaki1990@gmail.com>1 parent 45af260 commit 29c3ef4
5 files changed
Lines changed: 252 additions & 68 deletions
File tree
- control/autoware_command_gate
- src
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
Lines changed: 4 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| |||
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
100 | 81 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 82 | + | |
106 | 83 | | |
107 | 84 | | |
108 | 85 | | |
| |||
121 | 98 | | |
122 | 99 | | |
123 | 100 | | |
124 | | - | |
125 | 101 | | |
126 | 102 | | |
127 | 103 | | |
| |||
Lines changed: 60 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
22 | 82 | | |
23 | 83 | | |
24 | 84 | | |
25 | 85 | | |
26 | 86 | | |
27 | | - | |
28 | 87 | | |
29 | 88 | | |
30 | 89 | | |
| |||
33 | 92 | | |
34 | 93 | | |
35 | 94 | | |
36 | | - | |
37 | 95 | | |
38 | 96 | | |
39 | 97 | | |
| |||
42 | 100 | | |
43 | 101 | | |
44 | 102 | | |
45 | | - | |
46 | 103 | | |
47 | 104 | | |
48 | 105 | | |
| |||
51 | 108 | | |
52 | 109 | | |
53 | 110 | | |
54 | | - | |
55 | 111 | | |
56 | 112 | | |
57 | 113 | | |
| |||
78 | 134 | | |
79 | 135 | | |
80 | 136 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 137 | | |
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
39 | 59 | | |
40 | 60 | | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
44 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
45 | 72 | | |
46 | 73 | | |
47 | 74 | | |
48 | 75 | | |
49 | 76 | | |
50 | 77 | | |
51 | | - | |
52 | 78 | | |
53 | 79 | | |
54 | 80 | | |
| |||
0 commit comments