Skip to main content
Contact us
Contact us
force is strong with sphero
R&D

The Force is Strong with Sphero and Apple Watch

The saga continues. Remember when we awoke the Force with Kinect and Sphero? Right after that we received a similar request. We’re not gonna disclose the previous customer (don’t worry, Darth, you’re fine), but this time the order came from Master Yoda himself. When he saw Sphero’s new Star Wars watch, Master reasoned: why use an additional device when you already have Apple Watch on your wrist?

Apple Watch need you. Force feel you must…
Why not Android Wear?
Argue with the Master must you not. Use Apple Watch!

Really, who are we to argue with the powerful old green man? So, we started developing an app that will allow controlling Sphero with Apple Watch.

Sphero

WatchOS 2 and How to Track the Power

Fortunately for us, starting from WatchOS 2.0 developers have access to raw accelerometer data. Which is great because we will use it to track the changes in wrist movement.

The basic idea is to:

  1. Extract the accelerometer data from Apple Watch.
  2. From that data get the states (positions of the watch relative to the ground) that could be used as the control units (control movements).
  3. Send the corresponding movement action to an iPhone.
  4. Use Sphero SDK to send the command from an iPhone to Sphero.

Implementation

So, we have some data and now we need to extract a few patterns from it to create some basic movements. There are several ways it can be implemented, one of the easiest being to use the g-force vector. Because raw accelerometer data is returned in the format g + user acceleration (acceleration performed by the user), we can get the basic movements which we are interested in.

  • abs(acceleration.z) == g. Wrist is parallel to the ground (watch screen is parallel to the ground). Sphero moves forward.
  • acceleration.x == g. Wrist is pointing to the ground. Sphero moves backward.
  • acceleration.x == -g. Wrist is pointing to the sky. Sphero stops moving.
  • acceleration.y == g. Wrist is parallel to the ground and rotated 90 degrees clockwise. Sphero moves right.
  • acceleration.y == -g. Wrist is parallel to the ground and rotated 90 degrees counterclockwise. Sphero moves left.

Using these four states we can build a simple state machine which will manage the behavior of Sphero.

Basically, the list of technologies we used is simple: Swift, CoreMotion, Sphero SDK, WatchKit and WatchConnectivity.

What We Couldn’t Do...

Unfortunately, we can’t use bluetooth to send the signal directly from the smartwatch to Sphero. That is why we used the basic approach for the iPhone - Apple Watch communication. Maybe the next release of Apple Watch OS will give us better opportunities. By the way, Android has no such issue 🙂

… and What Can Be Done

We used only 4 states to manage Sphero, but using simple machine learning can help create a wider set of patterns, like the guys did here.

How to Use the Force

force is strong with Sphero
  1. Turn Sphero on. Aim Sphero
  2. Start the application on your iPhone. Check if Sphero is connected.
  3. Start the corresponding app on your Apple Watch.
  4. Move your wrist to control Sphero.

Click here to see the code on GitHub.

Have a question?
Speak to an expert
app development
Explore our application development services
Explore our application development services
Contact Us
  • We need your name to know how to address you
  • We need your phone number to reach you with response to your request
  • We need your country of business to know from what office to contact you
  • We need your company name to know your background and how we can use our experience to help you
  • Accepted file types: jpg, gif, png, pdf, doc, docx, xls, xlsx, ppt, pptx, Max. file size: 10 MB.
(jpg, gif, png, pdf, doc, docx, xls, xlsx, ppt, pptx, PNG)

We will add your info to our CRM for contacting you regarding your request. For more info please consult our privacy policy
  • This field is for validation purposes and should be left unchanged.

What our customers say

The breadth of knowledge and understanding that ELEKS has within its walls allows us to leverage that expertise to make superior deliverables for our customers. When you work with ELEKS, you are working with the top 1% of the aptitude and engineering excellence of the whole country.

sam fleming
Sam Fleming
President, Fleming-AOD

Right from the start, we really liked ELEKS’ commitment and engagement. They came to us with their best people to try to understand our context, our business idea, and developed the first prototype with us. They were very professional and very customer oriented. I think, without ELEKS it probably would not have been possible to have such a successful product in such a short period of time.

Caroline Aumeran
Caroline Aumeran
Head of Product Development, appygas

ELEKS has been involved in the development of a number of our consumer-facing websites and mobile applications that allow our customers to easily track their shipments, get the information they need as well as stay in touch with us. We’ve appreciated the level of ELEKS’ expertise, responsiveness and attention to details.

samer-min
Samer Awajan
CTO, Aramex