This is a very powerful tile, which allows you to have direct access to the Motion sensors built into your phone. Including Accelerometer, Gyroscope, and Magnetometer. There are several refined data options and there are raw data options available for you to make use of.
This is a unique String ID assigned to this tile and is used (by you) to identify what tile sent what data by your script.
Note that this is case sensitive, and cannot contain any white space.
This tile accepts input so you can use the send message function built into the server to send a value to this tile. This tile only accepts String. If you send "START", the motion tile will begin to send data.
String → "START" → Start sending motion data. (Enable the tile)
String → "STOP" → Stop sending motion data. (Disable the tile)
Tell the motion tile to begin sending data.
self.force.sendMessage("Jordan's iPhone", "Motion", "START")
The following is what data is sent from this tile to the server/your script. It is in the format:
Action → Data Type → Value
Raw Accelerometer Refreshed → Dictionary → {
"Event" : String → "RawAccelerometer"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'RawAccelerometer': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Raw Gyroscope Refreshed → Dictionary → {
"Event" : String → "RawGyroscope"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'RawGyroscope': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Raw Magnetometer Refreshed → Dictionary → {
"Event" : String → "RawMagnetometer"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'RawMagnetometer': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Acceleration From Device Motion Refreshed → Dictionary → {
"Event" : String → "AccelerationFromDeviceMotion"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'AccelerationFromDeviceMotion': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Gravity Acceleration From Device Motion Refreshed → Dictionary → {
"Event" : String → "GravityAccelerationFromDeviceMotion"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'GravityAccelerationFromDeviceMotion': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Magnetic Field From Device Motion Refreshed → Dictionary → {
"Event" : String → "MagneticFieldFromDeviceMotion"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'MagneticFieldFromDeviceMotion': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Raw Device Motion Refreshed → Dictionary → {
"Event" : String → "RawDeviceMotion"
"Value" : {
"ACCX" : Float
"ACCY" : Float
"ACCZ" : Float
"GRAVX" : Float
"GRAVY" : Float
"GRAVZ" : Float
"ROTX" : Float
"ROTY" : Float
"ROTZ" : Float
"MAGX" : Float
"MAGY" : Float
"MAGZ" : Float
"MAGACC" : Float → Magnetic Field Accuracy
"ATTROLL" : Float
"ATTPITCH" : Float
"ATTYAW" : Float
"ATTROTATIONMATRIX" : {
"M11" : Float
"M12" : Float
"M13" : Float
"M21" : Float
"M22" : Float
"M23" : Float
"M31" : Float
"M32" : Float
"M33" : Float
}
"ATTQUATERNION" : {
"W" : Float
"X" : Float
"Y" : Float
"Z" : Float
"TIMESTAMP" : String
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'RawDeviceMotion': # Read the Accelerometer Values accx = data["Value"]["ACCX"] accy = data["Value"]["ACCY"] accz = data["Value"]["ACCZ"] # Read the Gravitational Acceleration Values gravx = data["Value"]["GRAVX"] gravy = data["Value"]["GRAVY"] gravz = data["Value"]["GRAVZ"] # Read the Rotational Movement Values rotx = data["Value"]["ROTX"] roty = data["Value"]["ROTY"] rotz = data["Value"]["ROTZ"] # Read the Magnetometer Values magx = data["Value"]["MAGX"] magy = data["Value"]["MAGY"] magz = data["Value"]["MAGZ"] magacc = data["Value"]["MAGACC"] # Read the Attitude Roll, Pitch, and Yaw attRoll = data["Value"]["ATTROLL"] attPitch = data["Value"]["ATTPITCH"] attYaw = data["Value"]["ATTYAW"] # Read the Attitude Rotation Matrix Values rotm11 = data["Value"]["ATTROTATIONMATRIX"]["M11"] rotm12 = data["Value"]["ATTROTATIONMATRIX"]["M12"] rotm13 = data["Value"]["ATTROTATIONMATRIX"]["M13"] rotm21 = data["Value"]["ATTROTATIONMATRIX"]["M21"] rotm22 = data["Value"]["ATTROTATIONMATRIX"]["M22"] rotm23 = data["Value"]["ATTROTATIONMATRIX"]["M23"] rotm31 = data["Value"]["ATTROTATIONMATRIX"]["M31"] rotm32 = data["Value"]["ATTROTATIONMATRIX"]["M32"] rotm33 = data["Value"]["ATTROTATIONMATRIX"]["M33"] # Read the Attitude Quaternion Values quatW = data["Value"]["ATTQUATERNION"]["W"] quatX = data["Value"]["ATTQUATERNION"]["X"] quatY = data["Value"]["ATTQUATERNION"]["Y"] quatZ = data["Value"]["ATTQUATERNION"]["Z"] # Read the timestamp of the data readings timestamp = data["Value"]["TIMESTAMP"]
Attitude From Device Motion Refreshed → Dictionary → {
"Event" : String → "AttitudeFromDeviceMotion"
"Value" : {
"ROLL" : Float
"PITCH" : Float
"YAW" : Float
"ROTATIONMATRIX" : {
"M11" : Float
"M12" : Float
"M13" : Float
"M21" : Float
"M22" : Float
"M23" : Float
"M31" : Float
"M32" : Float
"M33" : Float
}
"QUATERNION" : {
"W" : Float
"X" : Float
"Y" : Float
"Z" : Float
}
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'AttitudeFromDeviceMotion': # Read the Roll, Pitch, and Yaw roll = data["Value"]["ROLL"] pitch = data["Value"]["PITCH"] yaw = data["Value"]["YAW"] # Read the Rotation Matrix Values rotm11 = data["Value"]["ROTATIONMATRIX"]["M11"] rotm12 = data["Value"]["ROTATIONMATRIX"]["M12"] rotm13 = data["Value"]["ROTATIONMATRIX"]["M13"] rotm21 = data["Value"]["ROTATIONMATRIX"]["M21"] rotm22 = data["Value"]["ROTATIONMATRIX"]["M22"] rotm23 = data["Value"]["ROTATIONMATRIX"]["M23"] rotm31 = data["Value"]["ROTATIONMATRIX"]["M31"] rotm32 = data["Value"]["ROTATIONMATRIX"]["M32"] rotm33 = data["Value"]["ROTATIONMATRIX"]["M33"] # Read the Quaternion Values quatW = data["Value"]["QUATERNION"]["W"] quatX = data["Value"]["QUATERNION"]["X"] quatY = data["Value"]["QUATERNION"]["Y"] quatZ = data["Value"]["QUATERNION"]["Z"]
Rotation Rate From Device Motion Refreshed → Dictionary → {
"Event" : String → "RotationRateFromDeviceMotion"
"Value" : {
"X" : Float
"Y" : Float
"Z" : Float
}
}
When the data is received from the Motion tile, read it and store it into a variable for later use.
def forceServerDidReceiveData(self, deviceName, senderTag, data): if senderTag == 'Motion': if data["Event"] == 'RotationRateFromDeviceMotion': x = data["Value"]["X"] y = data["Value"]["Y"] z = data["Value"]["Z"]
Note that a tile's tag is always sent to the server for identification purposes.
Click the Show Python buttons above to see a usage demo for each type of input from a Myo Armband.