I want to impress Darth Vader. I tried different things, but only way is to use the Force. So I made one! With the Power of Particle Photon. And then I used a glove and added the power of littleBits cloudBit. I created a mobile App using Unity3d.
Then I made a wearable glove with littleBits, when I close my finger, it would send a signal to my phone to move the Darth Vader Model.
Working with Augmented Reality projects are fun and exciting; but adding Particle Photon or littleBits added a new level of Interaction and magic. If you like to see more, please follow me and add respect to this project. Thanks.
PhotonWell, I found out that Sparkfun sells an IMU module to Photon. I can use that to get the rotation, so I can use it know when I tilt the device, I can trigger an augmented reality app app.
https://www.sparkfun.com/products/13629
The tutorial is easy to follow. Thanks Sparkfun.
https://learn.sparkfun.com/tutorials/photon-imu-shield-hookup-guide
I reused about the same code that I deployed in the photon from the Virtual Reality project
I made my phone as Access Point ... then connect Photon to my phone. Then I can now connect a Unity3d app to my Photon.
Here's the code that I used. Make sure you change the IP address of your phone.
https://gist.github.com/rondagdag/7d139d95e5b6ea2ef8e0
I have a USB battery from Motorola that I attached to my photon to make it portable.
I started learning Unity3d this year. This is a good platform for creating games and visualization. Especially in VR and AR.
My background is C# and .NET that's why I chose Unity3d instead of Unreal. I'm hoping I can reuse some .NET libraries for communication. It's now free to use networking stuff in Unity3d with the new version.
I'm new to Unity3d. There are good courses that I took in Pluralsight that helped me grasp the idea and the platform.
What's good about Unity3d is that it has an asset store. Looking at the asset store, there are quite a few libraries that I can use but I need to buy it.
I found this article:
http://forum.unity3d.com/threads/simple-udp-implementation-send-read-via-mono-c.15900/
So I tried the UDP receive since I only want to receive data from the photon.
I connected the Photon to Unity3d via UDP sockets.
I used this tutorial to create an Augmented Reality App.
Thanks to Edgaras Art.
Instead of the Dino, I replaced it with Darth Vader.
I used this Free Darth Vader Model made by Makeamo downloaded from here:
https://sketchfab.com/models/a9536866d4544b78b94da744226eae2d
Here's what I used to receive UDP packets from Photon:
https://gist.github.com/rondagdag/ee821452fad215a3c07c
At the end of the day, I receive the values from Photon, parse the string and pluck out the one I need. The 6th index is the tilt.
client = new UdpClient(port);
while (true)
{
try
{
IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
byte[] data = client.Receive(ref anyIP);
string text = Encoding.UTF8.GetString(data);
// latest UDPpacket
lastReceivedUDPPacket=text;
var rot = lastReceivedUDPPacket.Split(',');
Value = Convert.ToSingle (rot [6]);
}
catch (Exception err)
{
print(err.ToString());
}
}
Once I assigned the "Value" variable. I monitor that inside Unity3d.
void OnAnimatorMove()
{
if (anim) {
if (Value < 0.2) {
//start moving if photon is tilted upward.
Debug.Log ("Move");
Vector3 newPosition = transform.position;
newPosition.x -= moveSpeed; // change the position of Darth Vader
transform.position = newPosition;
} else
{
transform.position = initialPosition;
}
}
Here's how you can export an Augmented Reality project to an Android Phone
If you like this project, please add respect and follow me. Thank you.
littleBits cloudBitCreate the Glove. I taped 2 bend sensors to a glove and have a splitter bit for power. Use littleBit shoes to stick it to the glove. Connect the splitter bit to battery power. Then connect the 2 bend sensors to the wireless transmitter. As shown in the pictures.
Connect wireless receiver to cloudBit. Make sure cloudBit is setup properly.
I can't just connect the cloudBit to the glove, because I don't have enough power to run the cloudBit. That's why I used a wireless receiver.
I also attached another marker on the glove. So I can have the glowing hand.
Here's an asset in unity3d that connects to WebSockets, that's what I used to connect to the cloudBit
https://www.assetstore.unity3d.com/en/#!/content/8959 - To save some money, I actually compiled the open source websocket-sharp.dll and include it to my project -http://sta.github.io/websocket-sharp/
- You may also need to copy Newtonsoft.Json dlls to your project. I copied it under Plugins folder.
I also attached a C# code snippet in Unity3d on how to connect to cloudBit using WebSockets.
https://gist.github.com/rondagdag/4bff1724cdf624b04db8
Hopefully this will inspire you to start building Augmented Reality Projects with different hardware integration. Follow me if you're interested in Augmented Reality projects and thanks for adding respect this project.
Comments