Go to Post I had so much to say but I dont know how to get it accross -- but to all of you that we were involved with this weekend, thankyou for everything -- we're changing lives, and we truly are moving mountains, in more ways than one. - Jacqui Sutton [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 08-11-2014, 20:49
Timothyw0 Timothyw0 is offline
Registered User
FRC #4573
 
Join Date: Jan 2014
Location: South River
Posts: 4
Timothyw0 is an unknown quantity at this point
Logitech F310 Control Scheme Help

Hey guys,
So my team decided to switch to Java programming this year since we want to edge away from the basics of Labview. Everything's going swell so far however we encountered an issue with the control scheme that our drive team is used to. Our drive team uses the gamepad in a fps-like sense. The left joystick is utilized to move the robot forward and backwards while the right joystick is used to rotate the robot. Much like an fps, the controller's joysticks would be used in multiple directions to move the robot forward while turning a slight bit. Our programming team has worked tremendously hard on creating a formula to get this to work but we can't seem to get it. Could you guys possibly help us at all? Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 08-11-2014, 20:56
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is offline
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
Re: Logitech F310 Control Scheme Help

The simplest way to do that is:
Code:
rightPower = leftStickY - rightStickX
leftPower = leftStickY + rightStickX
For a slightly better version, see this method.
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist
Reply With Quote
  #3   Spotlight this post!  
Unread 08-11-2014, 21:32
bladetech932's Avatar
bladetech932 bladetech932 is offline
Programmer of awesome
AKA: Jon
FRC #0932 (Circuit Chargers)
Team Role: College Student
 
Join Date: May 2009
Rookie Year: 2009
Location: Tulsa
Posts: 242
bladetech932 is on a distinguished road
Re: Logitech F310 Control Scheme Help

Could you elaborate on why you are edging away from LabVIEW? Just out of curiosity.
__________________
Expect the best, Prepare for the worst
Reply With Quote
  #4   Spotlight this post!  
Unread 08-11-2014, 22:49
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Logitech F310 Control Scheme Help

Correct me if I'm misunderstanding what you're asking, but I think the arcade drive method in wpilibs RobotDrive class will do exactly what you want.

http://team2168.org/javadoc/edu/wpi/...ouble, double)


There's some code examples here you could modify:
http://wpilib.screenstepslive.com/s/...botdrive-class

I'd type up an example, but I'm on my phone. Let us know if you need some more guidance.
__________________
http://team2168.org

Last edited by otherguy : 08-11-2014 at 22:51.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-11-2014, 12:55
lamk lamk is offline
Ken Lam
FRC #4719
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Calgary
Posts: 69
lamk is just really nicelamk is just really nicelamk is just really nicelamk is just really nice
Re: Logitech F310 Control Scheme Help

Using the different methods in RobotDrive will be the easiest way to do it but what exactly you want to achieve with the right stick will dictate your code.
There is always confusion about what the right stick do.

Code:
arcadeDrive

public void arcadeDrive(double moveValue,
                        double rotateValue,
                        boolean squaredInputs)
Arcade drive implements single stick driving. This function lets you directly provide joystick values from any source.
Parameters:
moveValue - The value to use for forwards/backwards
rotateValue - The value to use for the rotate right/left
squaredInputs - If set, dereases the sensitivity at low speeds
In Arcade Drive, the right stick will rotate the robot even if the left stick is at mid stick. This is how our last driver likes to drive.

Code:
drive

public void drive(double outputMagnitude,
                  double curve)
Drive the motors at "speed" and "curve". The speed and curve are -1.0 to +1.0 values where 0.0 represents stopped and not turning. The algorithm for adding in the direction attempts to provide a constant turn radius for differing speeds. This function will most likely be used in an autonomous routine.
Parameters:
outputMagnitude - The forward component of the output magnitude to send to the motors.
curve - The rate of turn, constant for different forward speeds.
Myself, coming form remote control helicopter background, the left stick is the throttle and the right stick controls the turn rate. So if the left stick is at midstick nothing will happen even if you push the right stick completely over to the side. I can go full throttle with a very gentle curve by just moving the right stick a little bit or I can go very slow with an acute turn by moving the left stick only a little bit and the right stick bang to the side.


Attached the code for our 2 speed off season chassis using a logitech F310 gamepad as our controller. The left stick is the throttle and the right stick controls the turn rate. The inputs are squared to decrease the sensitivity at midstick(actually it is still very twitchy, may go cubed). If you decide to use arcadeDrive instead you don't need to use the formula I have put in the code cause you can ask the input to be squared at the constructor level.
If you want more sophisticated way to do it like cheesy drive you can look at team 254's code in Github.
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class RobotTemplate extends SimpleRobot {
    private Talon rightMotor = new Talon(1);
    private Talon leftMotor = new Talon (2);
    
    private RobotDrive chassis = new RobotDrive(rightMotor,leftMotor);
    private Joystick f310 = new Joystick(1);
    

    private Compressor compressor = new Compressor(1,1);
    private Solenoid shifterOne = new Solenoid(1);
    private Solenoid shifterTwo = new Solenoid(2);

    public RobotTemplate() {
        

        compressor.start();
    }
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
      
      
       while (isOperatorControl() && isEnabled()) {

            double rawleftY = f310.getRawAxis(2);
            double rawrightX = f310.getRawAxis(4);
            double leftY = rawleftY * rawleftY * rawleftY / Math.abs(rawleftY);
            double rightX = rawrightX * rawrightX * rawrightX / Math.abs(rawrightX);

            chassis.drive(leftY, rightX);

            if (f310.getRawButton(2)) {

                shifterOne.set(true);
                shifterTwo.set(true);

            } else if (f310.getRawButton(3)) {
                shifterOne.set(false);
                shifterTwo.set(false);
            }
        }
      
      
      
    }
    
    /**
     * This function is called once each time the robot enters test mode.
     */
    public void test() {
    
    }
}
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 11-11-2014, 14:15
JamieKilburn JamieKilburn is offline
Registered User
FRC #0610 (The Coyotes)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2013
Location: Toronto, Ontario
Posts: 15
JamieKilburn has a spectacular aura aboutJamieKilburn has a spectacular aura about
Re: Logitech F310 Control Scheme Help

Hi! For our controllers, we use the left stick to control forward/backward, and right stick to control left/right movement. Is this something similar to what you want? A sample implementation of this could be something along the lines of
Code:
 leftSpeed = y-x; 
rightSpeed = y+x; 
//y = Y axis of left joystick
//x = X axis of right joystick
If you have any other questions, please ask away!
Reply With Quote
  #7   Spotlight this post!  
Unread 11-11-2014, 22:51
lamk lamk is offline
Ken Lam
FRC #4719
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Calgary
Posts: 69
lamk is just really nicelamk is just really nicelamk is just really nicelamk is just really nice
Re: Logitech F310 Control Scheme Help

Quote:
Originally Posted by JamieKilburn View Post
Hi! For our controllers, we use the left stick to control forward/backward, and right stick to control left/right movement. Is this something similar to what you want? A sample implementation of this could be something along the lines of
Code:
 leftSpeed = y-x; 
rightSpeed = y+x; 
//y = Y axis of left joystick
//x = X axis of right joystick
If you have any other questions, please ask away!
Mr. Lim (Mentor of Jamie's team) called it the Kaj Drive.
"Kaj refers to Kajeevan, a long-standing and well-decorated former driver for 188 who pushed hard for this drive layout as a grade 9 driver, and used it to great effect ever since."
Here's the code written by one of his student.
Note how Mr. Lim's student decrease the midstick sensitivivty by using x^5:
Code:
//DRIVETRAIN--------------------------------------------------------------------------------------------
            
            //kaj drive (max forward and back = 90%)
            //          (max left and right = 75%)
            jagLeft.setX(-0.9 * (driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6))
                                 + 0.75 * (driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3)));
            jagRight.setX(-0.9 * (driverStick.getRawAxis(6)* driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6))
                                 - 0.75 * (driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3)* driverStick.getRawAxis(3) * driverStick.getRawAxis(3)));
https://code.google.com/p/crescent-c...svn644&r=64 4
__________________

Last edited by lamk : 11-11-2014 at 22:57.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-11-2014, 08:28
JamieKilburn JamieKilburn is offline
Registered User
FRC #0610 (The Coyotes)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2013
Location: Toronto, Ontario
Posts: 15
JamieKilburn has a spectacular aura aboutJamieKilburn has a spectacular aura about
Re: Logitech F310 Control Scheme Help

Quote:
Originally Posted by lamk View Post
Mr. Lim (Mentor of Jamie's team) called it the Kaj Drive.
"Kaj refers to Kajeevan, a long-standing and well-decorated former driver for 188 who pushed hard for this drive layout as a grade 9 driver, and used it to great effect ever since."
Here's the code written by one of his student.
Note how Mr. Lim's student decrease the midstick sensitivivty by using x^5:
Code:
//DRIVETRAIN--------------------------------------------------------------------------------------------
            
            //kaj drive (max forward and back = 90%)
            //          (max left and right = 75%)
            jagLeft.setX(-0.9 * (driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6))
                                 + 0.75 * (driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3)));
            jagRight.setX(-0.9 * (driverStick.getRawAxis(6)* driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6) * driverStick.getRawAxis(6))
                                 - 0.75 * (driverStick.getRawAxis(3) * driverStick.getRawAxis(3) * driverStick.getRawAxis(3)* driverStick.getRawAxis(3) * driverStick.getRawAxis(3)));
https://code.google.com/p/crescent-c...svn644&r=64 4


Yep, for Kaj Drive we usually cube it to smoothen the sensitivity. Another example of it is:
Code:
  
        //Create variables for x, y, right speed and the left speed
        double rightSpeed, leftSpeed, x, y;
        //Set x and y to their axis values
        x = driver.getRawAxis(InputConstants.rightXAxis);
        y = driver.getRawAxis(InputConstants.leftYAxis);
        //Drive Smoothing

        //Set the left and rightspeed using x and y
        leftSpeed = y - x;
        rightSpeed = y + x;
        

        //Set the left and right side of the drive
        driveTrain.setLeftVBus(-leftSpeed);
        driveTrain.setRightVBus(-rightSpeed);
If you have any questions about Kaj, ask away!
Reply With Quote
Reply


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 13:11.

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