Skip to content

Commit 295abcc

Browse files
add external controller executor
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
1 parent c453173 commit 295abcc

File tree

15 files changed

+1009
-0
lines changed

15 files changed

+1009
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(external_controller_executor)
3+
4+
find_package(autoware_cmake REQUIRED)
5+
autoware_package()
6+
7+
set(LATERAL_CONTROLLER_PERFORMANCE_ANALYZER_NODE external_controller_executor_node)
8+
ament_auto_add_library(${LATERAL_CONTROLLER_PERFORMANCE_ANALYZER_NODE} SHARED
9+
include/trajectory_follower_node/controller_node.hpp
10+
src/controller_node.cpp
11+
)
12+
13+
rclcpp_components_register_node(${LATERAL_CONTROLLER_PERFORMANCE_ANALYZER_NODE}
14+
PLUGIN "autoware::motion::control::trajectory_follower_node::Controller"
15+
EXECUTABLE ${LATERAL_CONTROLLER_PERFORMANCE_ANALYZER_NODE}_exe
16+
)
17+
18+
ament_auto_package(
19+
INSTALL_TO_SHARE
20+
param
21+
launch
22+
config
23+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Trajectory Follower Nodes
2+
3+
## Purpose
4+
5+
Generate control commands to follow a given Trajectory.
6+
7+
## Design
8+
9+
This is a node of the functionalities implemented in the controller class derived from [trajectory_follower_base](../trajectory_follower_base/README.md#trajectory-follower) package. It has instances of those functionalities, gives them input data to perform calculations, and publishes control commands.
10+
11+
By default, the controller instance with the `Controller` class as follows is used.
12+
13+
```plantuml
14+
@startuml
15+
package trajectory_follower_base {
16+
abstract class LateralControllerBase {
17+
longitudinal_sync_data_
18+
19+
virtual isReady(InputData)
20+
virtual run(InputData)
21+
sync(LongitudinalSyncData)
22+
reset()
23+
24+
}
25+
abstract class LongitudinalControllerBase {
26+
lateral_sync_data_
27+
28+
virtual isReady(InputData)
29+
virtual run(InputData)
30+
sync(LateralSyncData)
31+
reset()
32+
33+
}
34+
35+
struct InputData {
36+
trajectory
37+
odometry
38+
steering
39+
accel
40+
}
41+
struct LongitudinalSyncData {
42+
is_steer_converged
43+
}
44+
struct LateralSyncData {
45+
}
46+
}
47+
48+
package mpc_lateral_controller {
49+
class MPCLateralController {
50+
isReady(InputData) override
51+
run(InputData) override
52+
}
53+
}
54+
package pure_pursuit {
55+
class PurePursuitLateralController {
56+
isReady(InputData) override
57+
run(InputData) override
58+
}
59+
}
60+
package pid_longitudinal_controller {
61+
class PIDLongitudinalController {
62+
isReady(InputData) override
63+
run(InputData) override
64+
}
65+
}
66+
67+
package trajectory_follower_node {
68+
class Controller {
69+
longitudinal_controller_
70+
lateral_controller_
71+
onTimer()
72+
createInputData(): InputData
73+
}
74+
}
75+
76+
MPCLateralController --|> LateralControllerBase
77+
PurePursuitLateralController --|> LateralControllerBase
78+
PIDLongitudinalController --|> LongitudinalControllerBase
79+
80+
LateralSyncData --> LongitudinalControllerBase
81+
LateralSyncData --> LateralControllerBase
82+
LongitudinalSyncData --> LongitudinalControllerBase
83+
LongitudinalSyncData --> LateralControllerBase
84+
InputData ..> LateralControllerBase
85+
InputData ..> LongitudinalControllerBase
86+
87+
LateralControllerBase --o Controller
88+
LongitudinalControllerBase --o Controller
89+
InputData ..> Controller
90+
@enduml
91+
```
92+
93+
The process flow of `Controller` class is as follows.
94+
95+
```cpp
96+
// 1. create input data
97+
const auto input_data = createInputData(*get_clock());
98+
if (!input_data) {
99+
return;
100+
}
101+
102+
// 2. check if controllers are ready
103+
const bool is_lat_ready = lateral_controller_->isReady(*input_data);
104+
const bool is_lon_ready = longitudinal_controller_->isReady(*input_data);
105+
if (!is_lat_ready || !is_lon_ready) {
106+
return;
107+
}
108+
109+
// 3. run controllers
110+
const auto lat_out = lateral_controller_->run(*input_data);
111+
const auto lon_out = longitudinal_controller_->run(*input_data);
112+
113+
// 4. sync with each other controllers
114+
longitudinal_controller_->sync(lat_out.sync_data);
115+
lateral_controller_->sync(lon_out.sync_data);
116+
117+
// 5. publish control command
118+
control_cmd_pub_->publish(out);
119+
```
120+
121+
Giving the longitudinal controller information about steer convergence allows it to control steer when stopped if following parameters are `true`
122+
123+
- lateral controller
124+
- `keep_steer_control_until_converged`
125+
- longitudinal controller
126+
- `enable_keep_stopped_until_steer_convergence`
127+
128+
### Inputs / Outputs / API
129+
130+
#### Inputs
131+
132+
- `autoware_auto_planning_msgs/Trajectory` : reference trajectory to follow.
133+
- `nav_msgs/Odometry`: current odometry
134+
- `autoware_auto_vehicle_msgs/SteeringReport` current steering
135+
136+
#### Outputs
137+
138+
- `autoware_auto_control_msgs/AckermannControlCommand`: message containing both lateral and longitudinal commands.
139+
140+
#### Parameter
141+
142+
- `ctrl_period`: control commands publishing period
143+
- `timeout_thr_sec`: duration in second after which input messages are discarded.
144+
- Each time the node receives lateral and longitudinal commands from each controller, it publishes an `AckermannControlCommand` if the following two conditions are met.
145+
1. Both commands have been received.
146+
2. The last received commands are not older than defined by `timeout_thr_sec`.
147+
- `lateral_controller_mode`: `mpc` or `pure_pursuit`
148+
- (currently there is only `PID` for longitudinal controller)
149+
150+
## Debugging
151+
152+
Debug information are published by the lateral and longitudinal controller using `tier4_debug_msgs/Float32MultiArrayStamped` messages.
153+
154+
A configuration file for [PlotJuggler](https://github.com/facontidavide/PlotJuggler) is provided in the `config` folder which, when loaded, allow to automatically subscribe and visualize information useful for debugging.
155+
156+
In addition, the predicted MPC trajectory is published on topic `output/lateral/predicted_trajectory` and can be visualized in Rviz.

0 commit comments

Comments
 (0)