We have control!

So we went to the Manchester Raspberry Jam on Saturday, taking along our robot, and since everyone there got a chance to see the control block, there’s no harm in sharing it here too. The “lid” (a Lego plate) is taken off here, so that you can see the guts: a Pi3, plus two SparkFun Motor Driver – Dual TB6612FNG boards, which will allow us to control four motors independently. This control is wired to the four connectors along the side, allowing direct control of Lego powerforce motors. (At this stage, we’re using only two of these, driving our four motors as two pairs of two – works easily, you just piggy-back the connectors.) There are also three other connectors. One of these provides an I2C connection, and the other two are directly wired to 3V3, GND and two GPIO pins each. So we wire our sensors to Lego cables, then just clip them on.

Anyway, the Raspberry Jam. Just a few minutes before we walked out the door to go to the Jam, the postman knocked on the door, with a parcel containing our genuine Ps3 controller. So my son immediately decided that that was my task for the day: get it working! And after spending so much time last weekend messing around with the cheap fake, I’m happy to say that it did just work (once we got it charged). Steps to get it paired were:

  1. Download and install sixpair
  2. Connect controller to pi via USB connection
  3. Run sixpair as root
  4. Disconnect controller
  5. Run bluetoothctl:
    1. “agent on”
    2. “devices” and find MAC address of the controller
    3. “trust MAC” where MAC is that mac address
    4. “quit”
  6. Press the PS button on the controller. The lights should all flash rapidly for a bit, then just one.

And hooray, it worked, just like that. So the next step was actually using it to control the robot. First step towards this for me was to download Triangula’s wonderful python libraries – why reinvent the wheel? These libraries work well, and more importantly, are incredibly well documented. With these, by the end of the day  I had a program that could output to the terminal the axis positions of the PS3 joysticks. Son was very disappointed that I didn’t actually have it controlling the robot yet though.

So why did it take so long? Well really, it didn’t. It’s just that we were at the Raspberry Jam, and there was lots of other interesting stuff going on and people to talk to. My son had a great time in the basic robotics workshop, getting a pi to drive a motor. We met several other people who will be at Pi Wars, one in the same beginners class as us. (She was working hard on her line following task for most of the day.) Also someone who will be in the intermediate class, and others who took along a demo last year, and will probably go as spectators this year. Frustratingly, this last pair had had exactly the same problem with PS3 remote as we did – if only the Jam had been a couple of weeks earlier! But the good news is that they are now planning to move back to monthly Jams (it had been 2-monthly for a while).

So when we got home on Saturday evening, my son was a bit grumpy that I wouldn’t keep working on it there and then. But I held off until Sunday morning. The good news is that in less than an hour on Sunday morning I had it going… and it goes well 🙂 The main problem at the moment is that the chassis needs reinforcement – the motors are a bit too powerful, and we have a tendency to fall apart!

So now my son can work on that, while I think about the autonomous challenges 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s