-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from tier4/feature/rgl-fog-simulation
Add rain and fog simulation features
- Loading branch information
Showing
14 changed files
with
477 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &6956985947121104793 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 6197961024456584825} | ||
- component: {fileID: -8569641881512349866} | ||
- component: {fileID: 5029029592669420807} | ||
- component: {fileID: 2635114183252318215} | ||
m_Layer: 0 | ||
m_Name: RGLWeatherManager | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &6197961024456584825 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6956985947121104793} | ||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
m_LocalPosition: {x: -17.985855, y: -8.897016, z: 19.096115} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!114 &-8569641881512349866 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6956985947121104793} | ||
m_Enabled: 0 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: ac280d5abd54451082c0627a0d08b1b9, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
<IsSnowEnabled>k__BackingField: 0 | ||
<RainRate>k__BackingField: 9 | ||
<MeanSnowflakeDiameter>k__BackingField: 0.003 | ||
<TerminalVelocity>k__BackingField: 1.6 | ||
<Density>k__BackingField: 0.07 | ||
<OccupancyThreshold>k__BackingField: 0 | ||
<SnowflakesId>k__BackingField: 268435455 | ||
<FullBeamIntensity>k__BackingField: 1 | ||
--- !u!114 &5029029592669420807 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6956985947121104793} | ||
m_Enabled: 0 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: aa72d4643994ea2d4b9e731c9454694c, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
<IsRainEnabled>k__BackingField: 0 | ||
<RainRate>k__BackingField: 5 | ||
<RainNumericalThreshold>k__BackingField: 3 | ||
<OccupancyThreshold>k__BackingField: 0.2 | ||
<DropletsId>k__BackingField: 268435455 | ||
<FullBeamIntensity>k__BackingField: 1 | ||
--- !u!114 &2635114183252318215 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6956985947121104793} | ||
m_Enabled: 0 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: e537672f1e918b452802a824b8840e70, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
<IsFogEnabled>k__BackingField: 0 | ||
<AttenuationCoefficient>k__BackingField: 0.03 | ||
<NearCrossPoint>k__BackingField: 0.01 | ||
<FarCrossPoint>k__BackingField: 2 | ||
<FogId>k__BackingField: 268435455 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Assets/RGLUnityPlugin/Plugins/Linux/x86_64/libRobotecGPULidar.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Assets/RGLUnityPlugin/Plugins/Windows/x86_64/RobotecGPULidar.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright 2024 Robotec.ai. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using UnityEngine; | ||
|
||
namespace RGLUnityPlugin | ||
{ | ||
/// <summary> | ||
/// The singleton component to activate and configure the fog model for the LiDAR sensors. | ||
/// Note: This is a private feature. It requires replacing the RGL binary with the RGL private build binary. | ||
/// </summary> | ||
public class LidarFogManager : MonoBehaviour | ||
{ | ||
// Singleton pattern | ||
public static LidarFogManager Instance { get; private set; } | ||
|
||
// Delegate to notify that the snow model has been changed | ||
public delegate void OnNewConfigDelegate(); | ||
public OnNewConfigDelegate OnNewConfig; | ||
|
||
[field: Header("Base Settings")] | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Enable/disable fog effect on devices.r")] | ||
public bool IsFogEnabled { get; set; } = false; | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("The attenuation coefficient for fog corresponding to amount of fog in the air")] | ||
[field: Range(0.003f, 0.5f)] | ||
public float AttenuationCoefficient { get; private set; } = 0.03f; | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Near cross-point of transmitter and receiver beams of Lidar device in meters. Model assumes that lidar is working in bistatic beam configuration.")] | ||
[field: Range(0.0f, 1.0f)] | ||
public float NearCrossPoint { get; private set; } = 0.01f; | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Far cross-point of transmitter and receiver beams of Lidar device. Model assumes that lidar is working in bistatic beam configuration.")] | ||
[field: Range(1.0f, 10.0f)] | ||
public float FarCrossPoint { get; private set; } = 2.0f; | ||
|
||
[field: Header("Defaults")] | ||
[field: SerializeField] | ||
[field: Tooltip("Entity ID that is assigned to cloud points resulting from fog hits")] | ||
public int FogId { get; private set; } = 268435455; // Default RGL entity ID. | ||
|
||
private void Awake() | ||
{ | ||
if (!IsFogFeatureAvailable()) | ||
{ | ||
Debug.LogError("Loaded RGL plugin does not include support for Lidar Fog Model, removing component"); | ||
Destroy(this); | ||
return; | ||
} | ||
|
||
if (Instance != null && Instance != this) | ||
{ | ||
Debug.LogError("LidarFogManager is already on the scene. Removing this component"); | ||
Destroy(this); | ||
return; | ||
} | ||
Instance = this; | ||
} | ||
|
||
private void OnValidate() | ||
{ | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
IsFogEnabled = true; | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
private void OnDisable() | ||
{ | ||
IsFogEnabled = false; | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
public bool IsFogFeatureAvailable() | ||
{ | ||
return RGLNativeAPI.HasExtension(RGLExtension.RGL_EXTENSION_WEATHER); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright 2024 Robotec.ai. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using UnityEngine; | ||
|
||
namespace RGLUnityPlugin | ||
{ | ||
/// <summary> | ||
/// The singleton component to activate and configure the rain model for the LiDAR sensors. | ||
/// Note: This is a private feature. It requires replacing the RGL binary with the RGL private build binary. | ||
/// </summary> | ||
public class LidarRainManager : MonoBehaviour | ||
{ | ||
// Singleton pattern | ||
public static LidarRainManager Instance { get; private set; } | ||
|
||
// Delegate to notify that the rain model has been changed | ||
public delegate void OnNewConfigDelegate(); | ||
public OnNewConfigDelegate OnNewConfig; | ||
|
||
[field: Header("Base Settings")] | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Enable/disable rain effect on devices.r")] | ||
public bool IsRainEnabled { get; set; } = false; | ||
|
||
// Rain model properties | ||
[field: SerializeField] | ||
[field: Tooltip("The precipitation rate for rain is expressed in mm per hour")] | ||
[field: Range(0.0f, 10.0f)] | ||
public float RainRate { get; private set; } = 5.0f; | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Maximal number of droplets which not obstruct the lidar beam")] | ||
[field: Range(1, 5)] | ||
public int RainNumericalThreshold { get; private set; } = 3; | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Minimal beam aperture occupancy (ratio) that means a hit, both for droplets and for original hit")] | ||
[field: Range(0.0f, 1.0f)] | ||
public float OccupancyThreshold { get; private set; } = 0.2f; | ||
|
||
[field: Header("Defaults")] | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Entity ID that is assigned to cloud points resulting from droplet hits")] | ||
public int DropletsId { get; private set; } = 268435455; // Default RGL entity ID. | ||
|
||
[field: SerializeField] | ||
[field: Tooltip("Initial intensity of each LiDAR laser beam, used to evaluate energy loss based on beam aperture occupancy")] | ||
[field: Min(0.0f)] | ||
public float FullBeamIntensity { get; private set; } = 1.0f; | ||
|
||
private void Awake() | ||
{ | ||
if (!IsRainFeatureAvailable()) | ||
{ | ||
Debug.LogError("Loaded RGL plugin does not include support for Lidar Rain Model, removing component"); | ||
Destroy(this); | ||
return; | ||
} | ||
|
||
if (Instance != null && Instance != this) | ||
{ | ||
Debug.LogError("LidarRainManager is already on the scene. Removing this component"); | ||
Destroy(this); | ||
return; | ||
} | ||
Instance = this; | ||
} | ||
|
||
private void OnValidate() | ||
{ | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
IsRainEnabled = true; | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
private void OnDisable() | ||
{ | ||
IsRainEnabled = false; | ||
OnNewConfig?.Invoke(); | ||
} | ||
|
||
public bool IsRainFeatureAvailable() | ||
{ | ||
return RGLNativeAPI.HasExtension(RGLExtension.RGL_EXTENSION_WEATHER); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.