theta360.guide is working to get more plug-ins in the THETA Plug-in Store. More examples help the community. Getting published is a great accomplishment.
theta360.guide held a “Become a VR Developer” meetup on March 14. This article summarizes the techniques needed to take an existing plug-in repo, modify it, and make it yours.
We prepped code, laptops and THETA Vs. Participants could start tweaking and editing code quickly. It’s a great way to learn, working with a plug-in that is already functional. You can test and extend the code and see how to make it do what you want.
(If you want to start from scratch, that’s totally possible, too!)
Micah Stubbs (GitHub, Twitter) took a basic plug-in that used the accelerometer and changed it into a “Raise Your Hand” plug-in that aims to only take a photo if up and down motion is sensed by the accelerometer.
When you raise your hand high while you’re holding your THETA, it takes a picture. No need to use a mobile app to control it. No need to even press the shutter button. Pretty cool.
Micah says he’s submitting his Raise Your Hand plug-in to the store.
Try It Yourself
Download it and try it yourself. Repo here: GitHub - micahstubbs/theta-raise-your-hand: raise your hand to take a picture with the THETA V 360 degree camera
Some points to consider:
Basic Setup
- THETA V, usb cable
- pluginlibrary
- THETA SDK and theta4j (not using in this plug-in)
- Laptop, Android Studio, adb, Vysor, RICOH THETA desktop app
Development Flow
- Use Android Studio to build plug-in
- Connect with USB, press Run
- Unplug USB, test it using your THETA V
- Repeat
You must register with the Plug-in Partner Program
You need to register with the Plug-in Partner Program, send in your THETA serial number, and unlock you THETA V.
Checking the firmware version
Before getting started, make sure your THETA has the latest firmware installed: 2.50.1. If you do not get a response when trying to connect using adb, older firmware may be the reason.
Cool Tip - Pushing edits to Github after hitting Run in Android Studio
Fork Micah’s repo and clone it locally. Open it in Android Studio, and you can begin editing MainActivity.java. Looking over Micah’s shoulder, I noticed a good programming habit: After you make an edit in Android Studio, hit the Run button and test it on your THETA, doing a git add - commit - push means you’re nicely updating your GitHub repo at the same time.
Cool Tip - Reducing to one axis for simple testing
Actually, I looked over Micah’s shoulder a lot. Micah reduced the complexity for testing. The accelerometer gets data for X, Y, and X axes. But simplifying it down to one, the X axis, made it more clear while testing to if it was responding correctly.
Lines 135 - 139, commented out, show how it looks testing for all three axes:
if (Math.abs(accelerationGraSensor.getX()) > ACCELERATION_THRESHOLD_X ||
Math.abs(accelerationGraSensor.getY()) > ACCELERATION_THRESHOLD_Y ||
Math.abs(accelerationGraSensor.getZ()) > ACCELERATION_THRESHOLD_Z) {
new TakePictureTask(mTakePictureTaskCallback).execute();
}
Micah simplified this down to Lines 140 - 142:
if (Math.abs(accelerationGraSensor.getX()) > ACCELERATION_THRESHOLD_X ) {
new TakePictureTask(mTakePictureTaskCallback).execute();
}
Changing Wi-Fi LED color to magenta for picture taking indicator
In Line 103, Micah added a notification
to change the LED color when the shutter button is released. Nice indication that an end user action has happened.
@Override
public void onKeyUp(int keyCode, KeyEvent event) {
/**
* You can control the LED of the camera.
* It is possible to change the way of lighting, the cycle of blinking, the color of light emission.
* Light emitting color can be changed only LED3.
*/
notificationLedBlink(LedTarget.LED3, LedColor.MAGENTA, 2000);
}
Changing Wi-Fi LED color to yellow for shutter button press
What happens if the end user presses the Shutter button directly? How about if this is indicated with a different LED color? Micah edited Line 51 to accomplish this:
notificationLedBlink(LedTarget.LED3, LedColor.YELLOW, 2000);
Cool Tip - Copying and keeping old code commented out
Since you’re experimenting with a functioning plug-in, it’s good practice to comment out old code instead of deleting completely. Nice to have the working code preserved, just in case you want to quickly restore.
Example on Lines 64 and 65:
// private static final float ACCELERATION_THRESHOLD_X = 4.0f;
private static final float ACCELERATION_THRESHOLD_X = 2.0f;
Quick translation of Japanese comments for extra info
In the original repo, some comments are in Japanese. Drop them into Google translate for a little more info on each section.
Summary
Getting your plug-in in the THETA Plug-in Store is easy to do. It’s a cool accomplishment, and it’s great to get your functioning code out there to help the community.
theta360.guide will be doing more meetups where we have laptops set up with Android Studio, THETAs to work with, and suggestions how to test and tweak template plug-ins. Drop me a DM at @jcasman if you want to come to the next one.
If you show up, you’ll be able to Build and Submit a plug-in to the store. With minimal experience, we’ll make sure you can successfully submit your first plug-in. Come join in!