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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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:
We are excited to embark on this journey with you - Thank you from the Microsoft IoT Team!
Download the project, load it into Visual Studio compile and deploy the application. Follow this link.
The application can be run in 2 ways:
The robot can move in 8 directions:
A hard turn rotates the wheels in opposite directions. A soft turn rotates only one wheel in the specified direction.
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.
From the Windows 10 Desktop PC UWA, the keyboard controls are:
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.
To build the robot, you will need the following:
A picture is worth a 1000 words.
A video is 1000 pictures. Watch this quick tutorial to assemble your robot.
The robot kit software is a UWA project with 6 major files:
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
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.
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.
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.
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.
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>
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.