Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.
/ Sphero-Win-SDK Public archive

🚫 DEPRECATED: Sphero SDK for Win 8.1+ using RFCOMM

Notifications You must be signed in to change notification settings

sphero-inc/Sphero-Win-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo has been deprecated and archived.

Want to be updated when new SDKs are released?

Consider signing up for our SDK email list to be notified when we release new and updates to our SDKs.

For more information and documentation

Visit our SDK website to find more information about the SDK and the API!

Where to get help

Visit our community forum to get help, share your project, or help others!

Sphero-Win-SDK

sphero-apps.jpg

Windows 8.1 Quick Start Guide

Overview

This project shows Windows 8.1 developers how to integrate Sphero into their Apps and games!

Contents

  • Adding the RobotKit.dll to your Visual Studio solution
  • Discovering & Connecting Sphero
  • Changing Sphero's color
  • Using the Sphero UI elements
  • Driving Sphero
  • Sensor Streaming

Adding RobotKit.dll

From within your solution on Visual Studio 2013

  1. Right click on References and "Add Reference"
  2. Choose "Browse" and select the RobotKit.dll

Update Manifest

<wb:DeviceCapability Name="bluetooth.rfcomm">
  <wb:Device Id="any">
    <wb:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB" />
  </wb:Device>
</wb:DeviceCapability>

Discovering & Connecting Sphero

private void setupRobot(){
    RobotProvider provider = RobotProvider.GetSharedProvider();
    provider.DiscoveredRobotEvent += OnRobotDiscovered;
    provider.NoRobotsEvent += OnNoRobotsEvent;
    provider.ConnectedRobotEvent += OnRobotConnected;
    provider.FindRobots();
}

Handle the Events...

private void OnRobotDiscovered(object sender, Robot robot) {
    Debug.WriteLine(string.Format("Discovered \"{0}\"", robot.BluetoothName));

    if (m_robot == null) {
        RobotProvider provider = RobotProvider.GetSharedProvider();
        provider.ConnectRobot(robot);
        //...
    }
}

private void OnNoRobotsEvent(object sender, EventArgs e) {
  MessageDialog dialog = new MessageDialog("No Sphero Paired");
  //...
}

Changing Sphero's color

Sphero's main LED colors are controlled by web standard RGB. Best practice is to use hex values to stay within the valid range of 0-255.

public void turnSpheroWhite(){
    int red = 0xFF;
    int green = 0xFF
    int blue = 0xFF
    m_robot.SetRGBLED(red, green, blue);
}

Using the Sphero UI Elements

From within the BasicDriveApp sample, copy the RobotKitUI code for the Joystick and Calibration controls. Sphero needs to be calibrated so that the 'back LED" is aimed toward the driver. The easiest way to accomplish this is to use the 'CalibrateElement.cs'.

Driving Sphero

Driving Sphero is super simple. Just give it a direction in degrees where 0 is directly ahead and increases clockwise where 90 degrees is right and a velocity between 0.0 and 1.0.

public void hangRightAtHalfSpeed(){
    int heading = 90; // right
    float velocity = .5; // half speed
    m_sphero.Roll(heading, velocity);
}

Sensor Streaming

Sphero is capable of being used as a simple game controller or other input device using it's embedded sensors. Sphero has the following sensors.

  • Accelerometer
  • Gyrometer
  • Location in X,Y from a relative starting point
  • Velocity
  • Attitude in both Quaternions and Euler angles

Setup

The robot SensorControl manages the listeners for Accelerometer, Gyro, Location, Attitude in Eulers and Quaternion Attitude. The SensorControl.Hz value is between 1 and 400 and affects all sensors.

{
  m_robot.SensorControl.Hz = 60; // stream at 60Hz for ALL sensors that are enabled
  m_robot.SensorControl.AccelerometerUpdatedEvent += OnAccelerometerUpdated;
}

Data Handler

private void OnAccelerometerUpdated(object sender, AccelerometerReading reading) {
// expects AccelerometerX,Y,Z to be defined as fields
    AccelerometerX.Text = "" + reading.X;
    AccelerometerY.Text = "" + reading.Y;
    AccelerometerZ.Text = "" + reading.Z;
}

Samples

About

🚫 DEPRECATED: Sphero SDK for Win 8.1+ using RFCOMM

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published