LidarTemplate.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/RTTI/RTTI.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/std/string/string.h>
  12. #include <ROS2Sensors/ROS2SensorsTypeIds.h>
  13. namespace ROS2Sensors
  14. {
  15. //! Configuration reflecting a specific Lidar model.
  16. //! This is meant to capture differences between different Lidars available on the market.
  17. //! @note Current implementation is simplified. Rays in real lidars are often not uniformly
  18. //! distributed among angular range, there is noise etc.
  19. struct LidarTemplate
  20. {
  21. public:
  22. AZ_TYPE_INFO(LidarTemplate, LidarTemplateTypeId);
  23. static void Reflect(AZ::ReflectContext* context);
  24. enum class LidarModel
  25. {
  26. Custom3DLidar,
  27. Ouster_OS0_64,
  28. Ouster_OS1_64,
  29. Ouster_OS2_64,
  30. Velodyne_Puck,
  31. Velodyne_HDL_32E,
  32. // 2D Lidars
  33. Custom2DLidar,
  34. Slamtec_RPLIDAR_S1
  35. };
  36. struct NoiseParameters
  37. {
  38. public:
  39. AZ_TYPE_INFO(NoiseParameters, LidarTemplateNoiseParametersTypeId);
  40. static void Reflect(AZ::ReflectContext* context);
  41. //! Angular noise standard deviation, in degrees
  42. float m_angularNoiseStdDev = 0.0f;
  43. //! Distance noise standard deviation base value, in meters
  44. float m_distanceNoiseStdDevBase = 0.0f;
  45. //! Distance noise standard deviation increase per meter distance traveled, in meters
  46. float m_distanceNoiseStdDevRisePerMeter = 0.0f;
  47. };
  48. LidarModel m_model;
  49. //! Name of lidar template
  50. AZStd::string m_name;
  51. //! Whether the template is for a 2D Lidar.
  52. //! This causes vertical parameters of the Lidar to be unmodifiable (m_minVAngle, m_maxVAngle, m_layers).
  53. bool m_is2D = false;
  54. //! Minimum horizontal angle (altitude of the ray), in degrees
  55. float m_minHAngle = 0.0f;
  56. //! Maximum horizontal angle (altitude of the ray), in degrees
  57. float m_maxHAngle = 0.0f;
  58. //! Minimum vertical angle (azimuth of the ray), in degrees
  59. float m_minVAngle = 0.0f;
  60. //! Maximum vertical angle (azimuth of the ray), in degrees
  61. float m_maxVAngle = 0.0f;
  62. //! Number of lasers layers (resolution in horizontal direction)
  63. unsigned int m_layers = 0;
  64. //! Resolution in vertical direction
  65. unsigned int m_numberOfIncrements = 0;
  66. //! Minimum range of simulated LiDAR
  67. float m_minRange = 0.0f;
  68. //! Maximum range of simulated LiDAR
  69. float m_maxRange = 0.0f;
  70. NoiseParameters m_noiseParameters;
  71. bool m_isNoiseEnabled = true;
  72. bool m_showNoiseConfig = false;
  73. private:
  74. bool IsLayersVisible() const;
  75. [[nodiscard]] bool IsNoiseConfigVisible() const;
  76. static AZ::Outcome<void, AZStd::string> ValidateRange(float minRange, float maxRange);
  77. AZ::Outcome<void, AZStd::string> ValidateMinRange(void* newValue, const AZ::TypeId& valueType) const;
  78. AZ::Outcome<void, AZStd::string> ValidateMaxRange(void* newValue, const AZ::TypeId& valueType) const;
  79. };
  80. } // namespace ROS2Sensors