PcdGeneration
Abstract
Pcd Generation is a tool for a vehicle based point cloud mapping in a simulation environment.
It is useful when you need a point cloud based on some location, but are not able to conduct physically mapping on the real place.
When Pcd Generation is conducted, Vehicle object (carrying LiDAR) is warped along all centerlines of lanelets in the imported OSM map.
Point cloud map is generated to record points by LiDAR on Vehicle object on each centerlines of lanelets.
Overview
Traffic Simulation consists of the following flow:
graph TB
subgraph A["PcdGeneration::Initialize()"]
direction TB
AA("Load LaneletMap")~~~AB("Create `Capture Pose Queue`")
end
AB-->BA
subgraph B["PcdGeneration::OnUpdate()"]
direction TB
BA--"yes"-->BE("PcdGeneration::SavePcd()")
BA{`Capture Pose Queue` is empty}--"no"-->BB("Dequeue `Capture Pose Queue`")-->BC("Move pose")-->BD("Capture by LiDAR")-->BA
end
Configuration
PcdGeneration can be configured from PcdGenerator and RGLMappingAdapter components.
The configurable elements are listed in the following table:
PcdGenerator
| Parameter | Description |
|---|---|
| Osm Data Container | Imported OSM file. |
| Vehicle Transform | Game object containing sensors to capture pointcloud. |
| Rgl Mapping Adapter | Reference of LiDAR object which is attached RGLMappingAdapter. |
| Output Pcd File Path | Result PCD file name.On captured, it will be saved in Assets/[Output Pcd File Path] |
| Capture Location Interval | Distance in meters between consecutive warps along the centerline of a lanelet. |
| World Origin ROS | World origin in ROS coordinate systems, will be added to every point coordinates. |
RGLMappingAdapter
| Parameter | Description |
|---|---|
| Enable Downsampling | Enable/disable point cloud data downsampling. |
| Leaf Size | Resolution of point cloud data downsampling. |
Execution and Parameters
Execution
If you play prepared scene, PcdGenerator will automatically start mapping.
PCD file will be written when you stop scene or all lanelets in the route are captured.
If the Vehicle stops moving and you see the following message in the bottom left corner, you can safely stop the scene.
pcd save success
The Point cloud (*.pcd) file is saved to the location you specified in the Output Pcd File Path of PcdGenerator.
Parameters
Following parameters are useful to point cloud map of quality and file size you want to.
Leaf Size
Downsampling aims to reduce PCD size which for large point clouds may achieve gigabytes in exchange for map details.
It is essential to find the acceptable balance between the file size and details level.
Leaf Size can be configured by RGLMappingAdapter component.
A small Leaf Size results in a more detailed PCD, while a large Leaf Size could result in excessive filtering such that objects like buildings are not recorded in the PCD.
| Leaf Size = 1.0 | Leaf Size = 10.0 | Leaf Size = 100.0 |
|---|---|---|
Capture Location Interval
If the Capture Location Interval is too small, it could result in a sparse PCD where some region of the map is captured well but the other regions aren't captured at all.
Capture Location Interval can be configured by PcdGeneration component.
| Capture Location Interval = 6 | Capture Location Interval = 20 | Capture Location Interval = 100 |
|---|---|---|
Instruction
To use Pcd Generation, please follow the steps below.
For the preparation, the following must be prepared:
- 3D map (.fbx)
- lanelet map (.osm)
- LiDAR sensor (.fbx)
Info
AWSIM includes PcdGenerationDemo scene.
Please refer to:
* Assets/Awsim/Scenes/PcdGenerationDemo.unity
1. Add a Vehicle object
Add Vehicle object to carry LiDAR and capture points.
In addition, visual elements of Vehicle if needed.
Please create Vehicle object as the following:
- Create empty
GameObject(should beVehicle) - (optional) Create empty
GameObject(should beVehicle/Geometry)- If needed, visual elements of
Vehicleadded here - Visual element can even be a simple
Cubeobject as the sample image
- If needed, visual elements of
2. Add a Camera
Add Unity Camera to visualize recording process.
Please create Unity Camera as the following:
- Create
Cameraobject (should beVehicle/Follow Camera) - Attach
FollowCameracomponent toFollow Camera - Fill in
Targetfield withVehicle - Modify
Transform- Using
CamerasUnity view allows you to check the camera view
- Using
3. Add a LiDAR related objects
Add LiDAR object and configure components to record points.
LiDAR object
Please create and configure LiDAR object as the following:
- Create
LiDARobject (should beVehicle/LiDAR) - Set
Transform.Position.Y2.5 - Attach
PointCloudVisualizationcomponent toLiDAR - Attach
LidarSensorcomponent toLiDAR- Select
Model Preset(VelodyneVLP16andVelodyneVLS128is recommended)VelodyneVLS128can create more detail maps thanVelodyneVLP16VelodyneVLP16can work lighter thanVelodyneVLS128
- Set
Apply Distance Gaussian NoiseandApply Angular Gaussian NoiseFalse
- Select
- Attach
RGLMappingAdaptercomponent toLiDAR
RGLSceneManager
Please create SceneManager object as the following:
- Create empty
GameObject(should beRGLSceneManager) - Attach
SceneManagercomponent toRGLSceneManager
4. Setup PcdGenerator
Add PcdGenerator component to manage above objects and create point cloud map.
- Create empty
GameObject(should bePcdGenerator) - Attach
PcdGeneratorcomponent toPcdGenerator - Fill in
Osm Data Containerfield with.osmfile- If there is not
.osmfile in project, move.osmfile toAssets/Awsim/Externalsdirectory using file expoler
- If there is not
- Fill in
Vehicle Transformfield withVehicle - Fill in
Rgl Mapping Adapterfield withLiDAR - (optional) Fill in
World Origin ROSfield if your map hasMgrs Positioncomponent
5. Call methods of PcdGenerator and FollowCamera
Some methods of PcdGenerator and FollowCamera should be called from callback of MonoBehaviour to enable Pcd Generation.
Please implement as the following:
- Create or open class which is inherit
MonoBehaviour - Make fields of
PcdGeneratorandFollowCamera - Add description of calling method of
PcdGeneratorandFollowCamera
The method should be called are listed in the following table:
Pcd Generation
| Method | Description |
|---|---|
| Initialize() | Should be called Start() callback. |
| OnUpdate() | Should be called Update() callback. |
FollowCamera
| Method | Description |
|---|---|
| Initialize() | Should be called Start() callback. |
| OnUpdate() | Should be called Update() callback. |
Info
AWSIM includes AutowareSimulationDemo scene.
Please refer to:
* Assets/Awsim/Scenes/PcdGenerationDemo/PcdGenerationDemo.cs
* Assets/Awsim/Scenes/PcdGenerationDemo.unity scene
Modify and Verify PCD files
Modify PCD
Generated PCD files should be downsample because they are typically too large.
In addition, they should be converted to ASCII format because Autoware accepts only this format. (Pcd Generation returns PCD in binary format)
The tool (DownsampleLargePCD) can realize downsampling and converting PCD files.
Please clone and build DownsampleLargePCD tool following Github repository.
Please use DownsampleLargePCD tool as the following:
- Change the working directory to the location with
DownsampleLargePCDtool. - Use
DownsampleLargePCDtool to downsample and savePCDinASCIIformat.- You can also save
PCDin binary format by adding-binary 1option.
- You can also save
Note
If you don't want to downsample but want to convert PCD file to ASCII, you should use pcl_convert_pcd_ascii_binary tool.
This tool is available in the pcl-tools package and can be installed on Ubuntu with the following command:
Verify PCD
To verify your PCD you can launch the Autoware*(https://github.com/autowarefoundation/autoware).
Please verify PCD as the following:
-
Copy your
PCDfrom theAWSIMproject directory to theAutowaremap directory -
Source the
ROSandAutoware -
Launch the
planning simulationwith the map directory path (map_path) and PCD file (pointcloud_map_file) specifiedros2 launch autoware_launch planning_simulator.launch.xml \ vehicle_model:=sample_vehicle \ sensor_model:=sample_sensor_kit \ map_path:=<ABSOLUTE_PATH_TO_AUTOWARE_MAP> \ pointcloud_map_file:=<PCD_FILE_NAME>PCD file location
The PCD file needs to be located in the Autoware map directory and as a
pointcloud_map_fileparameter you only supply the file name, not the path.Absolute path
When launching
Autowarenever use~/to specify the home directory. Either write the full absolute path or use$HOMEenvironmental variable. -
Wait for the
Autowareto finish loading and inspect thePCDvisually given the effect ofLeaf Sizeand effect ofCapture Location Interval.