Friday 27 November 2015

ElMo: one week to go

This time next week it'll be PiWars eve - how exciting!  Do come and say hello - we should be quite easy to spot in our spiffy new t-shirts

We've had our timetable for the day through - and we are assured of at least one small victory as we have received a bye through the first round of PiNoon - I think we might need to do some work on our robot victory dance routine ;)

See you next week - and may the odds be ever in your favour...

Monday 23 November 2015

ElMo - menus and configuration files

We have continued to tweak ElMo this week - our hardware is as ready as it will ever be, so it is all about the testing and subsequent software changes.  We have now added a configuration file so we can get and set key parameters from the OLED menu.  The parameters we can tweak as of now are
  • voltage in - because when the batteries get used up, the motors slow down and we want to compensate for that.  
  • voltage out - so we can recklessly run our 6V motors at 9V during the speed test ;)
  • time1m - this records how long to run the motors to travel 1 metre (used during 3 point turn)
  • time360 - records how long to run the motors to rotate 360 degrees (ditto)
  • slowprox - the speed to run the motors at during the slow approach phase of the proximity test (the default 0.25 was not enough to move ElMo forward when the batteries were running low, so we can increase that now)
  • linefollowspeed - the speed to run the motors at during the line following challenge.  We have a better chance of staying on the line when we move slowly, but we can increase the motor speed to go for a faster lap.  Our line following is a bit hit and miss - I'm hoping that is due to the low quality construction values on our test course and that the sensors will perform well on the day.
I'd refer the interested user to our bitbucket source code to see the configuration file (elmo.cfg) and how it is used  (search in elmo.py for eg "voltagein").  We use the python ConfigParser module to read the config file (elmo.cfg) as part of the ElMo __init__ method.  We can get a numeric value from the config file using the getfloat method.  Parameters are set by calling eg setvoltagein (each of the setter methods is listed in our OLED menu list) - this in turn calls the method changevalue, which displays a value on the OLED screen and uses the up down buttons to change the value by an increment (0.01 for slowprox, 0.1 for settime1m, 1.0 for voltage out) and the centre button to return the new value.  When we have changed a value we call the writeconfig method to write the updated config file to disk.  This means that next time we reboot ElMo, we read the most recent configuration.

Here is some video demonstrating the menu in action - with a bit of last weeks Nigella in the background.  Do we get bonus points for having to work under these conditions ;) The font we are using is called Mario-Kart-DS which we found on dafont.com - seemed a bit more appropriate than Times New Roman ;)

This week we shall be testing, testing and retesting - and recording more video to share in the final week running up to PiWars - eek!


Thursday 12 November 2015

ElMo: finishing the finishing touches

Not a lot of time for blogging this week - too much coding to do:)  But we finally drilled and shaped our orange perspex lid for ElMo.  Looking good - a bit waspy perhaps?

We've spent quite a lot of time coding this week - as the deadline for the code review is on Saturday.  You can see how that is going at our bitbucket.  The new straight line speed test code uses an ultrasonic sensor to keep track of how far we are from the wall.  It does not work at all well unless the sensor is at right angles to the wall - because the reflections just don't bounce back otherwise.  We needed a bit more metal to be able to do this - we are making judicious use of wing nuts so we can swing the sensors to face forwards or sideways.  The line sensor is the last bit of code and is still 'bleeding edge' software - this is using 3 IR sensors that can detect black and white (as shown in the photo).  But it turns out we can use the same code to stay over the line as to stay close to the wall - we just need to change the comparison functions we use.  The technique uses something called a proportional integral derivative controller.  See this page for more details.  We've also checked our code using an online pylint tool - you can upload your python code and see how well it conforms to python standards.  After much refactoring we now score a fairly respectable 9.66 out of 10.

There are a number of parameters that we will need to change on the day.  Our very naive three point turn relies on knowing how long it takes to travel one metre and rotate 360 degrees - but these values change depending on the how much power is left in the batteries.  So we'll write a calibration function that will allow us to change this from the menu - and write the values to a configuration file so we can read them back in if we reboot.  We need to tweak the parameters for the various challenges.  And we need to stop the ball rolling away from the cannon as we push it forwards.  But it feels like we are getting there - which is probably just as well given there are only 3 weeks to go :)

Monday 2 November 2015

ElMo: hardware finishing touches

Our last session involved tidying up our power cables (with a terminal block that bolts to the lid of ElMo), the addition of an on/off switch (rather than having to disconnect the battery pack each time), and a simple menu system comprising a 128x64 pixel OLED screen and three buttons (move up the menu list, move down the menu list and select the menu item).  The screen is i2c compatible and so daisychains in with the other i2c items (the PicoBorgReverse and UltraBorg boards).  Adafruit provide an Adafruit_SSD1306 python library for sending images to the display.  The buttons (picked up in Maplin) use one GPIO pin each and are also connected to a ground pin.  Ideally we'd like to print out a proper circuit board (maybe using fritzing) and solder these items to it - but time is getting short, so we'll probably stick with the breadboard look.  We are planning to add a vibrant orange perspex lid, so we'll cut that next time, using the clear lid as a template.  And add somewhere for our mascot to sit.  And maybe some wing nuts for the ultrasonic sensors, so they are easier to swing into another position.  But hopefully that will be the final few cosmetic changes to the hardware.


There is still a lot of software to write - but we have now set up a bitbucket project to track changes - you can view it at https://bitbucket.org/elmorobogo/elmorobogo

We did have a major crisis of confidence last week - after adding the OLED screen, ElMo stopped working - the raspberry pi went into a constant reboot cycle.  Cue sleepless nights, rushed purchases of replacement hardware, etc, etc.  It turns out that our batteries were out of juice... once they were recharged, everything was good to go once again.  Lesson learned :)

And finally - we're really enjoying reading how everyone else is getting on - the other PiWars blogs are getting us excited.  Not long to go now...