Description
class for managing sensors. This is the Sensor system class.
#include <ChSensorManager.h>
Public Member Functions | |
| ChSensorManager (ChSystem *chrono_system) | |
| Class constructor. More... | |
| ChSensorManager (const ChSensorManager &)=delete | |
| Not copyable or movable. More... | |
| ChSensorManager & | operator= (const ChSensorManager &)=delete |
| void | Update () |
| Update the sensors as needed according to the current time of the chrono simulation. | |
| void | AddSensor (std::shared_ptr< ChSensor > sensor) |
| Add a sensor to the manager. More... | |
| std::vector< std::shared_ptr< ChSensor > > | GetSensorList () |
| Get the list of sensors for which this manager is responsible. More... | |
| void | SetDeviceList (std::vector< unsigned int > device_ids) |
| Set the list of devices (GPUs) that should be used for rendering. More... | |
| std::vector< unsigned int > | GetDeviceList () |
| Get the list of devices that are intended for use. More... | |
| void | ReconstructScenes () |
| Calls on the sensor manager to rebuild the scene. More... | |
| int | GetMaxEngines () |
| Get the maximum number of allowed render engines for the manager. More... | |
| void | SetMaxEngines (int num_groups) |
| Set the maximum number of allowable render engines. More... | |
| void | SetRayRecursions (int rec) |
| Set the number of recursions for ray tracing. More... | |
| int | GetRayRecursions () |
| Get the number of recursions used in ray tracing. More... | |
| void | SetVerbose (bool verbose) |
| Enable/disable verbose output mode (default: false). More... | |
| bool | GetVerbose () |
| Get the verbose setting. More... | |
| void | SetDebug (bool debug) |
| Enable/disable sensor debug mode (default: false). | |
Static Public Member Functions | |
| static void | SetRandomSeed (unsigned int seed) |
| Fix the BASE seed from which every sensor's per-pixel random state is derived, making stochastic renders reproducible run to run. More... | |
| static void | ClearRandomSeed () |
| Revert to clock-based seeding, the default. | |
| static bool | HasRandomSeed () |
| Whether a fixed base seed is in force. | |
| static unsigned long long | GetDeterministicSeed (const std::shared_ptr< ChSensor > &sensor, RngUsage usage, unsigned int filter_stream_index) |
| The seed for one specific RNG buffer, and the only supported way to seed one. More... | |
| static unsigned long long | MakeRngStreamId (unsigned int manager_id, unsigned int sensor_ordinal, unsigned int filter_stream_index, RngUsage usage) |
| Pack a stream key into its 64-bit id, without applying a base seed. More... | |
Constructor & Destructor Documentation
◆ ChSensorManager() [1/2]
| CH_SENSOR_API chrono::sensor::ChSensorManager::ChSensorManager | ( | ChSystem * | chrono_system | ) |
Class constructor.
The chrono system with which the sensor manager is associated is used for time management.
◆ ChSensorManager() [2/2]
|
delete |
Not copyable or movable.
The manager owns an RNG identity slot that its destructor releases, so a copy would release the same slot twice and hand a later manager an id that is still in use, silently correlating two sensors' random streams. Copying was already meaningless before that (two managers would drive the same OptiX engines and the same sensor list), and nothing in Chrono copies one: every use site holds a std::shared_ptr<ChSensorManager>.
Member Function Documentation
◆ AddSensor()
| CH_SENSOR_API void chrono::sensor::ChSensorManager::AddSensor | ( | std::shared_ptr< ChSensor > | sensor | ) |
Add a sensor to the manager.
- Parameters
-
sensor The sensor that should be added to the system
◆ GetDeterministicSeed()
|
static |
The seed for one specific RNG buffer, and the only supported way to seed one.
With a fixed base seed, the result is a deterministic function of (base seed, manager id, sensor ordinal, filter stream index, usage), injective over that domain, so no two buffers in a simulation share a stream. With no fixed seed it is a fresh clock reading per call, preserving the historical default.
- Parameters
-
sensor the sensor owning the buffer; must already be registered via AddSensor usage what the buffer is for filter_stream_index the calling filter's ChFilter::GetRngStreamIndex()
- Returns
- the 64-bit seed to pass to init_cuda_rng
- Exceptions
-
std::runtime_error if the sensor is null or was never registered, if the calling filter has no stream index, if usageis RngUsage::Unknown or a value at or past RngUsage::Count, or if any field of the stream key exceeds its bit width. Every one of these would otherwise silently correlate streams or seed a buffer with no purpose identity, so all are checked on every call, including when no fixed seed is in force.
◆ GetDeviceList()
| CH_SENSOR_API std::vector< unsigned int > chrono::sensor::ChSensorManager::GetDeviceList | ( | ) |
Get the list of devices that are intended for use.
- Returns
- List of device IDs that the manager will try to use when rendering.
◆ GetMaxEngines()
|
inline |
Get the maximum number of allowed render engines for the manager.
- Returns
- An integer specifying the maximum number of engines the manager is allowed to create.
◆ GetRayRecursions()
|
inline |
Get the number of recursions used in ray tracing.
- Returns
- The max number of recursions used in ray tracing
◆ GetSensorList()
|
inline |
Get the list of sensors for which this manager is responsible.
- Returns
- The list of sensors for which the manager is responsible and updates
◆ GetVerbose()
|
inline |
Get the verbose setting.
- Returns
- the verbose setting
◆ MakeRngStreamId()
|
static |
Pack a stream key into its 64-bit id, without applying a base seed.
Exposed for tests that need to prove injectivity directly rather than through a rendered image.
This is the RAW packer and is deliberately more permissive than the production path: it range-checks each field against its BIT WIDTH only, so a test can prove injectivity over more purposes than the enum currently declares. It does NOT enforce that the usage names a declared purpose. Production code must call GetDeterministicSeed, which does.
- Exceptions
-
std::runtime_error if any field exceeds its bit width.
◆ ReconstructScenes()
| CH_SENSOR_API void chrono::sensor::ChSensorManager::ReconstructScenes | ( | ) |
Calls on the sensor manager to rebuild the scene.
This translates all objects from the Chrono system into their active render-backend objects.
◆ SetDeviceList()
| CH_SENSOR_API void chrono::sensor::ChSensorManager::SetDeviceList | ( | std::vector< unsigned int > | device_ids | ) |
Set the list of devices (GPUs) that should be used for rendering.
- Parameters
-
device_ids List of IDs corresponding to the devices (GPUs) that should be used.
◆ SetMaxEngines()
| CH_SENSOR_API void chrono::sensor::ChSensorManager::SetMaxEngines | ( | int | num_groups | ) |
Set the maximum number of allowable render engines.
The manager will spawn up to this number of render engines based on the update rate of the sensors. Sensors with similar update rates will be grouped on the same engine to reduce the number of scene updates that are required as this is a major bottleneck in the multi-threading paradigm of the render engine.
- Parameters
-
num_groups The maximum number of render engines the manager is allowed to create.
◆ SetRandomSeed()
|
static |
Fix the BASE seed from which every sensor's per-pixel random state is derived, making stochastic renders reproducible run to run.
By default each sensor seeds its RNG from the wall clock, so a render that consumes random numbers (environment lighting, global illumination, the PATH integrator, motion-blur shutter sampling, sensor noise) produces different output on every run. That is the right default for a simulation but it makes byte-exact regression tests impossible, so this hook exists to pin it. Call before creating sensors: the seed is read when a sensor's render filter initializes.
This is a BASE seed, not the seed handed to cuRAND. Each RNG buffer gets its own derived seed from GetDeterministicSeed. Handing this value straight to curand_init at several call sites is exactly the defect that motivated the derivation: cuRAND separates generators by subsequence, which the per-pixel index already occupies, so two buffers given the same seed produce bit-identical numbers.
Deliberately static, because the seed has to reach filters that hold no reference back to the manager. It is a global determinism switch, not per-manager state, which is why the manager id is a separate field of the stream key rather than a second copy of the seed.
- Parameters
-
seed the base value from which per-stream seeds are derived
◆ SetRayRecursions()
| CH_SENSOR_API void chrono::sensor::ChSensorManager::SetRayRecursions | ( | int | rec | ) |
Set the number of recursions for ray tracing.
- Parameters
-
rec The max number of recursions allowed in ray tracing
◆ SetVerbose()
|
inline |
Enable/disable verbose output mode (default: false).
- Parameters
-
verbose whether the framework should print info
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono_sensor/ChSensorManager.h
- /builds/uwsbel/chrono/src/chrono_sensor/ChSensorManager.cpp