Component: Collision Detector Template (Sensors)
Author | Matrix Ltd |
Version | 1.2 (Release) |
Category | Sensors |
Contents
Collision Detector Template component
Polls a chosen panel object to see if it has collided with another object. When collisions happen, a user notification event is generated and a pin is set or reset. Another event is sent when the two objects separate.
This component can be used as a base to create child components
The following components all inherit the traits of Collision Detector Template:
Examples
Simple example showing the collision detector component at work, when a collision is detected the direction of the motor is reversed. Detector Simple example showing the beam break detector component at work, when a collision is detected the direction of the bouncing ball is reversed. Beam Break Demo
Downloadable macro reference
ReadState
Get the current collision state.
The 'Polarity' property will affect whether a collision is represented by a high
or low state.
Parameters
- This macro has no parameters
Return value
WaitUntilHigh
Pause the program until the detector goes high.
'Polarity' will affect whether high value represents a collision or separation.
NB) In simulation, only use this macro if testing for collision with animated or
timer driven objects!!
Parameters
- This macro has no parameters
Return value
- This call does not return a value
WaitUntilLow
Pause the program until the detector goes low.
'Polarity' will affect whether low value represents a collision or separation.
NB) In simulation, only use this macro if testing for collision with animated or
timer driven objects!!
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
SetTarget
Set the object that you want to test for collision with.
If this is not called, or is called with handle = 0, collisions will be tested against
every panel object that has 'Solid' status.
NB) Specifying an object will save CPU power!!
Parameters
- HANDLE Target
- The object to test for collision with.
Return value
- This call does not return a value
Property reference
Pin
This property is of type Single digital pin and can be referenced with the variable name pin.
The pin that should change state when objects collide or separate.
Polarity
This property is of type Fixed list of ints and can be referenced with the variable name polarity.
Active High = Pin is high when objects collide, low when they are separate.
Active Low = Pin is low when objects collide, high when they are separate.
Test Object
This property is of type Panel object and can be referenced with the variable name test_object.
The object to test for collisions.
A user event is sent each time this object collides with any other, or when the two object separate.
Mouse Object
This property is of type Panel object and can be referenced with the variable name mouse_object.
Choose an object that the user can clock on to simulate a collision when testing.
Detector Ident
This property is of type Unsigned integer and can be referenced with the variable name event_id.
An ID value to identify this particular detector. Will be sent as the 'Ident' value for the notification
events sent out so that multiple detectors can be told apart.
Timer Interval (ms)
This property is of type Unsigned integer and can be referenced with the variable name timer_int.
Time in milliseconds between collision scans.
Small time = Greater CPU load
Large time = More like to miss brief collisions.