Sensors are plug-ins that interface between Vizard and hardware. Sensors make the functions and data provided by the hardware manufacturers' APIs available to Vizard. One of Vizard's strengths is the variety of hardware connections it supports as standard features. You will want to work directly with sensor objects if you need access to the raw sensor data (e.g., you are performing a special function with the data or perhaps saving the data to disk).
To access a sensor's data:
Example:
Most sensors represent a 3DOF or 6DOF device. In this case you should use the following methods to get position/rotation data from the sensor.
Sensor method |
Description |
<sensor>.getPosition(flag=0) |
Get the [x,y,z] position. |
<sensor>.getEuler(flag=0) |
Get the [yaw,pitch,roll] euler rotation. |
<sensor>.getAxisAngle(flag=0) |
Get the [x,y,z,deg] axis-angle rotation. |
<sensor>.getQuat(flag=0) |
Get the [x,y,z,w] quaternion rotation. |
<sensor>.getMatrix(flag=0) |
Get the 4x4 transform matrix. |
The flag parameter is optional. Some sensors provide multiple position/rotations values, in which case the flag parameter specifies which value to retrieve.
There are special sensors which don't contain any position/rotation data (e.g. 5DT, Cyberglove), or regular sensors which contain extra information. In these cases you can use the following method to retrieve the raw data:
Sensor method |
Description |
<sensor>.getData() |
Returns a list of floating point values. The size of the list depends on the sensor. |
You can also retrieve the name of a sensor using the following method:
Sensor method |
Description |
<sensor>.getName() |
Returns the name of the sensor. |
Extension sensors are a newer form of sensors that support more advanced behaviors. The interface for extension sensors is similar to regular sensors. Extension sensors can also support button data, which can be accessed through the following methods:
Sensor method |
Description |
<extSensor>.getButtonState() |
Get the state of the buttons as a bit flag. |
<extSensor>.getButtonCount() |
Get the number of buttons on sensor. |
<extSensor>.isButtonDown(button) |
Returns whether the specified button is currently down. |
Extension sensors can also trigger the following button related events:
Sensor event |
Description |
Called when a sensor button is pressed. |
|
Called when a sensor button is released. |