Go to Post CAD pictures are cool, but hardware in hand is cooler. :) - ajlapp [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 18-01-2016, 21:02
christheman200's Avatar
christheman200 christheman200 is offline
Chris Lansdale, Programmer
AKA: Chris Lansdale
FRC #0854 (Iron Bears)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Toronto, Ontario
Posts: 31
christheman200 is an unknown quantity at this point
Unable to invert motor

Hi all!
I have the following code in my main robot class, and it is giving me a number of exceptions which I can't conquer:
Code:
MainDrive.setInvertedMotor(Talon.kRearLeft, true); 
	MainDrive.setInvertedMotor(Talon.kRearRight, true);
Exceptions:
First line:
- Syntax error on tokens, delete these tokens
- Syntax error on token "(", < expected
Second line:
- Syntax error on tokens, TypeArgument1 expected instead
- Syntax error on token "(", , expected

Any and all help is appreciated!
Thanks, Chris
Reply With Quote
  #2   Spotlight this post!  
Unread 18-01-2016, 21:16
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Unable to invert motor

The errors themselves make no sense but theres some issues
  1. Why is MainDrive capitalized? variables should be lowerCamelCase
  2. You mean RobotDrive.MotorType.kRearLeft, not Talon.

There may be other syntax errors in the code as well.. post the entire file
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 18-01-2016, 22:55
Tparbotmail Tparbotmail is offline
Registered User
FRC #3944
 
Join Date: Jan 2015
Location: Az
Posts: 69
Tparbotmail is an unknown quantity at this point
Re: Unable to invert motor

robotDrive.setInvertedMotor(RobotDrive.MotorType.k FrontRight, true);
Reply With Quote
  #4   Spotlight this post!  
Unread 19-01-2016, 07:26
christheman200's Avatar
christheman200 christheman200 is offline
Chris Lansdale, Programmer
AKA: Chris Lansdale
FRC #0854 (Iron Bears)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Toronto, Ontario
Posts: 31
christheman200 is an unknown quantity at this point
Re: Unable to invert motor

Here's the rest of the code. I've tried the fixes mentioned above, but they haven't seemed to help.
Code:
package org.usfirst.frc.team854.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
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 IterativeRobot
 * 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 Robot extends IterativeRobot {
	
	Joystick driveStick1 = new Joystick(1);
	Joystick driveStick2 = new Joystick(2);
	RobotDrive MainDrive = new RobotDrive(0,1);
	
	MainDrive.setInvertedMotor(Talon.kRearLeft, true); 
	MainDrive.setInvertedMotor(Talon.kRearRight, true);
	
	Talon lifter = new Talon(3);
	
	float lifterSpeed = 1.0f; //f for float (to have decimals!)
	
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
    	
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        MainDrive.tankDrive(driveStick1, driveStick2);
        
        
        if(driveStick2.getRawButton(3))
        	lifter.set(lifterSpeed);
        else if(driveStick2.getRawButton(5))
        	lifter.set(-lifterSpeed);
        else
        	lifter.set(0.0);
        
    }

	/**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
    
    }
    
}
Reply With Quote
  #5   Spotlight this post!  
Unread 19-01-2016, 08:51
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Unable to invert motor

you put it inside of the class declaration.

Move those calls to robotInit()

You can only declare functions and variables in that space you put the two calls, you can't do anything else like call functions
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #6   Spotlight this post!  
Unread 19-01-2016, 09:45
electronicsdude's Avatar
electronicsdude electronicsdude is offline
Registered User
AKA: Spencer
FRC #4918 (The Roboctopi)
Team Role: Engineer
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Port Townsend, WA
Posts: 15
electronicsdude will become famous soon enoughelectronicsdude will become famous soon enough
Re: Unable to invert motor

Quote:
Originally Posted by christheman200 View Post
Hi all!
I have the following code in my main robot class, and it is giving me a number of exceptions which I can't conquer:
Code:
MainDrive.setInvertedMotor(Talon.kRearLeft, true); 
	MainDrive.setInvertedMotor(Talon.kRearRight, true);
Exceptions:
First line:
- Syntax error on tokens, delete these tokens
- Syntax error on token "(", < expected
Second line:
- Syntax error on tokens, TypeArgument1 expected instead
- Syntax error on token "(", , expected

Any and all help is appreciated!
Thanks, Chris
Just flip the polarity on the motor side of your motor controller. its legal as long as you label it and it works like a dream.
Reply With Quote
  #7   Spotlight this post!  
Unread 19-01-2016, 11:40
christheman200's Avatar
christheman200 christheman200 is offline
Chris Lansdale, Programmer
AKA: Chris Lansdale
FRC #0854 (Iron Bears)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Toronto, Ontario
Posts: 31
christheman200 is an unknown quantity at this point
Re: Unable to invert motor

Thanks guys!
I managed to work it out through trial and error, but thanks for clearing up why it works.

Chris
Reply With Quote
  #8   Spotlight this post!  
Unread 23-01-2016, 19:43
JacobD's Avatar
JacobD JacobD is offline
Registered User
AKA: Jacob
FRC #1672 (Mahwah Robo T-Birds)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2013
Location: New Jersey
Posts: 92
JacobD is an unknown quantity at this point
Re: Unable to invert motor

For future reference, I believe there is a method to invert your speed controller.

In the class SpeedController:

Code:
SpeedController.setInverted();
Correct me if I'm wrong.
__________________
SolidWorks CAD
AutoCAD
Java
Reply With Quote
  #9   Spotlight this post!  
Unread 24-01-2016, 17:41
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Unable to invert motor

Quote:
Originally Posted by JacobD View Post
For future reference, I believe there is a method to invert your speed controller.

In the class SpeedController:

Code:
SpeedController.setInverted();
Correct me if I'm wrong.
You can't invert object within RobotDrive unless they are fed to robot drive which is a bit of work
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
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 11: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