Sensor
Last updated
Last updated
Sensors are detecting MUs. The sensor can use BoxColliders or Raycasts for collision detection. A behavior component (e.g. Sensor_Standard) must be added to the Sensor for a connection to a PLC’s Input and Outputs.
This tutorial explains first steps with Sensors:
This picture shows a configured Sensor using Colliders in the demo model:
Because collisions are used to detect the Sensor status you need to take care that the sensor game object is on the appropriate collision layer which should be normally g4aSensor.
Because of limitations in the collision detection of Mesh Colliders you should always use Box Colliders with Sensors.
The Sensor can change the color by changing the material of the sensor. For this, you need to select Display Status.
Another way for implementing Sensors is to use Raycasts. The advantage of a Raycasts is, that you don’t need to define colliders and you are totally free which Layers you would like to check with the Raycast.
Because there is no sensor geometry connected to a Raycast Sensor you need to define the Raycast Direction from the pivot point of the Gameobject and the Raycast length, as usual in mmm in realvirtual.io. In the game view the Raycast is shown as a Line Renderer which is automatically created on simulation start.
If the sensor is using Raycasts, the Raycast is always checked against colliders on the same Layer then the Sensor Gameobject itself. Optionally you can define additional Raycast Layers.
Raycast always needs to start before the collission with the detected component. Please make sure that the start of the sensor raycast is never inside of an object with needs to be detected.
It is possible to limit the sensor function to a certain Tag of the MU. You must enter the Tag in the property Limit Sensor To Tag.
The current sensor status can be inspected under the section Sensor IO’s.
Please check the Realvirtual.io Class Reference for more information about the properties and methods of this component.
You can subscribe to the Unity Events on the Sensor.
Event MU Sensor is called on every MU detected by the Sensor.
Event Non MU Gameobjet Sensor is called for all colliders without an MU script that are colliding with the Sensor.
Besides the color of the sensor you can check the state of the sensor in the section Sensor Status in the Inspector of the Sensor.
The Sensor_Standard component provides the standard Sensor behavior and connectivity to the PLC inputs and outputs. With the property NormallyClosed=true it can be selected, as the sensor is true and the sensor is not occupied.
The Sensor_Standard is a blueprint for additional sensors that return various values such as distance, speed etc. to the PLC. We suggest you use this template as the starting point for building your own sensors.
© 2022 in2Sight GmbH https://realvirtual.io - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.