View Full Version : Python: TypeError: unorderable types: complex() > float()?
team-4480
23-01-2015, 15:37
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.joyst ick.getX()),cmath.sqrt(self.joystick.getX()))
Any help will be greatly appreciated!
Christopher149
23-01-2015, 15:46
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().
Alan Anderson
23-01-2015, 16:05
Hi! We have a problem when trying to sqaure root our contoller's left and right axis for a nice speed curve.
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.
team-4480
23-01-2015, 16:36
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!
team-4480
24-01-2015, 22:02
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.
How would you square negatives? Thanks!
Ben Wolsieffer
24-01-2015, 22:09
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)
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.