OrientationController:
Filter:
3Dj/Classes (extension) | Libraries > 3Dj

OrientationController
ExtensionExtension

A class for managing interaction with an orientation sensing device

Description

This class provides a convenience method for easy access to the events generated by an orientation sensing device, for instance a smartphone.

Devices communicate via OSC, and for the moment they should be connected to the same subnet.

Logger/playback (aka looper) functionality is also available.

NOTE: In order to avoid reference system problems, the 0º azimuth is taken as the first azimuth angle received

Message format

Any application compilant with the message format is able to communicate with the orientation controller.

The three messages are:

Class Methods

.new

Instance Methods

Sensing

.acceleration

Get the current sensed acceleration

.gravity

Get the current sensed gravity

.azimuth

Get the current azimuth (yaw) value

NOTE: Reference azimuth (=0) is considered as the first received azimuth value

.elevation

Get the current elevation (pitch) value

.roll

Get current roll value

.setAction

Set an action to be performed when a new sensor value is received

Arguments:

key

a Symbol representing the kind of data. Possible values:

  • \orientation
  • \gravity
  • \acceleration
aFunc

the Function to be performed. Two arguments will be passed to the function:

  • args : For gravity and acceleration sensors, an Array with the sensed acceleration [x,y,z]. For orientation sensor, an Array in the form [azimuth,elevation,roll].
  • time : Timestamp of the received message

.enableOscListeners

Enable sensor listening

.disableOscListeners

Disable sensor listening

Log control

.log

Set whether to start or stop logging the sensor activity

Arguments:

state

a Boolean

.logging

Get if this is currently logging data

Playback control

.replay

If currently there is no playback, start it

Arguments:

repeat

number of repetitions

.pause

Pause the playback

.resume

Resume the playback from where it was paused

.stop

Stop playback

.isPlaying

Answers whether the class is playing back

Examples