May 7, 2015:
And what, you might ask, have I been doing this past nearly-a-month? Well, essentially, running into dead ends and bugs, before
finally getting stuff to work.
So, WebIOPi turned out to be another dead end. The server could only send on/off signals through the board to the test LED. Looking into the source code for it was a mess, so I moved to a different, more simple idea.
RPIO, the thing I use to send PWM signals, is coded with Python, and the great thing about Python, or so I've heard, is that you can combine modules and functions as long as they're installed.
I wouldn't know for sure; this is my first time working with Python.
So now, the Raspberry Pi is running a simple server using
Twisted. It's a Websocket connection, which for my rudimentary purposes is basically the same as a standard internet connection. No web pages, just listening for a client to connect.
Originally, I modeled it off some really complicated
Autobahn Twisted Server setup, but something about the code prevented the client and server from connecting.
I picked up pretty much the basic framework of a Twisted server-client pair, and modified them to suit my purposes: create a little window with clickable buttons to change the brightness of the LED!
Okay, that's simplifying things a lot. The basic idea was for the client to send a word to the server, have the server recognize it and change the LED brightness with PWM, then send the word back to the client as confirmation. What follows is a list of problems, solutions, and programming jargon.
First problem: Server crashes when client connects.
Solution: RPIO can't clear the signal if it hasn't been set up. Gonna have to manually clear it every time to send a new signal...
Second problem: The server can receive and echo the message back to the client, but it can't recognize it.
Solution: Refer extensively to documentation. Change the imported module to match the class that the client imported.
Third problem: Using
Tkinter as a GUI (application window with buttons) can't work with the server-client communication.
Solution: Hey, documentation says I just have to import another module and change how the GUI is run! Easy!
Fourth problem: Commands queue up and execute all at once after the GUI window is exited.
Solution: Change where the code is being executed. Instead of creating it when the client connects, move it somewhere else. Crash the server and client. Examine the code and realize that python classes are really complicated. Crash the client again. Move the code somewhere else. Crash the client once more. Take it out of the initial input/output class. Crash client. Fix variable references. Crash client. Research Python error messages. Refer to specific instance of the class instead of the general case. Crash. Examine source code and realize this is going to be even harder. Give up, take a break. Get prodded back to work. Override event on the connection-making class. Crash. Fix variable references again. Crash. Correct several bugs lying around. Finally get it to work. Celebrate by messing with the LED for half an hour.
Programming in a language you're unfamiliar with is hard.
But now I've got it working in concept! Press and hold a button to (theoretically) tilt the quadcopter in that direction. For now, it's not linked up to the flight controller and so it's just attached to the proof of concept LED. In fact, given the deadline coming up, I'm not sure if I can get everything stuck into the quadcopter board and find time to test it out for an actual flight and recalibrate the flight controller to receive the PWM signals form the Raspberry Pi correctly and wonder if it works on places other than our home network and fix it if it doesn't...
There's a lot of stuff left to do and I was thinking I was too ambitious with my initial goal.
In the end, though, I have a working, flying quadcopter, and working code that I could theoretically use to fly it with a laptop. I'd call that a pretty good success!