FollowMe Example with MonsterBorg

I don't suppose anyone has had luck getting something like the FollowMe or Ball follow example to work on the Monsterborg? I've tried, with my extremely limited experience, to make the necessary changes to port the example over but the errors are too numerous to sift through.

Before anyone asks, I did replace all instances of ZB and ZeroBorg with TB and ThunderBorg and set the power settings correctly. There were also some issues with the comms failsafe, led functions and then some general threading/picamera stuff that didn't work either.

Suggestions?

piborg's picture

For the ball following you can start from the DiddyBorg v2 version of the script. diddy2FollowBall.py, which is already written for the ThunderBorg :)

All you will need to do in that script is swap the left and right motor outputs on the ThunderBorg. Look for these lines:

        TB.SetMotor1(driveLeft)
        TB.SetMotor2(driveRight)

and swap the left and right like this:

        TB.SetMotor1(driveRight)
        TB.SetMotor2(driveLeft)

The yeti2FollowMe.py script will be a bit more difficult to convert as there are a fair number of differences between the two.

As you have done, the first step is to replace ZeroBorg with ThunderBorg in all cases. This includes the ZeroBorg.ScanForZeroBorg() which needs to be ThunderBorg.ScanForThunderBorg(). Changing ZB to TB is not strictly required, but it will help avoid confusion :)

The next thing is to remove the ZB.ResetEpo() line. This function is not available on the ThunderBorg.

After that we need to correct the LED functionality. Start by adding this line at the bottom of the setup section:

TB.SetLedShowBattery(False)

This allows the script to control the LED instead of showing the battery level. Now change this line at the end of the script:

ZB.SetLed(False)

for this one:

TB.SetLeds(0,0,0)

We also need to change the LED for showing motion, I suggest we use red for a detection and green for none. Look for this line:

        ZB.SetLed(motionDetected)

and swap if for these lines:

        if motionDetected:
            TB.SetLeds(1,0,0)
        else:
            TB.SetLeds(0,1,0)

The last thing that needs to be changed is the motor outputs. Look for these lines:

        # Set the motors
        ZB.SetMotor1(-driveRight * maxPower) # Rear right
        ZB.SetMotor2(-driveRight * maxPower) # Front right
        ZB.SetMotor3(-driveLeft  * maxPower) # Front left
        ZB.SetMotor4(-driveLeft  * maxPower) # Rear left

and change them to:

        # Set the motors
        TB.SetMotor1(driveRight * maxPower)
        TB.SetMotor2(driveLeft * maxPower)

That should be all the changes needed. Remember Python is very picky about the spacing at the start of each line, as such we suggest using the space bar to get them right, not the tab key.

Subscribe to Comments for "FollowMe Example with MonsterBorg"