Playstation Move UDP API

From Immersive Visualization Lab Wiki
Jump to: navigation, search

Contents

Project Overview

This project is an attempt to create a simple interface to the PS Move API via a local UDP server.

Features

  • Ability to receive all physical data from the move including:
    • Button presses
    • Analogue trigger value
    • Accelerometer data
    • Gyroscope data
    • Magnetometer data
  • Positional data of the Move Controllers using the Eye
  • Multiple Controllers
  • Rumble and LEDs can be set by client

TODO

  • Ability to send data back the to Move controllers such as Rumble and LED requests
  • Allow user to select Move Tracker color at beginning (either as option or .txt file).
  • Allow user to change ip/port of send/recv server. (Port remains static)
  • Minimize drift in the orientation of the Move.
  • Thread the menu and udp send functions.

Installation

Download Move API for Windows (New version as of 02/02/2016).

Setting up the Playstation Eye

Adapted from this guide.

  1. Insert PS Eye camera into an USB 2.0 port or above. Should appear as 'USB Camera-B4.09.24.1' or something similar in device manager.
  2. Navigate to /move_api/Install/PS Eye/
  3. Run Zadig and install libusb-win32 (Use the vertical arrows) onto 'USB Camera-B4.09.24.1' (Interface 0 on my machine)
    • If no devices appear for installation tick "Options->'List All Devices'"
    • NOTE: Don't install onto 'Interface 1', this will already have usbaudio installed.
  4. Close Zadig.
  5. Test the performance of the camera with 'test_camera.exe'. Hopefully a video stream appears!

If there is visible tearing/laggy footage:

  • Try installing the WinUSB driver with Zadig instead.
  • Ensure the Eye is the only USB device connected to the USB hub if possible.
  • Try another USB Port.

Other notes:

  • Camera is calibrated for the blue zoom.
  • Red light should come on when it is recording.
  • If the camera isn't recognized, use another USB port.
  • If you're getting a whole bunch of errors (10-15 lines) you may need to disable built in cameras on your computer in device manager. We had problems with a Surface laptop.

Setting up a Playstation Move Controller

Adapted from this guide.

  1. Make sure the controller has charge before beginning or you won't be able to pair via bluetooth.
    • NOTE: Windows 10 and wall chargers have trouble charging the Move Controller.
    • Windows 7 and Mac work from my own testing.
    • When the controller is charged pressing the 'PS' button will cause the LED on the controller to flash.
  2. Connect the PS Move Controller with USB and make sure your Bluetooth is on.
  3. Navigate to /move_api/Install/PS Move/
  4. Use the 'psmovepair.exe' utility to save the Bluetooth address to the controller. Follow instructions in application, including unplugging the controller. The util will fail past this point though.
  5. Close 'psmovepair.exe'.
  6. Warning: This step is easily the most frustrating. The controller seems to pair fairly randomly, once it does pair however you only need to press the 'PS' button to connect the next time. Best of luck!
    Run 'psmove-pair-win.exe'.
    • Press the 'PS' button and allow the utility to run. If the LED stops flashing press the 'PS' button again.
    • Basically continue this process until you get a successful connection, there doesn't seem to be a trick to it unfortunately.
    • NOTE: If the controller is low on battery a successful connection can look like it's still pairing (flashing LED)
    • A successful pairing will show up as 'CRE CRE CRE CRE' or something similar in the utility.
  7. Once the controller has paired you can close 'psmove-pair-win.exe'.
  8. Finally, run the 'magnetometer_calibration.exe' utility.
    1. Rotate the controller until you get a value 250+
    2. Click the 'Move' button.
    3. Stand the controller on its end on a flat surface with the 'PS' button facing you.

Notes:

  • If you get the error message "Ignoring non-USB PSMove #number" on the psmovepair.exe utility before you have any successfully connected moves I've found a hacky solution.
    1. Download the psmove_pair_ignore_warnings.zip
    2. Run the new 'psmovepair.exe' and follow the steps 4-8.
    3. When you run the 'magnetometer_calibration.exe' utility, you will probably run into an error regarding un-calibrated accelerometer values. (If not, ignore the next parts)
    4. To remedy this, copy the '00_13_8a_91_db_c9.calibration' file from the zip file to 'C:\Users\<username>\AppData\Roaming\.psmoveapi'
    5. Rename this file to the name of your controller (this can be found in the error message from the magnetometer_calibration.exe)
    6. Run the magnetometer_calibration.exe again. If it succeeds the controller is ready to use with the server.

Using Move Server

Open 'move_udp_server.exe'.

  1. Choose the desired network interface. Use 'local loop' if you're just using your computer.
  2. To calibrate the tracker for each controller, hold each controller approx 10cm from the camera.
  3. To calibrate the orientation of each controller face the controller to the camera with no roll and the MOVE button facing the roof.
  4. At the end of this process you should see 'Server Started' and a menu of options.
  5. For the server to start streaming you need to send it a 'connect' message.
    • Send the string "connect" to:
IP: '127.0.0.1' (or another interface)
Port: 23460
6. If successful you will see "Client connected. Streaming data to xxx.xxx.xxx.xxx:23459"
7. To listen for data bind to the UDP stream at:
IP: '127.0.0.1' (or another interface)
Port: 23459

Receiving Data Format

The server sends 2 different messages.

  • Type 'a': Move Physical Data (High frequency, around 100hz)
  • Type 'b': Move Positional Data (Slower, depends on machine)

Type 'a' message

msgType msgNo controller currButtons triggerVal ax ay az gx gy gz
Example a 1022 0 128 54 1.000 -0.456 0.234 0.123 0.123 -0.435
cont... mx my mz orientationEnabled qw qx qy qz r g b
Example -0.363 0.234 0.635 1 0.990 -0.033 0.133 -0.027 94 255 0
  • msgType: char - 'a'
  • msgNo: int - Begins at 0 and increments for each 'a' type message
  • controller: int - Controller number (starts at 0)
  • currButtons: int - Between 0-255. Stores button presses bitwise.
CROSS, SQUARE, TRIANGLE, CIRCLE, MOVE, START, SELECT, PS
eg - 01001000 Means SQUARE and MOVE are pressed.
  • triggerVal: int - Between 0-255, 0 means trigger is unpressed, 255 means fully pressed.
  • ax, ay, az: float - Accelerometer values. Measured in 'g' m.s-2. Standing the move on its end approx az = -1.
  • gx, gy, gz: float - Gyroscope values. Measured in rad.s-1. x-axis pitch, y-axis roll, z-axis yaw.
  • mx, my, mz: float - Magnetometer values. Between -1 and 1.
  • orientationEnabled: int - Either 0 or 1, running the magnetometer calibration is necessary to get the quarternion of the Move.
  • qw, qx, qy, qz: float - Quarternion of the move controller. Only read if orientationEnabled is 1.
  • r, g, b: int - In range 0 - 255, the current color of the blob.

Type 'b' message

msgType msgNo controller tx ty tz ux uy trackingMove
Example b 52313 0 10.24 20.53 10.3 0.342 0.623 1
  • msgType: char - 'b'
  • msgNo: int - Begins at 0 and increments for each 'b' type message
  • controller: int - Controller number (starts at 0)
  • tx, ty: float - x and y position of the PS Move light measured in cm from the center of the camera.
Note that as you move further from the camera you can get further horizontally/vertically
  • tz: float - z position of the PS Move light measured in cm.
  • ux, uy: float - normalised x and y positions between 0 and 1. Like tx and ty, the further you are from the camera the larger the viewing plane of the camera.

Sending Data Format

You can also send certain information to the server to control the LED and Rumble states of each Move. Connect and send data to:

IP: '127.0.0.1' (or another interface)
Port: 23460

Data format

msgType controller changeRumble rumble resetOrientation trackerLight changeLight r g b
Example d 0 0 0 0 128 1 255 0 255
  • msgType: char - 'c'
  • controller: int - Controller number (starts at 0)
  • changeRumble: int - 0 or 1. If '1' the value of 'rumble' will be applied to the controller
  • rumble: int - Between 0-255. Note that the rumble will timeout after a short period. If you want the Move to rumble continuously you must continually send packets.
  • resetOrientation: int - 0 or 1. If '1' the Move will set its 'flat, no roll, facing the screen' (identity) orientation to the current orientation of the Move.
  • trackerLight: int - 0 or 1. If '1' the Move will revert its light to the one the tracker set for it.
  • changeLight: int - 0 or 1. If '1' the Move will change its light to the given r, g, b values. Note: if trackerLight is '1' this has no effect.
  • r, g, b: int - Between 0-255. Values of red, green and blue to set Move color. Requires changeLight '1' to take effect.
IMPORTANT: If you change the color of a Move controller, tracking most likely won't work. To resume the Move to its tracking color set the trackerLight flag.

Using with Unity

Download Unity package. (New version as of 1/02/2016)
Install/Using instructions:

  1. Copy the C# scripts to your assets folder.
  2. Create an empty GameObject, name it 'moveServer', and place it in the scene and add the 'MoveServer.cs' script to it.
    • The server will now run on startup.
  3. To use the server, simply create a 'public MoveServer moveServer' in your objects script and drag the GameObject to the field.
    • Your script will also need 'using MoveServerNS'.
  4. To read data from a controller call moveServer.getController(c) to get a reference to the controller.
    • While the server is running you should get a steady stream of data accessible through the MoveController reference.
  5. To send data to a controller use the 'Send_' methods on MoveServer.

Troubleshooting

Bad Tracking

Large amounts of natural light and bright spots (such as lights) affect the ability of the Eye to track the Move. Unfortunately the only real solution to this is to move to a darker area.

Bad Calibration

If you find you are getting bad gyro/accel/magnetometer values (even after you have re-calibrated) you can clear the calibration files. They are found at 'C:\Users\<username>\AppData\Roaming\.psmoveapi'

Drift Issues

The Move's orientation quaternion can drift overtime. If this occurs you can recalibrate using the server menu, or by sending the 'resetOrientation' flag.

Physical Data Stops

Currently if you type into the menu the physical data stream will hold. Press enter to resume the stream.

Additional Information

Developers

Software Developer

  • Lachlan Smith

Project Advisor

  • Jurgen Schulze

Resources