Introduction
The Simulation Framework provides a built-in support for co-simulation with ANSYS AVxcelerate Sensor, enabling high-fidelity sensor simulation within the simulation environment. The AVxcelerate Sensor co-simulation feature allows you to integrate realistic sensor models (cameras, lidars, radars, etc.) that can process the ground truth data from the simulation and provide sensor-specific outputs. Note: Simfwk supports AVxcelerate Sensor v261 version. The co-simulation architecture consists of several key components:- AVxcelerate Sensor Connector Activity: A built-in activity that manages the communication with AVxcelerate Sensor service connection
- AVxcelerate VSS API Adapter: Handles gRPC communication with the AVxcelerate Sensor service
- OSI to VSS Converter: Converts Open Simulation Interface (OSI) data to AVxcelerate VSS format (optional)
- Configuration System: Manages co-sim specs, like sensor configuration, object mappings, and connection parameters
- Receiving ground truth data from the gt-gen (OSI SensorView)
- Converting the data to AVxcelerate VSS format (optional)
- Sending the data to the AVxcelerate Sensor service via gRPC
- Processing AVxcelerate Sensor logic
- Retrieving sensor outputs (coming soon)
Add one AVxcelerate Sensor activity
To add an AVxcelerate Sensor activity to your simulation, you need to configure it in the simulation scheduling section of your configuration file. Creation of one generic AVxcelerate Sensor activity is available asbuilt-in type.
Basic configuration
Add the following activity configuration to yoursimulation_scheduling.activities array:
Configuration parameters
Based on which kind of sensor actually runs the AVxcelerate Sensor Service, you can give the activity a specific"name". It is identified as AVxcelerate Sensor activity once you specify the "avx_sensor_setting" field.
The avx_sensor_setting object contains the following parameters:
Transport Mode Configuration
The AVxcelerate Sensor co-simulation supports different gRPC transport modes for communication with the AVxcelerate Sensor service. You can configure the transport mode in theavx_sensor_setting section of your simulation configuration.
Configuration
Add thetransport_mode object to your avx_sensor_setting configuration:
Transport Mode Parameters
Transport Modes
The following transport modes are supported:1. Insecure Mode (Default)
Mode value:"insecure"
Default behavior:
- Uses unencrypted gRPC communication
- No authentication or encryption
- Suitable for local development and testing
- Fastest communication method
- Security: No protection against eavesdropping or man-in-the-middle attacks
transport_mode is not specified, the system defaults to insecure mode for backward compatibility.
2. Mutual TLS (mTLS) Mode
Mode value:"mtls"
Default behavior:
- Uses encrypted gRPC communication with mutual TLS authentication
- Both client (Simfwk) and server (AVxcelerate Sensor) authenticate each other using certificates
- Provides end-to-end encryption and authentication
- Certificate location: The system looks for certificates in the following order:
- Path specified by
ANSYS_GRPC_CERTIFICATESenvironment variable - Default location:
certssubfolder under the application directory
- Path specified by
- Required certificate files:
client.crt- Client certificateclient.key- Client private keyca.crt- Certificate Authority (CA) certificate
- Set the
ANSYS_GRPC_CERTIFICATESenvironment variable to point to your certificates folder, or - Place the certificate files (
client.crt,client.key,ca.crt) in thecertssubfolder under your application directory - Ensure the AVxcelerate Sensor service is configured to use the same CA certificate for server-side authentication
3. Unix Domain Socket (UDS) Mode
Mode value:"unix_domain_socket"
Default behavior:
- Uses Unix Domain Socket for local inter-process communication
- Connection validation: Only supports
localhostor127.0.0.1as the endpoint host - Socket location:
- If
uds_custom_pathis specified:<uds_custom_path>/vss-<socket_id>.sock(orvss.sockifsocket_idis empty) - If
uds_custom_pathis not specified:<USER_HOME_DIRECTORY>/.conn/vss-<socket_id>.sock(orvss.sockifsocket_idis empty) - Falls back to system temp directory if
HOME(Linux) orUSERPROFILE(Windows) environment variable is not set
- If
- Performance: Faster than TCP/IP for local communication
- Security: Limited to local machine only
- The
grpc_endpointhost must belocalhostor127.0.0.1when using UDS mode - The port in
grpc_endpointis ignored for UDS mode - The socket file must be accessible by both Simfwk and AVxcelerate Sensor processes
- Ensure the AVxcelerate Sensor service is configured to use the same socket path
Cross-Reference with AVx Sensors Documentation
For detailed information about transport modes, certificate setup, and AVxcelerate Sensor service configuration, please refer to the official AVx Sensors documentation. The transport mode implementation in Simfwk follows the same patterns and defaults as the AVx Sensors VSS API to ensure compatibility. Key areas to check in AVx Sensors documentation:- Transport mode configuration and requirements
- Certificate generation and setup for mTLS
- Unix Domain Socket path configuration
- Server-side transport mode settings
- Network and security considerations
Dependencies
The AVxcelerate Sensor activity subscribes toSensorViewTopic as input and hence depends on the groundtruth_generator_activity to receive the simulation’s ground truth data. This ensures that the sensor receives the latest world state before processing.
Activity behavior
The AVxcelerate Sensor activity:- Subscribes to
SensorViewTopicto receive ground truth data - Initializes the AVxcelerate Sensor service connection during startup
- Processes the ground truth data:
- If
use_vss_osi_apiistrue: Sends OSI SensorView directly to AVxcelerate Sensor using VSS OSI API (requires AVxcelerate Sensor v261+ with-osioption) - If
use_vss_osi_apiisfalse: Converts OSI SensorView moving objects to AVxcelerate VSSWorldUpdateformat
- If
- Sends the data to the AVxcelerate Sensor service via gRPC
- Unloads the corresponding AVxcelerate Sensor at the end of its lifecycle
Co-sim configuration
The AVxcelerate Sensor co-simulation requires a dedicated configuration file that specifies the sensor setup, connection parameters, and object mappings.Configuration file structure
The AVxcelerate Sensor configuration file must be in JSON format and contain the following structure:Configuration fields
Object mapping
TheObjectMapping array defines how objects in your OpenScenario file correspond to AVxcelerate Sensor assets. Here is an example where two OpenScenario objects map to AVxcelerate assets.
Note that based on which AVxcelerate Sensor version is used, the path towards asset files could be different.
-
OpenScenarioObjectName: The name of the object as defined in yourOpenScenariofile-
The name can be found under
Entities/ScenarioObject:namein the*.xoscfile
-
The name can be found under
-
AVxAsset: Path to the corresponding AVxcelerate asset file (.assetformat). Note that Simfwk only sends the path as string to AVxcelerate Sensor as configuration; the asset files must be resolvable by AVxcelerate Sensor itself.
Example configuration
Here’s a complete example Simfwk configuration for AVxcelerate Sensor co-simulation:Sensor Data Access
The AVxcelerate Sensor co-simulation provides access to sensor output data through a configurable data access mechanism. This feature allows other activities in the simulation framework to receive and process sensor data generated by the AVxcelerate Sensor service. Additionally, sensor data can be recorded to MCAP files for later playback and analysis.Configuration
Sensor data access can be enabled through thesensor_data_access configuration section in your simulation settings:
Configuration parameters in “sensor_data_access”
Recording Sensor Data
Whenenable_recorder is set to true, the AVxcelerate Sensor activity automatically records all sensor data messages to an MCAP file. The MCAP file is created in the simulation output directory with a filename based on the topic name publish_topic_name (e.g., AvxSensorDataTopic.mcap).
The recorded MCAP file contains:
- Topic: Default mcap topic name is
/avx/sensor_data - Message Type:
ansys::api::avxcelerate::sensors::v1::sensor_data::SensorDataprotobuf messages - Format: MCAP format for efficient storage and playback
enable_recorder: true) will have an impact on simulation performance. The recording process involves serializing sensor data messages and writing them to disk, which adds I/O overhead and may increase memory usage. For high-frequency sensor data or long-running simulations, consider the trade-off between data capture and simulation performance. Monitor disk I/O and available storage space, as MCAP files can grow large depending on the sensor data payload size and simulation duration.
Playing Back Recorded Sensor Data
Recorded MCAP files can be played back using theAvxSensorDataPlayer utility class. This allows you to replay sensor data offline without requiring a live AVxcelerate Sensor connection. Each recorded message is of type ansys::api::avxcelerate::sensors::v1::sensor_data::SensorData and can be used for debugging or analyzing purposes (e.g., inspecting camera images, lidar point clouds, or radar detections after a simulation run).
Basic usage:
- Follow API Instructions: Always follow the usage instructions documented in the Doxygen comments in
avx_sensor_data_player.h. In particular, callHasNext()before callingGetNext()to ensure proper message availability checking. - Performance Considerations: AVx Sensor Data messages can have very high payload sizes (e.g., high-resolution camera images, dense lidar point clouds). When processing large messages or high-frequency playback, be aware of:
- Memory Usage: Each
GetNext()call returns a complete copy of the protobuf message, which may consume significant memory for large sensor data payloads. - Processing Time: Deserialization and processing of large messages may take considerable time. Consider implementing appropriate buffering or streaming strategies for real-time applications.
- I/O Performance: Reading from large MCAP files may involve significant disk I/O, especially when seeking or resetting playback position.
- Memory Usage: Each
avx_sensor_data_player.h.
Data format
When sensor data publishing is enabled (enable_publisher is true), the AVxcelerate Sensor activity publishes sensor data to the specified topic in the following format:
- Topic: The topic name specified in
publish_topic_name - Message Type:
rtidds::GenericBytesMessage - Content: Serialized sensor data descriptions containing metadata and data references
Usage in other activities
Other activities in the simulation framework can subscribe to the sensor data topic to receive and process sensor outputs. For example, a visualization activity could subscribe to receive camera images, or a perception activity could receive lidar point clouds. Example subscription in another activity:SensorDataDescription from received bytes in the topic, a static method DeserializeSensorDataDescriptions(bytes) is provided in AvxVssApiAdapter class.
Data retrieval
To access the actual sensor data content, activities need to:- Subscribe to the sensor data topic to receive data descriptions
- Use the VSS API to retrieve the actual sensor data using the data IDs from the descriptions
- Parse the data according to the sensor type and format
Supported sensor types
The sensor data access mechanism supports various sensor types including:- Camera sensors: Image data with metadata (width, height, pixel format, etc.)
- Lidar sensors: Point cloud data
- Radar sensors: Radar detection data
- Thermal cameras: Temperature map data
Prerequisites and Setup
Before using AVxcelerate Sensor co-simulation, ensure you have:- AVxcelerate Sensor Service: A running AVxcelerate Sensor service accessible via gRPC endpoint
- Valid License: Proper ANSYS license setup for AVxcelerate Sensor and Simfwk
- Asset Files: Required AVxcelerate asset files (
.assetformat) for your simulation objects and resolvable by AVxcelerate Sensor - Track Files: Required AVxcelerate Track files (
.trackformat) for your simulation objects and resolvable by AVxcelerate Sensor - Sensor Configurations: Valid sensor configuration files (
.sencfgxand parameter files, generated by AVxcelerate Sensor Lab)
Network configuration
The AVxcelerate Sensor co-simulation uses gRPC for communication. Ensure:- The specified
GrpcHostandGrpcPortare accessible - No firewall restrictions block the gRPC connection
- The AVxcelerate Sensor service is running and listening on the specified endpoint
File paths
All file paths in the configuration can be:- Absolute paths: Full system paths (e.g.,
/opt/Ansys/AVX_Library_v261/Assets/...) - Relative paths: Relative to the working directory when running the simulation
Troubleshooting
-
Connection timeout
-
Example of timeout error by start-up connection
-
How to solve:
- Verify the AVxcelerate Sensor service is running and correct gRPC endpoint is set
- Check network connectivity and firewall settings
- Increase the
timeout_in_secvalue if needed
-
Example of timeout error by start-up connection
-
Connection drop
-
If the AVxcelerate Sensor service dies during simulation or the connection is broken, the simulation will be aborted on the Simfwk side and the
Unloadoperation will also likely timeout. In this case, you might have some outputs from both Simfwk and AVxcelerate Sensor from previous successful cycles, but be cautious when using those results. To resolve this issue, restart the AVxcelerate Sensor service or fix the connection problem, then rerun the simulation completely to ensure complete and valid results.
-
If the AVxcelerate Sensor service dies during simulation or the connection is broken, the simulation will be aborted on the Simfwk side and the
-
Configuration file errors
-
Ensure all required fields are present in the configuration. Example error of missing
AvxSensorParameter: -
Verify file paths exist and are accessible. Example error of missing
*.sencfgxfile: -
Check JSON syntax validity. Example error in wrong json syntax:
-
Ensure all required fields are present in the configuration. Example error of missing
-
Track or object mapping issues
- Confirm
OpenScenarioobject names match exactly. Example error when wrong object name is given:
- Verify AVxcelerate asset and track files exist and are valid, accessible by AVxcelerate Sensor. Example error when track file is not accessible to AVxcelerate Sensor:
- Confirm
Performance considerations
- Cycle Time: The AVxcelerate Sensor activity inherits its cycle time from its dependencies. Consider the computational requirements of your sensor model when setting cycle times.
- Network Latency: gRPC communication adds latency. For real-time simulations, ensure low network latency between the simulation framework and AVxcelerate Sensor service.
- Resource Usage: AVxcelerate Sensor processing can be computationally intensive. Monitor system resources during simulation.
Limitation
The current implementation of AVxcelerate Sensor co-simulation has the following limitations:-
OSI to VSS Conversion: When
use_vss_osi_apiis set tofalse, the current converter only supports moving objects from OSI SensorView to VSS WorldUpdate. Static objects and pedestrians are not yet supported. This limitation does not apply whenuse_vss_osi_apiis set totrue, as the VSS OSI API (available in AVxcelerate Sensor v261+) supports native OSIosi3::SensorViewformat, eliminating the need for conversion from Simulation Framework. Please refer to AVx Sensors documentation for details on how AVx Sensors convert OSI objects, weather conditions, and other simulation data into the AVx Sensors world representation. - VSS API Compatibility: The implementation is based on the current VSS API (v261). Future VSS API changes may require updates to the converter and adapter components.
- Error Recovery: Limited error recovery mechanisms. If the AVxcelerate Sensor service becomes unavailable, the simulation may need to be restarted.
- Configuration Validation: File existence validation is limited to sensor configuration files. Track and asset file existence is not validated by Simfwk.