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
I'm using Visual Studio Community 2015. In the package manager consoler, install the latest beta version of SharpDX.XInput
Install-Package SharpDX.XInput -PreI'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(); } } } }
No comments:
Post a Comment