Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Python: TypeError: unorderable types: complex() > float()? (http://www.chiefdelphi.com/forums/showthread.php?t=133394)

team-4480 23-01-2015 15:37

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()
. I am doing
Code:

self.robot_drive.arcadeDrive(cmath.sqrt(self.joystick.getX()),cmath.sqrt(self.joystick.getX()))
Any help will be greatly appreciated!

Christopher149 23-01-2015 15:46

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().

Alan Anderson 23-01-2015 16:05

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

Originally Posted by team-4480 (Post 1432869)
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

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

Originally Posted by Alan Anderson (Post 1432895)
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

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

Originally Posted by Alan Anderson (Post 1432895)
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

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

Originally Posted by team-4480 (Post 1433512)
How would you square negatives? Thanks!

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)
This is how it is done internally:
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)



All times are GMT -5. The time now is 02:41.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi