Go to Post I might be singing a different tune if I get a water jet for Christmas. :) - FrankJ [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2015, 16:21
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Slowing down the drive motors

Quote:
Originally Posted by notmattlythgoe View Post
Change this line:
Code:
myRobot.tankDrive(stick1,stick2);
to this:
Code:
myRobot.tankDrive(stick1.getY() * 0.5, stick2.getY() * 0.5);
Then change the 0.5 to some scalar value depending on how much you want to scale it.
A simple way to still allow full top speed but give fine control at low speeds is to square the magnitude. You'll get 1/4 speed at half throw on your joystick, and full speed at full throw:

Code:
myRobot.tankDrive(stick1.getY() * Math.abs(stick1.getY()),
stick2.getY() * Math.abs(stick2.getY());
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2015, 16:35
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Slowing down the drive motors

Quote:
Originally Posted by GeeTwo View Post
A simple way to still allow full top speed but give fine control at low speeds is to square the magnitude. You'll get 1/4 speed at half throw on your joystick, and full speed at full throw:

Code:
myRobot.tankDrive(stick1.getY() * Math.abs(stick1.getY()),
stick2.getY() * Math.abs(stick2.getY());
Correct. Only if you don't want to limit your top speed.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2015, 19:53
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: Slowing down the drive motors

Quote:
Originally Posted by notmattlythgoe View Post
Quote:
Originally Posted by GeeTwo View Post
A simple way to still allow full top speed but give fine control at low speeds is to square the magnitude. You'll get 1/4 speed at half throw on your joystick, and full speed at full throw:

Code:
myRobot.tankDrive(stick1.getY() * Math.abs(stick1.getY()),
stick2.getY() * Math.abs(stick2.getY());
Correct. Only if you don't want to limit your top speed.
Hmm. Unless I'm reading the RobotDrive code wrong:
Code:
public class RobotDrive implements MotorSafety {
    ...
    public void tankDrive(double leftValue, double rightValue, boolean squaredInputs) {

        if(!kTank_Reported) {
            UsageReporting.report(tResourceType.kResourceType_RobotDrive, getNumMotors(), tInstances.kRobotDrive_Tank);
            kTank_Reported = true;
        }

        // square the inputs (while preserving the sign) to increase fine control while permitting full power
        leftValue = limit(leftValue);
        rightValue = limit(rightValue);
        if(squaredInputs) {
            if (leftValue >= 0.0) {
                leftValue = (leftValue * leftValue);
            } else {
                leftValue = -(leftValue * leftValue);
            }
            if (rightValue >= 0.0) {
                rightValue = (rightValue * rightValue);
            } else {
                rightValue = -(rightValue * rightValue);
            }
        }
        setLeftRightMotorOutputs(leftValue, rightValue);
    }
    ...
    public void tankDrive(double leftValue, double rightValue) {
        tankDrive(leftValue, rightValue, true);
    }
It looks like tankDrive(double,double) squares the inputs by default. So doing what is suggested will ^4 the inputs. It will certainly have the advertised effect either way. But if your robot won't really move until you apply 0.4 for example, you have to get your joystick all the way out to ~0.8 before it moves.

The best plan is probably to do as Ether suggested and go piece-wise linear. Perhaps first find your sweet-spot for operating the robot (say 0.4-0.7) map your deadzone to ~10-20% less than the minimum power to drive your robot and then map 0.9 to be the maximum you want to drive and then map 1.0 to 1.0.

There are many ways to code an OI...

I'll mention that what our team sees as a way to not lose motor strength and yet drive very slowly is to use a feedback encoder system so you are asking the wheels to go 0.4 of their fastest rotation rather than 0.4 constant output voltage. This way a PID can apply full power to the wheels to get it going but quickly cut back power as you reach your requested rate. If you are moving very slowly and something gets in your way, you can apply the full power of your cims to overcome and if your wheels happen to slip the PID would likely compensate back down to the maximum power possible without overcoming friction.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-02-2015, 13:50
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Slowing down the drive motors

Quote:
Originally Posted by cstelter View Post
Hmm. Unless I'm reading the RobotDrive code wrong:
Code:
public class RobotDrive implements MotorSafety {
    ...
    public void tankDrive(double leftValue, double rightValue, boolean squaredInputs) {

        if(!kTank_Reported) {
            UsageReporting.report(tResourceType.kResourceType_RobotDrive, getNumMotors(), tInstances.kRobotDrive_Tank);
            kTank_Reported = true;
        }

        // square the inputs (while preserving the sign) to increase fine control while permitting full power
        leftValue = limit(leftValue);
        rightValue = limit(rightValue);
        if(squaredInputs) {
            if (leftValue >= 0.0) {
                leftValue = (leftValue * leftValue);
            } else {
                leftValue = -(leftValue * leftValue);
            }
            if (rightValue >= 0.0) {
                rightValue = (rightValue * rightValue);
            } else {
                rightValue = -(rightValue * rightValue);
            }
        }
        setLeftRightMotorOutputs(leftValue, rightValue);
    }
    ...
    public void tankDrive(double leftValue, double rightValue) {
        tankDrive(leftValue, rightValue, true);
    }
It looks like tankDrive(double,double) squares the inputs by default. So doing what is suggested will ^4 the inputs. It will certainly have the advertised effect either way. But if your robot won't really move until you apply 0.4 for example, you have to get your joystick all the way out to ~0.8 before it moves.

The best plan is probably to do as Ether suggested and go piece-wise linear. Perhaps first find your sweet-spot for operating the robot (say 0.4-0.7) map your deadzone to ~10-20% less than the minimum power to drive your robot and then map 0.9 to be the maximum you want to drive and then map 1.0 to 1.0.

There are many ways to code an OI...

I'll mention that what our team sees as a way to not lose motor strength and yet drive very slowly is to use a feedback encoder system so you are asking the wheels to go 0.4 of their fastest rotation rather than 0.4 constant output voltage. This way a PID can apply full power to the wheels to get it going but quickly cut back power as you reach your requested rate. If you are moving very slowly and something gets in your way, you can apply the full power of your cims to overcome and if your wheels happen to slip the PID would likely compensate back down to the maximum power possible without overcoming friction.
You are absolutely correct, the tankDrive(x, y) method does square the input values already. So squaring them again would probably make the controls worse in this case.

Last edited by notmattlythgoe : 10-02-2015 at 13:59.
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 10:53.

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