|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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:
Code:
TypeError: unorderable types: complex() > float() Code:
self.robot_drive.arcadeDrive(cmath.sqrt(self.joystick.getX()),cmath.sqrt(self.joystick.getX())) |
|
#2
|
|||
|
|||
|
Re: Python: TypeError: unorderable types: complex() > float()?
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().
|
|
#3
|
|||||
|
|||||
|
Re: Python: TypeError: unorderable types: complex() > float()?
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.
|
|
#4
|
||||
|
||||
|
Re: Python: TypeError: unorderable types: complex() > float()?
Quote:
|
|
#5
|
||||
|
||||
|
Re: Python: TypeError: unorderable types: complex() > float()?
Quote:
|
|
#6
|
|||
|
|||
|
Re: Python: TypeError: unorderable types: complex() > float()?
RobotDrive has support for this built in, so you should be able to just use this:
Code:
self.robot_drive.arcadeDrive(self.joystick.getX(), self.joystick.getX(), true) Code:
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)
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|