Go to Post I cannot inspire greatness with mediocrity! - Jim Zondag [more]
Home
Go Back   Chief Delphi > Technical > Electrical > CAN
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 21-01-2011, 13:49
vinnie's Avatar
vinnie vinnie is offline
Registered User
FRC #3309 (Friarbots)
Team Role: College Student
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Los Angeles / Anaheim
Posts: 107
vinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond repute
setX() not working

Not sure if I should post this here or in the Java section...
I was trying to use setX to set a speed of the motor. I set up the speed and position references. But the Jaguar would not do anything (RobotDrive works fine). I did not set PID and am wondering if this could be the problem. Thanks in advance for your help.
Reply With Quote
  #2   Spotlight this post!  
Unread 21-01-2011, 15:33
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: setX() not working

Quote:
Originally Posted by vinnie View Post
Not sure if I should post this here or in the Java section...
I was trying to use setX to set a speed of the motor. I set up the speed and position references. But the Jaguar would not do anything (RobotDrive works fine). I did not set PID and am wondering if this could be the problem. Thanks in advance for your help.
If you have configured the CANJaguar to Speed Control mode, then you must do several things to make it work... Set a speed reference, set the number of codes per rotation your encoder outputs, set the PID values (they default to 0 which will do nothing), then call enableControl().

-Joe
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2011, 21:19
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: setX() not working

related question: is there a default number of ticks per revolution? I had everything you listed set but that value, and the speed was always reported as 0.0. Tomorrow I'll try setting some arbitrary value (or maybe look up the proper one ).
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2011, 23:17
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: setX() not working

Quote:
Originally Posted by JewishDan18 View Post
related question: is there a default number of ticks per revolution? I had everything you listed set but that value, and the speed was always reported as 0.0. Tomorrow I'll try setting some arbitrary value (or maybe look up the proper one ).
Guess what... the default is 0. You must set it.

-Joe
Reply With Quote
  #5   Spotlight this post!  
Unread 22-01-2011, 22:50
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: setX() not working

Ok, so I set the number of ticks, and setSpeed still does not seem to work. Here's what I've written.

Code:
    CANJaguar jag;
    
    public void robotInit() {
        try {
            jag = new CANJaguar(4);
            jag.setPID(1, 1, 0);
            jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
            jag.changeControlMode(CANJaguar.ControlMode.kSpeed);
            jag.configEncoderCodesPerRev(100);
            jag.enableControl();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Code:
    public void teleopPeriodic() {
        try {
            jag.setX(10);
            System.out.println(jag.getSpeed() + " " + jag.getOutputVoltage() +
                               " " + jag.getOutputCurrent() + " " + 
                               jag.getTemperature() + " " + jag.isAlive() +
                               " " + jag.isSafetyEnabled());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
During Current or Voltage control, the encoder reads fine. But in Speed control, no signal to drive is sent to the jaguar (light is yellow, both outputs are 0, as is the speed). Is there something I'm forgetting to set? Thanks.
Reply With Quote
  #6   Spotlight this post!  
Unread 23-01-2011, 02:45
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: setX() not working

Quote:
Originally Posted by JewishDan18 View Post
Ok, so I set the number of ticks, and setSpeed still does not seem to work. Here's what I've written.

Code:
    CANJaguar jag;
    
    public void robotInit() {
        try {
            jag = new CANJaguar(4);
            jag.setPID(1, 1, 0);
            jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
            jag.changeControlMode(CANJaguar.ControlMode.kSpeed);
            jag.configEncoderCodesPerRev(100);
            jag.enableControl();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Code:
    public void teleopPeriodic() {
        try {
            jag.setX(10);
            System.out.println(jag.getSpeed() + " " + jag.getOutputVoltage() +
                               " " + jag.getOutputCurrent() + " " + 
                               jag.getTemperature() + " " + jag.isAlive() +
                               " " + jag.isSafetyEnabled());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
During Current or Voltage control, the encoder reads fine. But in Speed control, no signal to drive is sent to the jaguar (light is yellow, both outputs are 0, as is the speed). Is there something I'm forgetting to set? Thanks.
The code looks OK at first glance. My guess would be that your PID constants are too small. Try increasing the P at least to see if that has any impact.

-Joe
Reply With Quote
  #7   Spotlight this post!  
Unread 23-01-2011, 09:33
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: setX() not working

I forgot to mention that with 100 ticks per revolution, my test rig reaches a max speed of 900 rpm. I'll try P=100 today, along with many other combinations of constants, and get back to you. Thanks.
Reply With Quote
  #8   Spotlight this post!  
Unread 23-01-2011, 16:33
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: setX() not working

Ok, I found the issue. Instead of doing something like this

Code:
jag2 = new CANJaguar(2);
jag2.changeControlMode(CANJaguar.ControlMode.kSpeed);
I had to do this

Code:
jag2 = new CANJaguar(2,CANJaguar.ControlMode.kSpeed);
I want to look into switching control modes, since I feel position control would be useful during autonomous, and speed would be used for teleoperated.
Reply With Quote
  #9   Spotlight this post!  
Unread 23-01-2011, 16:58
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: setX() not working

Quote:
Originally Posted by JewishDan18 View Post
Ok, I found the issue. Instead of doing something like this

Code:
jag2 = new CANJaguar(2);
jag2.changeControlMode(CANJaguar.ControlMode.kSpeed);
I had to do this

Code:
jag2 = new CANJaguar(2,CANJaguar.ControlMode.kSpeed);
I want to look into switching control modes, since I feel position control would be useful during autonomous, and speed would be used for teleoperated.
Ah yes... your symptoms reminded me of why your code did not work...

setPID() sets the PID constants for the control mode you are in. The original code you posted will work if you move setPID() below changeControlMode().

-Joe
Reply With Quote
  #10   Spotlight this post!  
Unread 23-01-2011, 17:43
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: setX() not working

Quote:
Originally Posted by JewishDan18;1006118[CODE
public void teleopPeriodic() {
try {
jag.setX(10);
System.out.println(jag.getSpeed() + " " + jag.getOutputVoltage() +
" " + jag.getOutputCurrent() + " " +
jag.getTemperature() + " " + jag.isAlive() +
" " + jag.isSafetyEnabled());
} catch (Exception e) {
e.printStackTrace();
}
}[/code]
I am confused. My team is triying to use CAN to control a swerve drive, and most of this makes sense. The System.out.print is what puzzles me. Where does this print to?? Obviously it won't go to the driver station lcd, but how would you go about configuring a laptop (I am assuming that is where it would ultimatly print to, but I am unsure where) so that you can operate the robot and see the System.out.print?

A concerned programmer
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
Reply With Quote
  #11   Spotlight this post!  
Unread 23-01-2011, 17:47
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: setX() not working

Quote:
Originally Posted by buildmaster5000 View Post
I am confused. My team is triying to use CAN to control a swerve drive, and most of this makes sense. The System.out.print is what puzzles me. Where does this print to?? Obviously it won't go to the driver station lcd, but how would you go about configuring a laptop (I am assuming that is where it would ultimatly print to, but I am unsure where) so that you can operate the robot and see the System.out.print?

A concerned programmer
Assuming you are using NetBeans and Java, it prints to the NetBeans "Output" tab below the Source frame.

-Joe
Reply With Quote
  #12   Spotlight this post!  
Unread 23-01-2011, 18:07
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: setX() not working

So if i plug the laptop into the cRIO port 1 and boot the robot I should get all the println?? How would I run the robot from the driver station then??
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
Reply With Quote
  #13   Spotlight this post!  
Unread 23-01-2011, 18:13
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: setX() not working

I'm using Ubuntu with Netbeans installed there, and have the driver station running in a virtual machine of Windows XP (Remember that any computer can act as the driver station). The println's go to Netbeans. if you have the driver station on a seperate laptop, simply plug both of them into the D-Link (or put one/both on wireless), and run the code from netbeans to get it to display the output. Make sure no IPs conflict!



Quote:
setPID() sets the PID constants for the control mode you are in. The original code you posted will work if you move setPID() below changeControlMode().
That makes a lot of sense, since if I were to use different modes, I'd want different PID constants for each mode. Thanks a lot for the clarification.
Reply With Quote
  #14   Spotlight this post!  
Unread 23-01-2011, 18:27
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: setX() not working

DUH I cant believe I didnt think of that before. Thanks so much!
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
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 02:50.

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