Python: TypeError: unorderable types: complex() > float()?

Hi! We have a problem when trying to sqaure root our contoller’s left and right axis for a nice speed curve. The error message is:

TypeError: unorderable types: complex() > float()

. I am doing

self.robot_drive.arcadeDrive(cmath.sqrt(self.joystick.getX()),cmath.sqrt(self.joystick.getX()))

Any help will be greatly appreciated!

Shot in the dark guess: taking the square root of getX(), which can sometimes be negative, will give you an imaginary value. You need some way to avoid that and only produce real numbers for arcadeDrive().

Even after accounting for the sign of the value, taking the square root sounds like it would bend the speed curve in the wrong direction. It would make the motors more sensitive to small inputs, instead of giving the driver more low-speed control. Most suggestions I see call for squaring or cubing the joystick value.

My bad…I mixed those up…Thanks!

How would you square negatives? Thanks!

RobotDrive has support for this built in, so you should be able to just use this:

self.robot_drive.arcadeDrive(self.joystick.getX(), self.joystick.getX(), true)

This is how it is done internally:

if squaredInputs:
            # square the inputs (while preserving the sign) to increase fine
            # control while permitting full power
            if moveValue >= 0.0:
                moveValue = (moveValue * moveValue)
            else:
                moveValue = -(moveValue * moveValue)
            if rotateValue >= 0.0:
                rotateValue = (rotateValue * rotateValue)
            else:
                rotateValue = -(rotateValue * rotateValue)