Loading...

Ways to control the T-Bot

The simplest way to control your T-Bot is the use the T-Bot Controller.

TBot Android Controller

Connect your android device to you T-Bot

Close Joystick bluetooth Commander and pair your Android device with your T-Bot

Connecting

Open the T-Bot Controller, switch on your T-Bot and press connect. Select your T-Bot from the list. Once connected, the controller will monitor the connection and automatically reconnect if the connection is lost.

T-Bot Controller Screen Shots


Adjusting the Trim
Initially, the most important thing you will have to change on your T-Bot is the trim. You can can use the - and + buttons next to the Trim button in the app to adjust this. You will see the third value in blue change slowly. If your T-Bot is rushing forward, press - repeatedly until the drift is removed. Likewise, if your T-Bot is rushing backwards press + repeatedly until the drift is removed. Once you're happy, you can hard code the trim value into the TBot.ino file. Look for the following lines and set gtrim to the value showing in the Trim datafield (3.0 in the example above). You can now upload the T-Bot.ino code to the T-Bot to make the change persistent.

////////////////////  Speed and Stability tunings   /////////////////////////

float gtrim = -1.25;   // Compensated for drift in forward or reverse direction.

float rtrim = -0.0; // Compensated for rotational drift.



Controlling the T-Bot using Python

There are two versions of the Python controller bundled with your T-Bot software. These have been tested on Linux. You might have do do some googling to get them working on Windows or Mac computers. One uses Pybluez to handel the Bluetooth connection and was written for Python 2 users, the other was written for Python 3 users and uses Socket to handel the Bluetooth connection. Windows users shoul look at PySerial.

PyBluez Version

You can allow the software to search for your T-Bot or if you know the mac address, you can hard code it in to the software to speed up the connection process.

search = False
bd_addr = '98:D3:32:11:4C:CF' # put the bluetooth address of your T-Bot here.

Then launch a command terminal type the following to launch the Joystick:

python Controller.py



Socket Version

The socket version does not have the search function so you need to know the mac address. This can be stored as a python dictionary in the MAC_Adresses file. Multiple address can be stored if you have more than one T-Bot

{'George': '98:d3:32:11:4c:cf'}

Launch with:

python3 Controller.py

TBot Controller

pySerial Version (Windows 10)

Switch on your T-Bot. Open 'Bluetooth and other device'. Click on 'Add Bluetooth or other devices'. When the dialogue window opens, click on Bluetooth. Your T-Bot should show up as Unknown Device which will change to HC-05 or the name you chose. The PIN is 1234 if you haven't changed it. Now open Control Panel > Hardware and Sound > Devices and Printers. You should now see your T-Bot under Unspecified. Right click and select properties. Click on the Hardware tab. You will see two device functions in the list. The second one will have the port number eg. COM6. Take note of this and edit Controller.py

port = 'COM9'
sock = serial.Serial(port, baudrate)
      

Now launch Controller.py. Spyder is good for this. You might have to run it as administrater.

pySerial Version (Mac)

Install Pygame and pySerial

    sudo easy_install pip
    sudo pip install pygame
    sudo pip install pyserial
      

Open System Preferences > Bluetooth. Pair your T-Bot. Open a terminal and type:

ls /dev/*NameOfYourTbot*
      

The result should look like this:

cu.NameOfYourTbot-DevB	tty.NameOfYourTbot-DevB
      

Now update Controller.py with the port name including the path.

port = '/dev/tty.NameOfYourTbot-DevB'
        sock = serial.Serial(port, baudrate)