Using collision groups¶
What are collision groups?¶
The dynamic and static physics objects can be assigned to specific collision groups. All objects are in collision group 0 by default, which means that they collide with all other physics objects.
The settings for the collision groups can be found in the section "Expert settings -> Physics properties -> Collision settings". These consist of the two properties "Collision group" and "Additional collision groups".
Difference between "Neutral while Collision" and different collision groups¶
Before we explain the collision groups in more detail, we want to clarify the difference to the property "Neutral while collision" in the section "Main settings->Limit switch settings".
If the property "Neutral while collision" is selected, the object set in this way does not exert any force on a possible collision partner. So another object can pass the object without affecting the movement of the other object. However, the object with the property "Neutral while collision" can "sense" the collision (if the collision group setting allows this). If the object is configured as a limit switch, then the limit switch operand is changed in status.
As can be seen in the following example. A blue rectangular object falls down from above. In the center a green rectangle object is configured as a limit switch; the property "Neutral while collision" is also selected. The limit switch operand was specified on the LED, so it is illuminated as soon as the limit switch is actuated.
The layout shows that the limit switch does not influence the falling object, but it "senses" the collision and thus the limit switch operand is changed in status.
In the next step, the layout is changed. The falling rectangle is assigned to collision group 1. The limit switch is assigned to collision group 2.
After these changes, the limit switch no longer "senses" a collision with the falling rectangle, which now belongs to a different collision group. Thus the limit switch operand is no longer changed in status and the lamp is also no longer illuminated.
The two examples clearly show the difference between the property "Neutral while collision" and belonging to different collision groups.
Using collision groups¶
Areas of application for collision groups are, for example, layouts with separators or filters.
The following image shows such a layout.
The blue circle object and the brown rectangle at the bottom belong to collision group 1. These two objects collide with each other. The grey circle object belongs to collision group 2, so it does not collide with the brown rectangle. The black rectangles of the containers are all set to collision group 0, so they collide with all objects.
The simulation shows the following behaviour:
The circle objects are separated. The grey circle objects fall through the inclined plane; the blue circle objects collide with it and are separated into the container on the right.
A further use is the visualization of different layers on top of each other.
The picture shows two conveying elements that are arranged one above the other. The blue conveying element influences objects of collision group 1, to which the blue circle object belongs. An additional conveyor element is placed vertically. This is set to collision group 2. The yellow circle object belongs to this group.
The layout shows the following behavior in the simulation:
The two conveying elements and their objects do not influence each other.
The property "Additional collision groups"¶
The property "Additional collision groups" can be used to specify a collision group with which the object also collides. In addition to its own collision group. For example, if the object is assigned to collision group 2 and the property "Additional collision groups" contains collision group 3, then the object collides with other objects in groups 2 and 3.
Several groups can be specified at the property "Additional collision groups"; the numbers must be separated by commas: For example "2, 5, 10".
In the layout shown below, the circle objects belong to different collision groups. The blue circle belongs to group 1, the yellow circle to group 2 and the green circle to group 3.
In the yellow circle object, group 3 is specified in the property "Additional collision groups". Group 2 is specified for the green circle. This results in the following behavior during the simulation.
The blue circle does not influence the other two circle objects because they do not belong to its collision group. The yellow and green circle collide. Although they belong to different collision groups, the other collision group is also specified in the property "Additional collision groups".
This makes it possible to split objects into collision groups and also to set special relationships to other collision groups for individual objects.
Video about collision groups¶
Changing a collision group during a collision with a limit switch¶
As of version 188.8.131.52, a limit switch (or a geometric physics object) can be set so that the collision group of the colliding object is changed in the event of a collision. The two properties "Limit switch changes collision group" and "New collision-group when collide" have been added. The functionality is activated using the "Limit switch changes collision group" property. You have to specify the new collision group to be set in the "New collision-group when collide" property. The entry is made as a constant or variable, e.g. using a word operand (e.g. IM.MW2).
How to change the collision group?¶
If an object collides with the limit switch where the property "Limit switch changes collision group" is selected, the object is assigned to the new collision group. When a body consisting of several objects collides with the limit switch, then all objects of the body are set to the new collision group which belong to the collision group of the object that collides with the limit switch.
A body consists of 4 objects. Two objects belong to collision group 1, the rest to collision group 2. Now an object of collision group 1 collides with a limit switch. Now only the collision groups of the two objects with collision group 1 are changed. The other two objects remain in collision group 2.
An exception to the rule described above is when the collision group 0 is written. If a body group collides with a limit switch and collision group 0 is set as the collision group to be set for this limit switch, this collision group is set for all objects of the body, regardless of their previous collision group. This is due to the fact that the collision group 0 has a special feature: objects of this collision group collide with all other collision groups.
Example for writing a new collision group
In the following example, blue rectangles are created. These are subject to gravity and therefore fall downwards. They activate a limit switch, which changes the collision group of the object. The collision group to be set can be set via a slider object in a range between 1 and 3. Below this there are ramps which are assigned to the respective collision groups 1 to 3 and thus collide only with objects of this group.
Depending on the setting of the collision group to be set, the blue rectangle collides with the corresponding ramp and is transported away with it. This layout with the name "KollisionsGruppeSchreiben_01.plclab" can be found in the directory of documents of the user in "PlcLab-Editor\Examples".
Additional example for writing a new collision group
In the next example, a circle object is transported by a conveying element. On the conveying element there is a limit switch which overwrites the collision group of the circle object in the case of a collision. The collision group to be written can be specified using a slider. Depending on the setting, the circular object is transported away by the auxiliary conveyer 1, 2, or 3.
In the property "Additional collision groups", the auxiliary conveyer have been set so that they only transport objects of collision group 1, 2, or 3. This layout with the name "KollisionsGruppeSchreiben_02.plclab" can be found in the directory of documents of the user in "PlcLab-Editor\Examples".