Class: Phidgets::Spatial

Inherits:
Common
  • Object
show all
Defined in:
lib/phidgets/spatial.rb,
ext/phidgets/phidgets_spatial.c

Instance Method Summary collapse

Methods inherited from Common

#close, #getAttached, #getChannel, #getChannelClass, #getChannelClassName, #getChannelName, #getChannelSubclass, #getDeviceChannelCount, #getDeviceClass, #getDeviceClassName, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceSKU, #getDeviceSerialNumber, #getDeviceVersion, #getHubPort, #getHubPortCount, #getIsChannel, #getIsHubPortDevice, #getIsLocal, #getIsRemote, #getServerHostname, #getServerName, #getServerPeerName, #getServerUniqueName, #open, #openWaitForAttachment, #setChannel, #setDeviceLabel, #setDeviceSerialNumber, #setHubPort, #setIsHubPortDevice, #setIsLocal, #setIsRemote, #setOnAttachHandler, #setOnDetachHandler, #setOnErrorHandler, #setOnPropertyChangeHandler, #setServerName, #writeDeviceLabel

Constructor Details

#newObject

Creates a Phidget Spatial object.



7
8
9
10
11
# File 'ext/phidgets/phidgets_spatial.c', line 7

VALUE ph_spatial_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetSpatial_create((PhidgetSpatialHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getDataIntervalObject Also known as: data_interval

The DataInterval is the time that must elapse before the channel will fire another SpatialData event. The data interval is bounded by MinDataInterval and MaxDataInterval.



13
14
15
# File 'ext/phidgets/phidgets_spatial.c', line 13

VALUE ph_spatial_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetSpatial_getDataInterval);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



26
27
28
# File 'ext/phidgets/phidgets_spatial.c', line 26

VALUE ph_spatial_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetSpatial_getMaxDataInterval);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



22
23
24
# File 'ext/phidgets/phidgets_spatial.c', line 22

VALUE ph_spatial_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetSpatial_getMinDataInterval);
}

#resetMagnetometerCorrectionParametersObject Also known as: reset_magnetometer_correction_parameters

Resets the MagnetometerCorrectionParameters to their default values. Due to physical location, hard and soft iron offsets, and even bias errors, your device should be calibrated. We have created a calibration program that will provide you with the MagnetometerCorrectionParameters for your specific situation. See your device’s User Guide for more information



36
37
38
39
# File 'ext/phidgets/phidgets_spatial.c', line 36

VALUE ph_spatial_reset_magnetometer_correction_parameters(VALUE self) {
  ph_raise(PhidgetSpatial_resetMagnetometerCorrectionParameters((PhidgetSpatialHandle)get_ph_handle(self)));
  return Qnil;
}

#saveMagnetometerCorrectionParametersObject Also known as: save_magnetometer_correction_parameters

Saves the MagnetometerCorrectionParameters. Due to physical location, hard and soft iron offsets, and even bias errors, your device should be calibrated. We have created a calibration program that will provide you with the MagnetometerCorrectionParameters for your specific situation. See your device’s User Guide for more information



41
42
43
44
# File 'ext/phidgets/phidgets_spatial.c', line 41

VALUE ph_spatial_save_magnetometer_correction_parameters(VALUE self) {
  ph_raise(PhidgetSpatial_saveMagnetometerCorrectionParameters((PhidgetSpatialHandle)get_ph_handle(self)));
  return Qnil;
}

#setDataInterval(interval) ⇒ Object Also known as: data_interval=

The DataInterval is the time that must elapse before the channel will fire another SpatialData event. The data interval is bounded by MinDataInterval and MaxDataInterval.



17
18
19
20
# File 'ext/phidgets/phidgets_spatial.c', line 17

VALUE ph_spatial_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetSpatial_setDataInterval((PhidgetSpatialHandle)get_ph_handle(self), NUM2UINT(interval)));
  return Qnil;
}

#setMagnetometerCorrectionParameters(mag_field, offset0, offset1, offset2, gain0, gain1, gain2, T0, T1, T2, T3, T4, T5) ⇒ Object Also known as: set_magnetometer_correction_parameters

Calibrate your device for the environment it will be used in. Due to physical location, hard and soft iron offsets, and even bias errors, your device should be calibrated. We have created a calibration program that will provide you with the MagnetometerCorrectionParameters for your specific situation. See your device’s User Guide for more information.



30
31
32
33
34
# File 'ext/phidgets/phidgets_spatial.c', line 30

VALUE ph_spatial_set_magnetometer_correction_parameters(VALUE self, VALUE mag_field, VALUE offset0, VALUE offset1, VALUE offset2, VALUE gain0, VALUE gain1, VALUE gain2, VALUE T0, VALUE T1, VALUE T2, VALUE T3, VALUE T4, VALUE T5) {
  ph_raise(PhidgetSpatial_setMagnetometerCorrectionParameters((PhidgetSpatialHandle)get_ph_handle(self), NUM2DBL(mag_field), NUM2DBL(offset0), NUM2DBL(offset1), NUM2DBL(offset2),
      NUM2DBL(gain0), NUM2DBL(gain1), NUM2DBL(gain2), NUM2DBL(T0), NUM2DBL(T1), NUM2DBL(T2), NUM2DBL(T3), NUM2DBL(T4), NUM2DBL(T5)));
  return Qnil;
}

#setOnSpatialDataHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_spatial_data

call-seq:

setOnSpatialDataHandler(proc=nil, &block)

Assigns a handler that will be called when the SpatialData event occurs.



11
12
13
14
15
# File 'lib/phidgets/spatial.rb', line 11

def setOnSpatialDataHandler(cb_proc = nil, &cb_block)
  @on_spatial_data_thread.kill if defined? @on_spatial_data_thread and @on_spatial_data_thread.alive?
  callback = cb_proc || cb_block
  @on_spatial_data_thread = Thread.new {ext_setOnSpatialDataHandler(callback)}
end

#zeroGyroObject Also known as: zero_gyro

Re-zeros the gyroscope in 1-2 seconds. The device must be stationary when zeroing. The angular rate will be reported as 0.0°/s while zeroing. Zeroing the gyroscope is a method of compensating for the drift that is inherent to all gyroscopes. See your device’s User Guide for more information on dealing with drift.



46
47
48
49
# File 'ext/phidgets/phidgets_spatial.c', line 46

VALUE ph_spatial_zero_gyro(VALUE self) {
  ph_raise(PhidgetSpatial_zeroGyro((PhidgetSpatialHandle)get_ph_handle(self)));
  return Qnil;
}