Go to Post Whatever you do, do it in graciously professional manner. - EricH [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
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 10-05-2012, 16:25
SoyStuff SoyStuff is offline
Registered User
FRC #1257
 
Join Date: Jan 2012
Location: Brooklyn
Posts: 29
SoyStuff is a jewel in the roughSoyStuff is a jewel in the roughSoyStuff is a jewel in the rough
CANJaguar Control C++

We are working with CANJaguar for the first time, and we are sort of lost. We have the motors themselves spinning, but we can't seem to control them as we want to. We're in PercentVBus mode, and we are using the regular old set function (we pass it a value between -1 and 1 using the axes on our gamepad). Instead of moving the motor at the speed that is specified, though, it gradually approaches that speed.

Here is a rough outline of our code, just highlighting stuff relating to the CANJags:
Code:
cjag(12, CANJaguar::kPercentVbus), // This is in the constructor for our drivetrain class

// Settings
cjag.SetPID(0.4, 0.005, 0);
cjag.ConfigEncoderCodesPerRev(200);
cjag.SetSpeedReference(CANJaguar::kSpeedRef_Encoder);
cjag.EnableControl();

// Moving 
cjag.Set(gamepad.GetY());
Reply With Quote
  #2   Spotlight this post!  
Unread 10-05-2012, 17:11
Andrew Schreiber Andrew Schreiber is offline
Joining the 900 Meme Team
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,062
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: CANJaguar Control C++

This is because you are using a PID controller on them. You are telling it to try to get to a certain value. Try not using the PID controller (try removing the cjag.EnableControl(); line and see if you get the same behavior)
__________________




.
Reply With Quote
  #3   Spotlight this post!  
Unread 10-05-2012, 19:30
dudefise dudefise is offline
Registered User
FRC #2637 (Panthers)
Team Role: College Student
 
Join Date: Feb 2011
Rookie Year: 2011
Location: CA
Posts: 92
dudefise is an unknown quantity at this point
Re: CANJaguar Control C++

Quote:
Originally Posted by Andrew Schreiber View Post
This is because you are using a PID controller on them. You are telling it to try to get to a certain value. Try not using the PID controller (try removing the cjag.EnableControl(); line and see if you get the same behavior)
He's right, it's due to the PID control. We also used CAN and C++ on our robot this year, and started with P as 1.0, I as 0.01 and D as 0. It will still loop, but will get to speed much quicker, although it may have significant overshoot until you tune it.

As far as I know, there is no way to control the Jaguars with encoders without a PID loop being involved.

I'm not a programmer so I'm not sure about this, but you might also need to construct the CANJaguar as CANJaguar::kSpeed instead of kPercentVbus.

Hope this helps!
__________________
2010 VRC 2453B - Team Captain
2011 FRC 2637 - Electrical - Las Vegas Regional Semifinalists with 1726 and 166
2012 FRC 2637 - Electronics Captain - Las Vegas Regional Semifinalists with 1661 and 2984
2013 FRC 2637 - Build Captain - Inland Empire Quarterfinalists with 3925 and 207
2014 FRC 2637 - College Mentor - Central Valley Quarterfinalists with 2085 and 5136 / LA Regional Semifinalists with 696 and 5102
2015 FRC 2637 - Lazy Schmuck - Couch Sitting Quarterfinalist
2016 FRC 2637 - College Mentor - SD Regional Finalist with 1572 and 2443, Excellence in Engineering, Wildcard
Reply With Quote
  #4   Spotlight this post!  
Unread 10-05-2012, 19:37
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: CANJaguar Control C++

Quote:
Originally Posted by Andrew Schreiber View Post
This is because you are using a PID controller on them. You are telling it to try to get to a certain value. Try not using the PID controller (try removing the cjag.EnableControl(); line and see if you get the same behavior)
Also note that the mode you're using uses neither PID nor encoders. You want to use speed control to use them.

It also seems to me, looking through the FIRSTForge documentation, that kPercentVbus is no longer a control mode, and has been renamed to be "kPercentVoltage".
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
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:40.

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