This project assumes you have completed the following guides:
The Rover is controlled by the orientation of the Spatial Phidget while it is being held in someone's hand. Tilting forward or back will move the rover forward or back. Tilting the Phidget left or right will result in the rover turning to the left or right.
Converting Sensor Data
The Spatial Phidget's accelerometer can measure all accelerations experienced by the sensor, including the acceleration due to gravity. As this acceleration always points down, it can be used to calculate orientation. Read the Calculating Tilt Angles Tutorial for a detailed explanation.
Once you have read the tutorial here are the relevant equations for reference:
`theta = "roll angle "phi = "pitch angle"`
`M_x = "Measured x-axis acceleration"`
`M_y = "Measured y-axis acceleration"`
`M_z = "Measured z-axis acceleration"`
In your Rover Kit, you converted thumbstick values into motor commands. In this project, you can retrofit that code by plugging in our Spatial data in place of the thumbstick commands.
Here you'll need to create Phidget Objects, attach Phidget Listeners and begin the control loop. Use this code snippet and flowchart to get started.
Don't worry if your programming language is not displayed below. The flowcharts are all you need to complete this project.
Here you will update the tilt values in the listener and store them for later use. First the raw accelerometer data must be converted to a tilt angle. Next rescale the control value such that a 90 tilt forward will correspond to a control input of 1.
Note: accelerometer data comes in an array of three values, one for each axis.
Update the motors target velocity using the accelerometer tilt data.
The Rover's path is now in your hands.
Have a cool project or suggestions for future education projects? Let us know at email@example.com