Enter Your Electronics & Design Project for a chance to win a Grand Prize of a SNES Classic and $200 Shopping Cart of Product! | Project14 Home | |
Monthly Themes | ||
Monthly Theme Poll |
The next step in my augmented reality for the Project14 electronic toy challenge, after checking that I do seem to be able to display the Pixy cam processed image onto a display, is to create a headset that will detect rotation and tilt and transfer that information to the servo motors controlling the pan and tilt of the Pixycam.
To confirm that all the parts seem to be working and to obtain some feel for the way the system will operate I have just used one output from the rotation sensor connected to one servo motor. The sensor I am using is a BN0055 IMU from Adafruit and to start with I am only using the X rotation angle which varies between 0 and 360 degrees. The particular servo motor I am using rotates in the opposite direction to the value provided by the sensor so I have just subtracted the sensor value from 360 to create an angle that matches the servo motor direction. Also, the servo motor will only rotation 0 to 180 degrees so for a quick fix I have just limited the value sent to the servo motor to 180 degrees if the sensor rotation angle is greater than 180 degrees. This does create a problem in that the sensor produces angles continuously where 0 is adjacent to 360 degrees and is a modulo 360 value. This means the servo suddenly changes from 180 degrees to 0 degrees when rotating past 360 degrees. I'll have to think how best to fix that problem.
I have used the example program provided by Adafruit for their sensor so there is nothing much special about it. I have listed the statements converting sensor angle to servo angle below.
while (1)
{
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
/* Display the floating point data */
Serial.print("X: ");
Serial.print(euler.x());
servo_angle = 360 - euler.x();
Serial.print(" Servo: ");
Serial.print(servo_angle);
Serial.print(" Y: ");
Serial.print(euler.y());
Serial.print(" Z: ");
Serial.println(euler.z());
// Serial.print("\t\t");
if (servo_angle > 180) servo_angle = 180;
scan_servo.write(servo_angle);
I will need to calibrate the servo motor as currently it only rotates between 20 and 122 degrees in order to avoid entangling with bits of the mobile robot chassis. As I will have to make a better two axis servo motor mechanism at some point I didn't bother messing about with it currently.
Below is a video showing this first stage of testing which I hope the system working mostly. There does seem to be some problem with the calibration of the BN0055 sensor as the angle does seem to change for some reason I have not yet identified. I will have to do some more tests on it.
Dubbie
Top Comments