VectorNav Unity Library
getting_started

This example illustrates communicating with a VectorNav sensor over a serial port.

Windows

  1. Open Unity and then open the project located at <root>/unity/examples/getting_started.

  2. You may need to load the rotating_cube.unity scene. This may be done by going to the Project tab at the bottom and selecting the scene located at Assets/Scenes/rotating_cube.unity.

  3. With a VectorNav sensor plugged in, start running the scene by clicking the play button at the top of Unity. The scene scripts will then start searching for any attached sensor and automatically connect to the first one once found. After the sensor is connected, the orientation data (yaw, pitch, roll) from the sensor will be used to drive the displayed orientation of the displayed cube. The script file SensorRotateObject.cs contains details and comments describing the process of connection and updating the cube's orientation.

Android

  1. You will need to make sure you have an Android phone attached to the computer with debug mode enabled. You will also need an adapter that will allow you to connect the USB cable of your VectorNav sensor into the Micro USB port of your phone. Please see the FAQ's How do I connect a VectorNav sensor to an Android phone? for information on getting a proper adapter.

  2. Open Unity and then open the project located at <root>/unity/examples/getting_started.

  3. You may need to load the rotating_cube.unity scene. This may be done by going to the Project tab at the bottom and selecting the scene located at Assets/Scenes/rotating_cube.unity.

  4. Change the build target by going to the menu File -> Build Settings... and for the Platform option, select the Android option.

  5. Now build and deploy the application by clicking the Build And Run button. You will be asked to save the application package file (*.apk). Choose a name and location. Unity should then push the application to the phone and start running it. Once the cube is displayed on the phone, disconnect the phone from the computer and plug the VectorNav sensor into the phone. The program should then detect the sensor and start moving the displayed cube based on the orientation data coming from the sensor. If the message "Allow application getting_started to access USB device?" pops up, click the OK button.