Now as the robot is 3D printed I can just scale it up to the size I want yes? Well, unless you have a fully working replicator, its not quite that easy. The plastic parts scale up nicely the motors and other electronics don't. The weight increases, so you need bigger motors, then bigger, however the batteries, and possibly a higher rated motor controller. Then you need to make all these bigger components fit on the robot and suddenly it feels like you have less space than you did before!
I stripped all the parts from my PiWars 2015 entry and went through several revisions of the scaled up chassis, trying to work out how to make everything fix together. Eventually I did a spot of rewiring on the controller, cut off some pins and finally came up with the following.
|Old vs New|
The new Pi Squared chassis is considerably larger than the previous variant, as well as gaining a rear wing, just fitting inside the maximum dimensions allowed for PiWars. The front wing is now removable, allowing the chassis a bit more space on my 3D printer, and can be swapped out for the various different challenges, although the only one I have prepped so far is for Pi Noon.
|Removable front wings|
The control method is my usual PS3 controller, with a simple python script driving the motors, making use of pygame and the GPIOZero library to keep everything simple. In fact the entire code is rather small.
import pygame import os import time import gpiozero os.environ["SDL_VIDEODRIVER"] = "dummy" pygame.init() pygame.display.set_mode((1,1)) # Wait for a joystick while pygame.joystick.get_count() == 0: print 'waiting for joystick count = %i' % pygame.joystick.get_count() time.sleep(1) pygame.joystick.quit() pygame.joystick.init() j = pygame.joystick.Joystick(0) j.init() print 'Initialized Joystick : %s' % j.get_name() from gpiozero import OutputDevice from gpiozero import Robot EN1 = OutputDevice(17) EN2 = OutputDevice(6) EN1.on() EN2.on() r = Robot(left=(27,5), right=(13,4)) try: # Only allow axis and button events pygame.event.set_allowed([pygame.JOYAXISMOTION, pygame.JOYBUTTONDOWN]) left = 0.0 right = 0.0 while True: time.sleep(0.1) events = pygame.event.get() for event in events: UpdateMotors = 0 if event.type == pygame.JOYAXISMOTION: left = j.get_axis(1) right = j.get_axis(3) r.value = (left, right) except KeyboardInterrupt: # Turn off the motors j.quit()
Finally here's a quick view of the new and improved Pi Squared running around.
With only a week left until PiWars I still have a lot to do, sensors to attach, code to write, practising driving.. So its going to be a busy weekend and evenings for the rest of the month!