Skip to content

Commit 7103a8c

Browse files
brkay54Berkay Karaman
authored and
Berkay Karaman
committed
feat: update for new sensor setup, fix bug, optimize code, show pipeline latency, update readme
Signed-off-by: Berkay Karaman <berkay@leodrive.ai>
1 parent b2b71aa commit 7103a8c

12 files changed

+109
-170
lines changed

tools/reaction_analyzer/README.md

+47-28
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,28 @@ start to test. After the test is completed, the results will be stored in the `o
7676
#### Perception Planning Mode
7777

7878
- Download the rosbag files from the Google Drive
79-
link [here](https://drive.google.com/file/d/1_P-3oy_M6eJ7fk8h5CP8V6s6da6pPrBu/view?usp=sharing).
79+
link [here](https://drive.google.com/file/d/1-Qcv7gYfR-usKOjUH8I997w8I4NMhXlX/view?usp=sharing).
8080
- Extract the zip file and set the path of the `.db3` files to parameters `path_bag_without_object`
8181
and `path_bag_with_object`.
82-
- Because custom sensor setup, you need to check out the following branches before launch the
83-
reaction analyzer: For the `autoware_individual_params` repository, check out the
84-
branch [here](https://github.com/brkay54/autoware_individual_params/tree/bk/reaction-analyzer-config).
85-
- For the `awsim_sensor_kit_launch` repository, check out the
86-
branch [here](https://github.com/brkay54/awsim_sensor_kit_launch/tree/bk/reaction-analyzer-config).
87-
- After you check outed the branches, you can start to test with the following command:
82+
- You can start to test with the following command:
8883

8984
```bash
90-
ros2 launch reaction_analyzer reaction_analyzer.launch.xml running_mode:=perception_planning vehicle_model:=sample_vehicle sensor_model:=awsim_sensor_kit map_path:=[MAP_PATH]
85+
ros2 launch reaction_analyzer reaction_analyzer.launch.xml running_mode:=perception_planning vehicle_model:=sample_vehicle sensor_model:=awsim_labs_sensor_kit map_path:=[MAP_PATH]
9186
```
9287

9388
After the command, the `e2e_simulator` and the `reaction_analyzer` will be launched. It will automatically start
9489
to test. After the test is completed, the results will be stored in the `output_file_path` you defined.
9590

91+
#### Prepared Test Environment
92+
93+
**Scene without object:**
94+
![sc1-awsim.png](media%2Fsc1-awsim.png)
95+
![sc1-rviz.png](media%2Fsc1-rviz.png)
96+
97+
**Scene object:**
98+
![sc2-awsim.png](media%2Fsc2-awsim.png)
99+
![sc2-rviz.png](media%2Fsc2-rviz.png)
100+
96101
### Custom Test Environment
97102

98103
**If you want to run the reaction analyzer with your custom test environment, you need to redefine some of the
@@ -101,39 +106,53 @@ The parameters you need to redefine are `initialization_pose`, `entity_params`,
101106
for `perception_planning` mode) parameters.**
102107

103108
- To set `initialization_pose`, `entity_params`, `goal_pose`:
104-
- Upload your `.osm` map file into the [scenario editor](https://scenario.ci.tier4.jp/scenario_editor/) to define the
105-
position of the position parameters.
106-
- Add EGO vehicle from edit/add entity/Ego to map.
107-
- Set destination to EGO vehicle and add another dummy object in same way. The dummy object represents the object spawn
108-
suddenly in the reaction analyzer test.
109+
- Run the AWSIM environment. Tutorial for AWSIM can be found
110+
[here](https://autowarefoundation.github.io/AWSIM/main/GettingStarted/QuickStartDemo/).
111+
- Run the e2e_simulator with the following command:
112+
113+
```bash
114+
ros2 launch autoware_launch e2e_simulator.launch.xml vehicle_model:=sample_vehicle sensor_model:=awsim_labs_sensor_kit map_path:=[MAP_PATH]
115+
```
109116

110-
**After you set up the positions in the map, we should get the positions of these entities in the map frame. To achieve
111-
this:**
117+
- After EGO is initialized, you can move the ego vehicle to the desired position by using the `SetGoal` button in the
118+
RViz.
119+
- After the EGO stopped in desired position, please localize the dummy obstacle by using the traffic controller. You can
120+
control the traffic by pressing `ESC` button.
112121

113-
- Convert the positions to map frame by changing Map/Coordinate to World and Map/Orientation to Euler in Scenario
114-
Editor.
122+
**After localize EGO and dummy vehicle, we should write the positions of these entities in the map frame in `reaction_analyzer.param.yaml`. To achieve this:**
115123

116-
- After these steps, you can see the positions in map frame and euler angles. You can change
117-
the `initialization_pose`, `entity_params`, `goal_pose` parameters with the values you get from the website.
124+
- Get initialization pose from `/awsim/ground_truth/vehicle/pose` topic.
125+
- Get entity params from `/perception/object_recognition/objects` topic.
126+
- Get goal pose from `/planning/mission_planning/goal` topic.
127+
128+
**PS: `initialization_pose` is only valid for `planning_control` mode.**
129+
130+
- After the parameters were noted, we should record the rosbags for the test. To record the rosbags, you can use the
131+
following command:
132+
133+
```bash
134+
ros2 bag record --all
135+
```
118136

119-
**For the `topic_publisher` parameters, you need to record the rosbags from the AWSIM. After opened your AWSIM
120-
environment, you should record two different rosbags. However, the environment should be static and the position of the
121-
vehicle should be same.**
137+
- You should record two rosbags: one without the object and one with the object. You can use the traffic controller to
138+
spawn the object in front of the EGO vehicle or remove it.
122139

123-
- Record a rosbag in empty environment (without an obstacle in front of the vehicle).
124-
- After that, record another rosbag in the same environment except add an object in front of the vehicle.
140+
**NOTE: You should record the rosbags in the same environment with the same position of the EGO vehicle. You don't need
141+
to run Autoware while recording.**
125142

126-
**After you record the rosbags, you can set the `path_bag_without_object` and `path_bag_with_object` parameters with the
127-
paths of the recorded rosbags.**
143+
- After you record the rosbags, you can set the `path_bag_without_object` and `path_bag_with_object` parameters with the
144+
paths of the recorded rosbags.
128145

129146
## Results
130147

131148
The results will be stored in the `csv` file format and written to the `output_file_path` you defined. It shows each
132-
pipeline of the Autoware by using header timestamp of the messages, and it reports `Node Latency`, and `Total Latency`
149+
pipeline of the Autoware by using header timestamp of the messages, and it reports `Node Latency`, `Pipeline Latency`, and `Total Latency`
133150
for each of the nodes.
134151

135152
- `Node Latency`: The time difference between previous and current node's reaction timestamps.
136-
- `Total Latency`: The time difference between the message's published timestamp and the spawn obstacle command sent timestamp.
153+
- `Pipeline Latency`: The time difference between published time of the message and pipeline header time.
154+
- `Total Latency`: The time difference between the message's published timestamp and the spawn obstacle command sent
155+
timestamp.
137156

138157
## Parameters
139158

tools/reaction_analyzer/include/reaction_analyzer_node.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ReactionAnalyzerNode : public rclcpp::Node
100100
std::optional<rclcpp::Time> test_environment_init_time_;
101101
std::optional<rclcpp::Time> spawn_cmd_time_;
102102
std::atomic<bool> spawn_object_cmd_{false};
103-
bool is_vehicle_initialized_{false};
103+
bool is_initialization_requested{false};
104104
bool is_route_set_{false};
105105
size_t test_iteration_count_{0};
106106

tools/reaction_analyzer/include/topic_publisher.hpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,12 @@ class TopicPublisher
223223
const std::string & topic_name, const rosbag2_storage::SerializedBagMessage & bag_message,
224224
const bool is_empty_area_message);
225225
void set_period(const std::map<std::string, std::vector<rclcpp::Time>> & time_map);
226-
std::map<std::string, PublisherVariables<PointCloud2>> set_general_publishers_and_timers();
227-
void set_pointcloud_publishers_and_timers(
226+
void set_publishers_and_timers_to_variable();
227+
void set_timers_for_pointcloud_msgs(
228228
const std::map<std::string, PublisherVariables<PointCloud2>> & pointcloud_variables_map);
229229
bool check_publishers_initialized_correctly();
230230
void init_rosbag_publishers();
231-
void init_rosbag_publishers_with_object(const std::string & path_bag_with_object);
232-
void init_rosbag_publishers_without_object(const std::string & path_bag_without_object);
231+
void init_rosbag_publisher_buffer(const std::string & bag_path, const bool is_empty_area_message);
233232
void pointcloud_messages_sync_publisher(const PointcloudPublisherType type);
234233
void pointcloud_messages_async_publisher(
235234
const std::pair<

tools/reaction_analyzer/launch/reaction_analyzer.launch.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<launch>
22
<arg name="reaction_analyzer_param_path" default="$(find-pkg-share reaction_analyzer)/param/reaction_analyzer.param.yaml"/>
33

4-
<!-- reaction analyzer publishes own perception objects -->
4+
<!-- reaction analyzer publishes own perception objects for planning_control mode -->
55
<arg name="launch_simulator_perception_modules" default="false"/>
66

77
<!-- Arguments for occupancy_grid_map -->
@@ -23,7 +23,6 @@
2323
<arg name="vehicle_model" value="$(var vehicle_model)"/>
2424
<arg name="sensor_model" value="$(var sensor_model)"/>
2525
<arg name="use_sim_time" value="false"/>
26-
<arg name="enable_image_decompressor" value="false"/>
2726
</include>
2827
</group>
2928
<group if="$(eval &quot;'$(var running_mode)'=='planning_control'&quot;)">
@@ -51,6 +50,7 @@
5150
<node_container pkg="rclcpp_components" exec="component_container_mt" name="reaction_analyzer_container" namespace="" args="" output="screen">
5251
<composable_node pkg="reaction_analyzer" plugin="reaction_analyzer::ReactionAnalyzerNode" name="reaction_analyzer" namespace="">
5352
<param from="$(var reaction_analyzer_param_path)"/>
53+
<param name="running_mode" value="$(var running_mode)"/>
5454
<remap from="output/pointcloud" to="/perception/obstacle_segmentation/pointcloud"/>
5555
<remap from="output/objects" to="/perception/object_recognition/objects"/>
5656
<remap from="output/initialpose" to="/initialpose"/>
@@ -61,7 +61,6 @@
6161
<remap from="input/routing_state" to="/api/routing/state"/>
6262
<remap from="input/operation_mode_state" to="/api/operation_mode/state"/>
6363
<remap from="input/ground_truth_pose" to="/awsim/ground_truth/vehicle/pose"/>
64-
<param name="running_mode" value="$(var running_mode)"/>
6564
<extra_arg name="use_intra_process_comms" value="false"/>
6665
</composable_node>
6766
</node_container>
1.11 MB
Loading
634 KB
Loading
1.11 MB
Loading
490 KB
Loading

tools/reaction_analyzer/param/reaction_analyzer.param.yaml

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22
ros__parameters:
33
timer_period: 0.033 # s
44
test_iteration: 10
5-
output_file_path: <PATH_TO_RESUlTS_FOLDER>
5+
output_file_path: <PATH_TO_OUTPUT_FOLDER>
66
spawn_time_after_init: 10.0 # s for perception_planning mode
77
spawn_distance_threshold: 15.0 # m # for planning_control mode
88
poses:
99
initialization_pose:
10-
x: 81247.9609375
11-
y: 49828.87890625
10+
x: 81546.984375
11+
y: 50011.96875
1212
z: 0.0
1313
roll: 0.0
1414
pitch: 0.0
15-
yaw: 35.5
15+
yaw: 11.1130405
1616
goal_pose:
17-
x: 81824.90625
18-
y: 50069.34375
17+
x: 81643.0703125
18+
y: 50029.8828125
1919
z: 0.0
2020
roll: 0.0
2121
pitch: 0.0
22-
yaw: 8.9305903
22+
yaw: 13.12
2323
entity_params:
24-
x: 81392.97671487389
25-
y: 49927.361443601316
26-
z: 42.13605499267578
27-
roll: 0.2731273
28-
pitch: -0.6873504
29-
yaw: 33.7664809
30-
x_dimension: 4.118675972722859
31-
y_dimension: 1.7809072588403219
32-
z_dimension: 0.8328610206872963
24+
x: 81633.86068376624
25+
y: 50028.383586673124
26+
z: 42.44818343779461
27+
roll: 0.0
28+
pitch: 0.0
29+
yaw: 11.8235848
30+
x_dimension: 3.95
31+
y_dimension: 1.77
32+
z_dimension: 1.43
3333
topic_publisher:
34-
path_bag_without_object: <PATH_TO_YOUR_BAGS>/lexus_bag_without_car/rosbag2_2024_01_30-13_50_45_0.db3
35-
path_bag_with_object: <PATH_TO_YOUR_BAGS>/lexus_bag_with_car/rosbag2_2024_01_30-13_50_17_0.db3
34+
path_bag_without_object: <PATH_TO_YOUR_BAGS>/rosbag2_awsim_labs/rosbag2_awsim_labs.db3
35+
path_bag_with_object: <PATH_TO_YOUR_BAGS>/rosbag2_awsim_labs_obstacle/rosbag2_awsim_labs_obstacle.db3
3636
pointcloud_publisher:
3737
pointcloud_publisher_type: "sync_header_sync_publish" # "async_header_sync_publish", "sync_header_sync_publish" or "async_publish"
3838
pointcloud_publisher_period: 0.1 # s

tools/reaction_analyzer/src/reaction_analyzer_node.cpp

+15-14
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,14 @@ void ReactionAnalyzerNode::init_test_env(
269269
last_test_environment_init_request_time_ = current_time;
270270

271271
// Pose initialization of the ego
272-
is_vehicle_initialized_ = !is_vehicle_initialized_
273-
? init_ego(initialization_state_ptr, odometry_ptr, current_time)
274-
: is_vehicle_initialized_;
272+
is_initialization_requested = !is_initialization_requested
273+
? init_ego(initialization_state_ptr, odometry_ptr, current_time)
274+
: is_initialization_requested;
275275

276-
if (!is_vehicle_initialized_) {
276+
if (
277+
is_initialization_requested &&
278+
initialization_state_ptr->state != LocalizationInitializationState::INITIALIZED) {
279+
is_initialization_requested = false;
277280
return;
278281
}
279282

@@ -298,7 +301,7 @@ void ReactionAnalyzerNode::init_test_env(
298301
}
299302

300303
const bool is_ready =
301-
(is_vehicle_initialized_ && is_route_set_ &&
304+
(is_initialization_requested && is_route_set_ &&
302305
(operation_mode_ptr->mode == OperationModeState::AUTONOMOUS ||
303306
node_running_mode_ == RunningMode::PerceptionPlanning));
304307
if (is_ready) {
@@ -332,14 +335,12 @@ bool ReactionAnalyzerNode::init_ego(
332335
{
333336
// Pose initialization of the ego
334337
if (initialization_state_ptr) {
335-
if (initialization_state_ptr->state != LocalizationInitializationState::INITIALIZED) {
336-
if (node_running_mode_ == RunningMode::PlanningControl) {
337-
// publish initial pose
338-
init_pose_.header.stamp = current_time;
339-
init_pose_.header.frame_id = "map";
340-
pub_initial_pose_->publish(init_pose_);
341-
}
342-
return false;
338+
if (node_running_mode_ == RunningMode::PlanningControl) {
339+
// publish initial pose
340+
init_pose_.header.stamp = current_time;
341+
init_pose_.header.frame_id = "map";
342+
pub_initial_pose_->publish(init_pose_);
343+
RCLCPP_WARN_ONCE(get_logger(), "Initialization position is published. Waiting for init...");
343344
}
344345
// Wait until odometry_ptr is initialized
345346
if (!odometry_ptr) {
@@ -407,7 +408,7 @@ void ReactionAnalyzerNode::reset()
407408
return;
408409
}
409410
// reset the variables
410-
is_vehicle_initialized_ = false;
411+
is_initialization_requested = false;
411412
is_route_set_ = false;
412413
test_environment_init_time_ = std::nullopt;
413414
last_test_environment_init_request_time_ = std::nullopt;

0 commit comments

Comments
 (0)