ms-iot/build2015-robot-kit

Name: build2015-robot-kit

Owner: ms-iot

Description: null

Created: 2015-04-15 16:16:09.0

Updated: 2018-04-06 06:03:59.0

Pushed: 2016-08-10 16:02:35.0

Homepage: null

Size: 3206

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Welcome: Say hello to your little friend!

You are about to embark on a journey, and we are excited to be part of it! Get ready to make and program your robot using Windows 10 IoT Core!

By the time you are done with this project you will gain the following experience:

  1. Understand how Windows 10 Universal Windows Applications (UWA) work
  2. See how the same application can come alive and change behavior by running on the robot via Windows 10 IoT Core on a Raspberry Pi 2 and on your Windows 10 Desktop PC
  3. Program a UWA, using C# and XAML
  4. Control digital GPIO from your Raspberry Pi 2
  5. Use GPIO and timers to power a servo motor
  6. React to a toggled switch
  7. Process USB Joystick information
  8. Send and receive networking commands
  9. Process keyboard, mouse clicks and touch events

We are excited to embark on this journey with you - Thank you from the Microsoft IoT Team!

Usage

Download the project, load it into Visual Studio compile and deploy the application. Follow this link.

The application can be run in 2 ways:

  1. Windows 10 desktop UWA - here you can use the mouse or touch to drive the robot. You can also plug in the Xbox 360 controller and use that to drive the robot over the network
  2. Windows 10 IoT Core UWA for the Raspberry pi 2 - here you can drive the robot directly with the Xbox 360 controller, or via network commands from the Windows 10 UWA
Directional movement

The robot can move in 8 directions:

  1. Forward
  2. Reverse
  3. Hard left turn
  4. Hard right turn
  5. Soft forward left turn
  6. Soft forward right turn
  7. Soft backward left turn
  8. Soft backward right turn

A hard turn rotates the wheels in opposite directions. A soft turn rotates only one wheel in the specified direction. alt-text

Joystick Input

The robot can be controlled via the left analog stick or digital direction pad. They joystick can be plugged into the robot directly via the USB port on the Raspberry Pi 2 or the Windows 10 Desktop PC via USB.

Keyboard Input

From the Windows 10 Desktop PC UWA, the keyboard controls are:

Mouse/Touch

When run on the Windows 10 Desktop PC, there is an input screen with the 8 directional movements of the robot. Click or touch any of these to move the robot.

alt-text

Bill of Materials

To build the robot, you will need the following:

  1. Wooden Robot Frame in 7 pieces - Get the cutting plans from the Sumo Robot Jr. GitHub repo and submit them to http://ponoko.com. We cut them 4 to a sheet of P3 5.2 mm Veneer Core Birch
  2. 2x continuous rotation servos, like these
  3. A ball caster, like this
  4. A USB Xbox 360 Controller
  5. a Digital switch, like this
  6. 6x 6” Male-to-Female Wires (2 red, 2 white and 2 black) like these
  7. 2x 6” Female-to-Female Wires (1 red and 1 black) like these
  8. Screws, Nuts, Bolts and standoffs like this
  9. Raspberry Pi 2, a 2 Amp power supply, SD card, network ethernet cable
  10. Micro screwdrivers

Hardware assembly

A picture is worth a 1000 words.

alt-text

A video is 1000 pictures. Watch this quick tutorial to assemble your robot.

Pin Assignments

alt-text

Assembly Notes

Software

The robot kit software is a UWA project with 6 major files:

  1. MainPage.xaml.cs - The main application code and entry point
  2. XboxHidController.cs - The initialization and handling logic for the Xbox controller
  3. MotorControl.cs - The main logic for controlling the continuous rotation servos
  4. Controller.cs - The logic for converting joystick, key press, mouse, and touch events to robot movements
  5. NetworkCommands.cs - the logic to setup client and server networking threads and create/process network messages
  6. package.appxmanifest - the manifest file that defines properties of this UWP application
MainPage.xaml.cs

The MainPage class is where the supporting robot classes get started. It is the only UI page for the RobotApp. The onscreen buttons, and key input properties, are setup in MainPage.xaml.

MainPage.xaml.cs is also where RobotApp reads the previously saved mode, and initializes itself to run as a Robot or Controller. When using a remote controller (optional), the robots need to know the name of a host computer, where the controlling app is running. It can be your laptop, or even a phone. The following String is where the default name can be hard-coded. It is also set in config.txt in the application data folder. Change it to your laptop's name or ip address, so the robots can connect to it for directional commands.

private static String defaultHostName = "tak-hp-laptop";  // <-- change to your laptop name or ip address
XboxHidController.cs

The XboxHidController class contains the interface logic for getting input from the Xbox game controller. Once the initialization method in Controllers.cs finds an attached gaming HID device, it sets up the delegates in XboxHidController.cs to process the input events. Ultimately, these methods return a direction and a magnitude value, which are used to determine how to drive the servo motors.

There are two types of directional inputs from the game controller, DPad and joystick. The DPad type simply returns one of eight directions, making it easy to work with. The joystick type requires translating an X and Y value into appropriate directions, as well as filtering out minute movements while the stick is closer to its center position.

MotorControl.cs

This MotorCtrl class handles all of the I/O to control the continuous rotation servo motors, and block sensor. The GPIO library is used to control selected I/O pins for this project. The main timing loop generates appropriate pulse signals to drive the motors, for any of the eight selected directions. This loop, is also where other critical system checks are done (i.e. block sensor, device communication breaks, etc.).

The block sensor, is also defined here, and was setup to demonstrate a basic motion-safety feature. With it connected, the robot will stop, and turn-around, if an obstacle triggers the switch.

Controllers.cs

This Controllers class coordinates the several types of input which can be used to drive the robot. Directional inputs are handled from key presses, mouse or touch input, and Xbox game controller input, which are either connected directly, or sent from a remote RobotApp. The Controllers class provides methods to translate each of these into the basic directional values used by the MotorControl class.

NetworkCommands.cs

This NetworkCmd class sets up either a client or server stream socket object. If the RobotApp is a basic robot, a client object is used. A basic robot reads in commands from a networked App, to optionally use along with any locally attached input devices. If the App is setup as a remote controller, a server object which listens for connections is used. When the App is in a server mode, it writes directional commands out to connected client robots. Both modes of the RobotApp utilize the same Controllers classes.

See the note about how to set the defaultHostName string in MainPage.xaml.cs above, to set who the host computer is.

package.appxmanifest

The Capabilities defined in the manifest file, enable networking, and human interface device privileges. Be sure to include these within your modified projects.

<Capabilities>
  <Capability Name="privateNetworkClientServer" />
  <DeviceCapability Name="humaninterfacedevice">
    <Device Id="any">
      <Function Type="usage:0001 0005"/>
    </Device>
  </DeviceCapability>
</Capabilities>
Future Considerations

Make. Invent. Do.

This robot kit (hardware and software) is made available as an Open Source Project.

The kit is a starting point. Let your creativity go wild with the mechanical, electrical and software design. Make the robot kit your own. Decorate it. Improve the cutting plans. Add motors; Add sensors; Submit improvements and bug fixes! No matter what, tell us what you did with it: #MakeInventDo

Thanks from the Microsoft IoT Team!

===

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.