Web UI - robot runs the wrong way

Hi,
My DiddyBorg status at the moment:
- Joystick control OK
- Wifi OK
- Camera OK
- PicoBorg Reverse OK
- WebUi is running, but wrong direction

i have just a little problem with the WebUi.
WebUi status:
Forward wrong direction (moves reverse)
Reverse wrong direction (moves forward)
Turn Left wrong direction (turn right)
Turn Right wrong direction (turn left)
Stop OK
Spin Left OK
Spin Right OK
Save Photo OK
Camera on WebUi: the image is rotated 180 degrees around

i hope you can help me with this problem

thank you in advance,
sorry for my bad english :)

piborg's picture

That is a little strange, the diddyWeb.py script should match the assembled DiddyBorg setup.
Which model of DiddyBorg do you have?

From the sounds of it there are two differences between the script and your DiddyBorg:

  1. The left and right motor outputs are swapped
  2. The camera is mounted the other way up

Both of these can be fixed in the script fairly easily.

To swap the motor outputs:
Change the "Set the outputs" section to read as follows:

            # Set the outputs
            driveLeft *= maxPower
            driveRight *= maxPower
            PBR.SetMotor1(-driveLeft)
            PBR.SetMotor2(driveRight)

To remove the 180 degree camera rotation:
Change the "Read the image and save globally" section to read as follows:

                    # Read the image and save globally
                    self.stream.seek(0)
                    #flippedArray = cv2.flip(self.stream.array, -1) # Flips X and Y
                    retval, thisFrame = cv2.imencode('.jpg', self.stream.array)
                    #del flippedArray
                    lockFrame.acquire()
                    lastFrame = thisFrame
                    lockFrame.release()

First, thanks for the quick response!
I was very busy the last few days.

I have the parts of an normal "DiddyBorg - The most powerful Raspberry Pi robot available" (PicoBorg Reverse, BattBorg, ...) just with a self-made case.

I changed the "diddyWeb.py" as you described it.

Now:
- Forwar OK
- Reverse OK
- Stop OK
- Turn Left and Turn Right wrong direction
- Spin Left and Spin Right wrong direction

- Camera OK

I´m going to try some things.
But if you have a possible solution for my problem , I would be very grateful ;)

Code changes:
#217 PBR.SetMotor1(driveLeft)
#218 PBR.SetMotor2(driveRight)

WebUi Button (left side) = Real function on the car (right side)
spin left = reverse
spin right = forward
forward = spin left
reverse = spin right
turn right = turn left
turn left = motors on the left side move backwards

.

Code changes:
#217 PBR.SetMotor1(-driveLeft)
#218 PBR.SetMotor2(driveRight)

WebUi Button (left side) = Real function on the car (right side)
spin left = wrong direction
spin right = wrong direction
forward = OK
reverse = OK
turn right = wrong direction
turn left = wrong direction

.

Code changes:
#217 PBR.SetMotor1(driveLeft)
#218 PBR.SetMotor2(-driveRight)

WebUi Button (left side) = Real function on the car (right side)
spin left = OK
spin right = OK
forward = wrong direction
reverse = wrong direction
turn right = wrong direction
turn left = wrong direction

.

Code changes:
#217 PBR.SetMotor1(-driveLeft)
#218 PBR.SetMotor2(-driveRight)

WebUi Button (left side) = Real function on the car (right side)
spin left = forward
spin right = reverse
forward = spin right
reverse = spin left
turn right = motors on the right side move backwards
turn left = turn right

piborg's picture

I can only think the motors are running backwards instead of being swapped.

Try this version instead:

            # Set the outputs
            driveLeft *= maxPower
            driveRight *= maxPower
            PBR.SetMotor1(-driveRight)
            PBR.SetMotor2(driveLeft)

already tried this:

Code changes:
#217 PBR.SetMotor1(-driveLeft)
#218 PBR.SetMotor2(driveRight)

WebUi Button (left side) = Real function on the car (right side)
spin left = wrong direction, spin right
spin right = wrong direction, spin left
forward = OK
reverse = OK
turn right = wrong direction, turns left
turn left = wrong direction, turns right

piborg's picture

I was suggesting that driveLeft ad driveRight should be swapped around to how they were before, then swapping only the - sign.

So you end up with this:
PBR.SetMotor1(-driveRight)
PBR.SetMotor2(driveLeft)

oh no , what an embarrassing mistake by me!
I have read the code a hundred times wrong... driveRight and driveLeft was wrong.

I changed it:
PBR.SetMotor1(-driveLeft)
PBR.SetMotor2(driveRight)

Everything is fine now :)

Thank you very much for your time and the fast answers,
very good support!!

Subscribe to Comments for "Web UI - robot runs the wrong way"