Skip to content

Commit 2567481

Browse files
authored
Merge pull request tier4#1325 from tier4/feature/interpreter/lidar-configuration
Feature/interpreter/lidar configuration
2 parents 4ef9594 + 6f03459 commit 2567481

File tree

4 files changed

+418
-20
lines changed

4 files changed

+418
-20
lines changed

docs/developer_guide/ConfiguringPerceptionTopics.md

Lines changed: 117 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ where `<NAME>` and `<VALUE>` can be set to:
2424

2525
| Name | Value | Default | Description |
2626
|--------------------------------------------|-----------------------------------------------|:-------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
27-
| `detectedObjectMissingProbability` | A `double` type value between `0.0` and `1.0` | `0.0` | Do not publish the perception topic with the given probability. |
28-
| `detectedObjectPositionStandardDeviation` | A positive `double` type value | `0.0` | Randomize the positions of other vehicles included in the perception topic according to the given standard deviation. |
29-
| `detectedObjectPublishingDelay` | A positive `double` type value | `0.0` | Delays the publication of the perception topic by the specified number of seconds. |
30-
| `detectedObjectGroundTruthPublishingDelay` | A positive `double` type value | `0.0` | Delays the publication of the perception ground truth topic by the specified number of seconds. |
27+
| `detectedObjectMissingProbability` | A `double` type value between `0.0` and `1.0` | `0.0` | Do not publish the perception topic with the given probability. |
28+
| `detectedObjectPositionStandardDeviation` | A positive `double` type value | `0.0` | Randomize the positions of other vehicles included in the perception topic according to the given standard deviation. |
29+
| `detectedObjectPublishingDelay` | A positive `double` type value | `0.0` | Delays the publication of the perception topic by the specified number of seconds. |
30+
| `detectedObjectGroundTruthPublishingDelay` | A positive `double` type value | `0.0` | Delays the publication of the perception ground truth topic by the specified number of seconds. |
3131
| `detectionSensorRange` | A positive `double` type value | `300.0` | Specifies the sensor detection range for detected object. |
3232
| `isClairvoyant` | A `boolean` type value | `false` | Specifies whether the detected object is a Clairvoyant. If this parameter is not defined explicitly, the property of `detectionSensorRange` is not reflected and only detected object detected by lidar is published. |
33-
| `randomSeed` | A positive `integer` type value | `0` | Specifies the seed value for the random number generator. |
33+
| `pointcloudChannels` | A positive `integer` type value | `16` | Number of channels of pseudo LiDAR inside the simulator used to generate pointclouds. |
34+
| `pointcloudHorizontalResolution` | A positive `double` type value | `1.0` | Horizontal angular resolution of the pseudo LiDAR inside the simulator used to generate the pointcloud. |
35+
| `pointcloudVerticalFieldOfView` | A positive `double` type value | `30.0` | Vertical field of view of the pseudo LiDAR inside the simulator used to generate the pointcloud. |
36+
| `randomSeed` | A positive `integer` type value | `0` | Specifies the seed value for the random number generator. |
3437

3538
These properties are not exclusive. In other words, multiple properties can be
3639
specified at the same time. However, these properties only take effect for
@@ -161,7 +164,7 @@ this problem by setting an interval of the specified number of seconds between
161164
`scenario_simulator_v2` generating a perception result and publishing it.
162165

163166
**Specification** - The property's value must be a positive real number. The
164-
unit is seconds. It is an error if the value is negative. Since the delay is
167+
unit is seconds. It is an error if the value is negative. Since the delay is
165168
set to the same value for each topic, it is not possible to delay only a
166169
specific topic.
167170

@@ -230,6 +233,114 @@ it reaches the receiver node.
230233
value: "3"
231234
```
232235

236+
## Property `pointcloudChannels`
237+
238+
**Summary** - Number of channels of pseudo LiDAR inside the simulator used to
239+
generate pointclouds.
240+
241+
**Purpose** - The `simple_sensor_simulator` simulates a simple LiDAR, such as a
242+
horizontally rotating vertically aligned laser, typical of the VLP-16, to
243+
generate a pointcloud. The default settings produce a pointcloud that exactly
244+
mimics the sensing results from the VLP-16. However, VLP-16 is a relatively low
245+
pointcloud density LiDAR used with Autoware, so if a higher pointcloud density
246+
LiDAR is to be installed, it will be necessary to simulate a scenario with a
247+
higher pointcloud density to match the actual vehicle. This property addresses
248+
this issue by providing a means to specify the number of pseudo LiDAR channels.
249+
250+
**Specification** - The property value must be a real number greater than or
251+
equal to 1. Zero or negative values are errors. The upper limit of values is
252+
the maximum value of a 64-bit unsigned integer, but computer performance
253+
effectively limits the value to much lower values.
254+
255+
**Guarantee** - The `simple_sensor_simulator` does not simulate a realistic
256+
LiDAR. For example, in the case of a LiDAR with a mechanically rotating laser
257+
structure, the resulting point cloud will be distorted when moving at high
258+
speeds, but `simple_sensor_simulator` cannot simulate such behavior and
259+
produces an undistorted pointcloud.
260+
261+
**Default behavior** - If the property is not specified, the default value is
262+
`"16"`. When the properties `pointcloudChannels` and
263+
`pointcloudVerticalFieldOfView` are both at their default values, the behavior
264+
mimics Velodyne VLP-16.
265+
266+
**[Example](https://github.com/tier4/scenario_simulator_v2/blob/487556437b448186e2de484f5130eb2b1d015e74/test_runner/scenario_test_runner/scenario/Property.pointcloudVerticalFieldOfView.yaml)** -
267+
```
268+
ObjectController:
269+
Controller:
270+
name: '...'
271+
Properties:
272+
Property:
273+
- name: 'isEgo'
274+
value: 'true'
275+
- name: 'pointcloudChannels'
276+
value: '128'
277+
```
278+
279+
## Property `pointcloudHorizontalResolution`
280+
281+
**Summary** - Horizontal angular resolution of the pseudo LiDAR inside the
282+
simulator used to generate the pointcloud.
283+
284+
**Purpose** - To address the same issues as the property `pointcloudChannels`,
285+
this property provides a means to specify the angular resolution of the pseudo
286+
LiDAR.
287+
288+
**Specification** - The property value must be a real number greater than zero.
289+
The unit is degrees. If the value is zero or negative, it is an error.
290+
291+
**Guarantee** - Same as one for `pointcloudChannels`
292+
293+
**Default behavior** - If the property is not specified, the default value is
294+
`"1.0"`.
295+
296+
**[Example](https://github.com/tier4/scenario_simulator_v2/blob/487556437b448186e2de484f5130eb2b1d015e74/test_runner/scenario_test_runner/scenario/Property.pointcloudVerticalFieldOfView.yaml)** -
297+
```
298+
ObjectController:
299+
Controller:
300+
name: '...'
301+
Properties:
302+
Property:
303+
- name: 'isEgo'
304+
value: 'true'
305+
- name: 'pointcloudHorizontalResolution'
306+
value: '1.5'
307+
```
308+
309+
## Property `pointcloudVerticalFieldOfView`
310+
311+
**Summary** - Vertical field of view of the pseudo LiDAR inside the simulator
312+
used to generate the pointcloud.
313+
314+
**Purpose** - To address the same issues as the property `pointcloudChannels`,
315+
this property provides a means to specify the vertical field of view of the
316+
pseudo LiDAR.
317+
318+
**Specification** - The property value must be a real number greater than zero.
319+
The unit is degrees. A value of zero or negative is an error. The specified
320+
angle is assigned equally up and down to the horizontal plane as viewed from
321+
the pseudo LiDAR. For example, if the value `30.0` is specified, the vertical
322+
field of view is +15° to -15°.
323+
324+
**Guarantee** - Same as one for `pointcloudChannels`
325+
326+
**Default behavior** - If the property is not specified, the default value is
327+
`"30.0"`. When the properties `pointcloudChannels` and
328+
`pointcloudVerticalFieldOfView` are both at their default values, the behavior
329+
mimics Velodyne VLP-16.
330+
331+
**[Example](https://github.com/tier4/scenario_simulator_v2/blob/487556437b448186e2de484f5130eb2b1d015e74/test_runner/scenario_test_runner/scenario/Property.pointcloudVerticalFieldOfView.yaml)** -
332+
```
333+
ObjectController:
334+
Controller:
335+
name: '...'
336+
Properties:
337+
Property:
338+
- name: 'isEgo'
339+
value: 'true'
340+
- name: 'pointcloudVerticalFieldOfView'
341+
value: '45.678'
342+
```
343+
233344
## Property `randomSeed`
234345

235346
**Summary** - Specifies the seed value for the random number generator.

openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,34 @@ class SimulatorCore
334334
}());
335335

336336
if (controller.isAutoware()) {
337-
core->attachLidarSensor(
338-
entity_ref, controller.properties.template get<Double>("pointcloudPublishingDelay"));
337+
core->attachLidarSensor([&]() {
338+
simulation_api_schema::LidarConfiguration configuration;
339+
340+
auto degree_to_radian = [](auto degree) {
341+
return degree / 180.0 * boost::math::constants::pi<double>();
342+
};
343+
344+
// clang-format off
345+
configuration.set_architecture_type(core->getROS2Parameter<std::string>("architecture_type", "awf/universe"));
346+
configuration.set_entity(entity_ref);
347+
configuration.set_horizontal_resolution(degree_to_radian(controller.properties.template get<Double>("pointcloudHorizontalResolution", 1.0)));
348+
configuration.set_lidar_sensor_delay(controller.properties.template get<Double>("pointcloudPublishingDelay"));
349+
configuration.set_scan_duration(0.1);
350+
// clang-format on
351+
352+
const auto vertical_field_of_view = degree_to_radian(
353+
controller.properties.template get<Double>("pointcloudVerticalFieldOfView", 30.0));
354+
355+
const auto channels =
356+
controller.properties.template get<UnsignedInteger>("pointcloudChannels", 16);
357+
358+
for (std::size_t i = 0; i < channels; ++i) {
359+
configuration.add_vertical_angles(
360+
vertical_field_of_view / 2 - vertical_field_of_view / channels * i);
361+
}
362+
363+
return configuration;
364+
}());
339365

340366
core->attachDetectionSensor([&]() {
341367
simulation_api_schema::DetectionSensorConfiguration configuration;

simulation/traffic_simulator/src/visualization/visualization_component.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,20 @@ const visualization_msgs::msg::MarkerArray VisualizationComponent::generateMarke
124124
constexpr auto default_quaternion = rosidl_runtime_cpp::MessageInitialization::DEFAULTS_ONLY;
125125
auto ret = visualization_msgs::msg::MarkerArray();
126126
auto stamp = get_clock()->now();
127-
std_msgs::msg::ColorRGBA color;
128-
switch (status.type.type) {
129-
case status.type.EGO:
130-
color = color_names::makeColorMsg("limegreen", 0.99);
131-
break;
132-
case status.type.PEDESTRIAN:
133-
color = color_names::makeColorMsg("orange", 0.99);
134-
break;
135-
case status.type.VEHICLE:
136-
color = color_names::makeColorMsg("lightskyblue", 0.99);
137-
break;
138-
}
127+
128+
const auto color = [&]() {
129+
switch (status.type.type) {
130+
case status.type.EGO:
131+
return color_names::makeColorMsg("limegreen", 0.99);
132+
case status.type.PEDESTRIAN:
133+
return color_names::makeColorMsg("orange", 0.99);
134+
case status.type.VEHICLE:
135+
return color_names::makeColorMsg("lightskyblue", 0.99);
136+
default:
137+
case status.type.MISC_OBJECT:
138+
return color_names::makeColorMsg("magenta", 0.99);
139+
}
140+
}();
139141

140142
if (goal_pose.size() != 0) {
141143
goal_pose_max_size = std::max(goal_pose_max_size, int(goal_pose.size()));

0 commit comments

Comments
 (0)