PS2 controller emulator

I have a quadruped robot that I can control with a PS2 controller. However, I would like to automate the commands with a simple python script but am having difficulty with emulating the controller using either the teensy or an arduino. Does anyone have any experience or guidance they can offer, I have tried using the code from the following blog (Procrastineering - Project blog for Johnny Chung Lee: Simulated PS2 Controller for Autonomously playing Guitar Hero)?

Thanks in advance!

This is essentially the code I am using on the robot:

Also, I am using Bill Porter's libraries on a Botborduino for interfacing with a the PS2 controller which works perfectly. In other words, my system is able to be wirelessly controlled through the PS2 controller. The next thing I would like to do is add a Teensy (or Arduino board) to the quadruped for receiving commands via bluetooth from my python script instead of using the PS2 controller. I have tried playing around with the code from the following blog but can't seem to get it to work (through the serial interface, the botboarduino is not properly receiving the ps2 emulated commands). I'm not sure if this is the correct approach, or if there is a better way (or if someone has done something similar successfully).

Again, this is the setup I am trying to emulate with my quadruped and botborduino: Procrastineering - Project blog for Johnny Chung Lee: Simulated PS2 Controller for Autonomously playing Guitar Hero