To keep track of the code I submitted today I created a tag in GIT called PiWars2015-CodeChallenge so I can refer back to it later (if needed) and the stats of that code snapshot are
http://cloc.sourceforge.net v 1.60 T=0.17 s (297.2 files/s, 29810.7 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 20 583 594 1700
C/C++ Header 21 258 422 564
Arduino Sketch 6 131 221 340
Python 2 44 55 162
CMake 2 12 9 21
-------------------------------------------------------------------------------
SUM: 51 1028 1301 2787
-------------------------------------------------------------------------------
So that's 51 files created and almost 2800 lines of code written... But is it complete?
In the past few weeks I've added 'ThoughtProcesses for the StraightLine and ThreePointTurn challenges. These both make use of the Sense HAT's array of sensors to determine the current heading of the robot, using it to try and maintain driving in a straight line, and for performing the turns for the three point turn. As can be seen in the following videos it doesn't always work quite right... I've tried re-calibrating the sensors a couple of times, but looks like I need to try it once more, not to mention changing the 'dead-reckoning' times to something a little more intelligent.
So, in theory, I can now enter all the autonomous challenges, although not with a huge chance of success as the code currently stands.
During testing I've been running one challenge at a time, editing the code and rebuilding it when switching between them. Obviously this is something I'd rather not have to do on the day, so I need a way of selecting between the various tasks. I had previously purchased an OLED display, but had been avoiding playing with it until I had the other functionality out of the way. Most of the example code for driving the OLED was for the Arduino so I spent some time hunting for a library that I could use from C/C++.
After wasting a bit of time searching for the wrong driver (SSD1305 instead of a SSD1306) I eventually selected the ArduiPi_OLED library to drive the display. The library does come with a few disadvantages, I now have to run my binary with 'sudo', the binary contains two library that try to access the GPIO pins and I2C bus (so far no obvious conflicts) and I can't have all my devices hanging off the same bus (which means more cables on the robot). However it has the advantage of getting things up and running now, which is useful when you have a deadline!
With the display working I added a 'Menu' class, updated the main PiWars class to create and display a menu, and to update all the ThoughtProcesses so they can be run in a background thread to not block the main thread. To navigate the menu's I'm making use of the joystick on the Sense HAT, as that will always be connected (the PS3 joystick may not be) and is simple to use. The results of all this work can be seen below
With the menu system I can select all the supported functionality, as well as shutting down the robot correctly, without yanking the power out and risking file system corruption.
So with three weeks what's left to do? There's a couple of nice-to-have items that are just not going to make it (My RFID reader has been on back order for 2 months now, it may arrive before December but no time to add it) so I'll be spending the rest of the time tweaking my code,, practising driving and making the robot pretty, not necessarily in that order!
Leo
No comments:
Post a Comment
Note: only a member of this blog may post a comment.