Showing posts with label plan. Show all posts
Showing posts with label plan. Show all posts

Thursday, 3 September 2015

Using XBox One Controller for command input

One of my requirements was to achieve fully autonomous flight. It dawned to me that before I get there, I'll probably need to manually control the quad to perform flight tests and improve the control subsystems. Hence I need a controller, but I don't want to invest in a costly radio-controlled solution.

I already have WiFi onboard the Pi. I have an Xbox One Controller. And I already need to develop a control app to run on my computer. I'll simply interface with the Xbox One controller, which is extremely versatile.


The control mapping will surely change, but it could look like the above.
  • Throttles: control motor throttle in manual mode, control altitude in altitude stabilization mode
  • Select: switch between manual, altitude stabilized, position hold and fully automated
  • Start: start/stop onboard control
  • Right joystick: adjust yaw
  • Left joystick: adjust pitch (up / down) and roll (left / right)
  • A-button: automated lift-off and landing activation
The controller can be plugged into any Windows system with a USB cord and is instantaneously recognized. Plus there are DirectX APIs to interface with it. Since I'll be developing in C# on the Windows side, I'll be using the SharpDX.XInput library, a convenient managed wrapper around the DX native XInput APIs.

I'm using Visual Studio Community 2015. In the package manager consoler, install the latest beta version of SharpDX.XInput
Install-Package SharpDX.XInput -Pre
I'm using the beta version as the latest stable release is based on DX11 and I ended up with missing DX DLLs (Windows 10 comes with DX12).

Once you have that imported, getting a Controller object is quite simple.. In the example below, in a simple Form app, when I update the text field with the X/Y coordinates of the left joystick anytime the form button is pressed.

using SharpDX.XInput;

namespace QuadRemote
{
    public partial class Form1 : Form
    {
        public Controller _controller;

        public Form1()
        {
            InitializeComponent();
            _controller = new Controller(SharpDX.XInput.UserIndex.One);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (_controller.IsConnected)
            {
                var state = _controller.GetState();
                var x = state.Gamepad.LeftThumbX;
                var y = state.Gamepad.LeftThumbY;

                richTextBox1.Text = x.ToString() + " " + y.ToString();
            }
        }
    }
}

Thursday, 27 August 2015

BOM

I've been trying to budget the project in terms of cost and weight of the quadcopter.
I have a model in mind of a simple 24" wide X shaped design made of wood, polycarbonate and sorbothane (for vibration dampening). With that model in mind and a quick survey of what I need to propel / control the quad, I get the below.

Description Size Units Weight (g) Wratio Price (CAD) Pratio Required TWeight Tprice
Structure
Polycarbonate Sheet 432 sq-inch 1000 2.3  $        23.90 0.06 128 296 7.1
Goujon SQ 1/2 48 lin-inch 99 2.1  $          1.78 0.04 48 99 1.8
Goujon RD 1/2 48 lin-inch 44 0.9  $          0.98 0.02 32 29 0.7
Insulation tube 36 lin-inch 17 0.5  $          1.29 0.04 6 3 0.2
Sorbothane 1/4" 30 DURO 50 sq-inch 50 1.0  $        26.95 0.54 8 8 4.3
Hardware (screws, nuts, etc.) 1 bulk 100 100.0  $        50.00 50.00 1 100 50.0
Propulsion/Energy
1050Kv Brushless Motor 1 motor 57 57.0  $        35.09 35.09 4 228 140.4
Propellers 10in/4.5p 4 approx 60 15.0  $          6.00 1.50 4 60 6.0
ESC 30A 1 approx 29 29.0  $        13.00 13.00 4 116 52.0
3S 5200mAh Lipo Pack 1 approx 330 330.0  $        35.00 35.00 1 330 35.0
Control
PCA9685 1 unit 7 7.0  $        15.85 15.85 1 7 15.9
Raspberry Pi 1 unit 45 45.0  $        46.11 46.11 1 45 46.1
MPU9250 1 unit 5 5.0  $        15.61 15.61 1 5 15.6
BMP280 adafruit 1 approx 5 5.0  $          9.95 9.95 1 5 10.0
GPS 1 approx 10 10.0  $        50.00 50.00 1 10 50.0
(optional) Xbee radio

Some components I've already bought and weighted, some are just approximations based on some quick web searches. I haven't locked on some components.

Still, I'm 11% under budget for weight, and 28% under budget for cost. I've excluded the cost of tools - they can always be reused for other projects. I've taken a similar commercially available kit (ELEV-8 V2 Quadcopter Kit from Parallax) as a reference. I've converted the amounts in Canadian currency (CAD).

Metric Total Target Delta %
Weight (g) 1341 1500 -159 -11%
Price (CAD) 435 600 -165 -28%