Go to Post One of our electrical engineers would bring his kids in every so often, so they could actually see their dad during build season. - Karthik [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 22-09-2013, 11:57
magnets's Avatar
magnets magnets is offline
Registered User
no team
 
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
magnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond repute
Re: Converting Two joystick values into a vector

Alright, let me get this straight.

You have a setup with two joysticks that are used in a tank drive set up, and from these two, you'd like to find the angle/magnitude.

This is a little trickier, as you first need to find the amount of turn (x), then you need the amount of going forward (y) from the two axes used in tank drive.
The speed of your turn is just the difference in the speeds of two sides of the robot, and the forward speed is the average of the two sticks.

Here's some more java examples.

NOTE:See my later post for corrections!

Code:
 public double getTheta(double x, double y){
        return com.sun.squawk.util.MathUtils.atan2(y, x);
    }
    
    public double getR(double x, double y){
        return Math.sqrt((x*x)+(y*y));
    }
    
    public double getX(){
        return stick1.getY()-stick2.getY();
    }
    
    public double getY(){
        return (stick1.getY()+stick2.getY())/2;
    }
Code:
//you can get your values like this
double theta = getTheta(getX(), getY());
       double r = getR(getX(), getY());

Last edited by magnets : 22-09-2013 at 15:10.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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