For my C64 Multiplayer Universe Video I wanted to make a 3D Flight by Hand inside Blender.
That's the reason for this Arduino Project. For this project I've used a SparkFun 9DoF Razor IMU M0 Board with a SAMD21 (ATSAMD21G18 32-bit SAM Microcontroller) and MPU-9250 (Accelerometer, Gyroscope, Magnetometer).
At the Blender side I had to write an Add-On to receive the data of the IMU Board. I like this new Blender Add-On very much, because it’s so easy to use:
- Connect the IMU Board via USB
- Select the USB Port, Baudrate and String Separator
- Select the Object you want to control (“Anim Obj.”)
- Press “Activate IMU”
...and then the camera will fly around in the 3D Space like you hold the IMU board in your hand. The Arduino IMU Board is sending a String with Quaternions (4 numbers as W,X,Y,Z with a separator Character) like this: “0.472,-0.192,0.457,0.8628”
This Video is the final result of the Project: 3D Flight via hand movements:
Step 1: Prepare the Microprocessor Board With the Arduino Sketch
To prepare the Microprocessor Board, you have to follow these steps:
- Unzip the downloaded "Arduino_Workspace_SparkFun_IMU0_MPU9250.zip" file
- Start the Arduino IDE
- In the Arduino IDE select Arduino -> Preferences -> Sketchbook location: press "Browse" and select the unzipped folder, then press "Ok"
- Restart the Arduino IDE
- Take the Sparkfun 9DoF Razor IMU M0 Board and connect the board via USB with your Computer
- Select the Board in the Arduino IDE: Tools -> Board -> Sparkfun 9DoF Razor IMUM0 (if not available: Open the Arduino IDE Board Manager, search for "sparkfun" and install the "SparkFun SAMD Boards")
- Select the right USB Port of the Sparkfun USB Board
- In the Arduino IDE open the File "MPU9250_DMP_Quaternion.ino" from the unzipped folder
- Compile and Upload the sketch
The Board is ready
Step 2: The Blender 3D "IMU Animator" Add-On
In order to use the IMU board with Blender, I programmed an Add On: "IMU Animator"
To prepare this Blender Add-On, you have to follow these steps:
- Download the "IMUAnimator.zip" file and unzip it
- Open Blender and the Preferences: File -> User Preferences -> Tab "AddOns"
- At the bottom, press "Install Add-On from File" and select the unzipped "animation_imuanimator.py" file
Now the Add-On you can find in the Blender Add-On Preferences on the left side under:
Supported Level: "Community"
The new Add-On is checked ... and activated.
Step 3: Use the IMU Board With Blender
Finally: use it!
To use the Blender Add and the IMU Board, you have to follow these steps:
- Connect the IMU Board via USB (be sure the chip is facing up and forward like in the picture)
- On the left side inside the main Blender Window select the "IMU Animator" Tab.
- Press the "Reload" Icon near by "Select Serial Port:"
- Select the USB Port from the IMU Board
- Select the "Object" you want to animate (in this case select the "Box" Object)
- Finally activate "IMU direct Rotation" (if you want to animate the Camera, then disable "IMU direct Rotation" and select the "Camera" object)
Now press "Activate IMU" and rotate the IMU Board... the Box must rotate also...
... if not, press "Deactivate IMU", select an other Port and press again "Activate IMU".
That's it. Now you can animate any 3D Object you like (in my case the Camera).
Hint: While you record frames, hide the "Animate Frame View", because it consuming to much CPU time and the result will stutter.
This is an entry in the
Arduino Contest 2019