Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Inverting Axis (http://www.chiefdelphi.com/forums/showthread.php?t=133776)

Ether 02-02-2015 14:09

Re: Inverting Axis
 
Quote:

Originally Posted by GeeTwo (Post 1437326)
For an example where the simpler code is not easier to read:

Logically, you want to do a conditional:

if (c is between a and b, and you don't know whether a is larger or smaller than b) then...

Human simpler (use this!):

if ((a<b) && (b<c) || (a>b) && (b>c)) then..

Probably machine quicker, but don't use:

if ((a-b)*(b-c) > 0) then..

Either your code is wrong, or your prose description is.

I guess neither is simpler.



GeeTwo 02-02-2015 16:01

Re: Inverting Axis
 
I swapped b and c between the two. Let's correct the prose. I meant to say that b was between a and c, and you didn't know whether a or c were larger.

2386programming 03-02-2015 16:44

Re: Inverting Axis
 
Code:

double strafe = mainStick.getRawAxis(3);
        double forward = mainStick.getRawAxis(1);
        double rotation = mainStick.getRawAxis(2);


//mecanum algotrithms
        double mFL = strafe + forward + rotation;
        double mFR = strafe + forward - rotation;
        double mRL = strafe - forward + rotation;
        double mRR = strafe - forward - rotation;

        FL.set(mFL);
        FR.set(mFR);
        RL.set(mRL);
        RR.set(mRR);


This is my code for regular driving for mecanum but I feel that if I inverted the motot not everything else would be the same.

Ether 03-02-2015 17:31

Re: Inverting Axis
 
Quote:

Originally Posted by 2386programming (Post 1437809)

Code:



        double mFL = strafe + forward + rotation;
        double mFR = strafe + forward - rotation;
        double mRL = strafe - forward + rotation;
        double mRR = strafe - forward - rotation;


This is my code for regular driving for mecanum but I feel that if I inverted the motor not everything else would be the same.

The correct inverse kinematics for mecanum is:
Code:



double mFL = forward - strafeRight  - rotateClockwise;
double mFR = forward + strafeRight  + rotateClockwise;
double mRL = forward - strafeRight  + rotateClockwise;
double mRR = forward + strafeRight  - rotateClockwise;

If the above doesn't work, it's better to do the necessary motor inverting/swapping to make it work, rather than changing the signs of the kinematics.




All times are GMT -5. The time now is 13:03.

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