Go to Post Meh, that's nothing a freshman with a drill press and a dremel can't fix... - Chad987 [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: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 12-02-2012, 13:59
dsirovica's Avatar
dsirovica dsirovica is offline
Programming and Electrical Mentor
AKA: Dean Sirovica
FRC #1458 (Red Ties)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Alamo
Posts: 63
dsirovica is on a distinguished road
CANbus Jaguar control

We are finding several problems with CANbus control. There is no adequate documentation for the WPI lib code - this is a major failing on the part of FIRST.

Problems:
1. We used set(), setX(), and then get() and the get() results drift from what we have set! espaecially pronounced if we vary the set() values. Immediately after a set() or setX() the get() value is the same, but a few ms later it will drift quite significantly ~+/-0.1-0.3.
2. After a while (~10-100ms) the get() value goes to 0.0. We tried to use
CANjaguar.setExpiration() but that didn't do anything - following the source code it appears WPlib does not even use this parameter nor the
DEFAULT_SAFETY_EXPIRATION that is supposedly set at 0.1.
3. It seems that each call to CANbus takes ~10ms so our (very small) code that updates the motors grinds to a crawl, which we think is causing the set() to expire.
4. UpdateDashboard in the main loop - is just unusable due to the delay it causes. We used Timer to run updateDashbord only every second and the motors have a very visible slowdown every second!
5. The Timer "documentation" says it is in microseconds while it is actually in seconds. -minor issue but just highlights the quality and effort that was put into documentation (when there is any). Remember the purpose here is to educate kids, and not to teach them to give up in life!

So any pointers to:
1. perfrmance aspect of comands that use CANbus, updateDashboard, and
driverStation.update.
2. How to get the set/setX() values to stay set (a) no drift, and (b) increase timeout.

Would be greatly appreciated so we can focus on the real code.

Thanks,
Dean
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2012, 18:14
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: CANbus Jaguar control

I agree that some parts of the documentation are lacking, or even completely incorrect in some instances, but most of it isn't a giant issue (imho) that would "teach them [kids] to give up in life". Besides, even if FIRST is primarily about education (hint: it's not), not everything in life comes with a nicely written manual meticulously error-checked by a university professor.

1. Regarding CAN, are you guys using PID control and encoders? The problems you're describing sound a lot like issues with your PID values. I'm only asking because most teams only use CANs for its PID control features. If yes, then perhaps you should read the Wikipedia article on PID control loops and how to tune them. BDC-Comm is a good program to use for the black jaguars provided by FIRST.

2. You should not need to setExpiration for CAN. Place it in a thread so that other code don't interfere with its operations.

3. Same with updateDashboard, put that in a separate thread.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2012, 14:09
dsirovica's Avatar
dsirovica dsirovica is offline
Programming and Electrical Mentor
AKA: Dean Sirovica
FRC #1458 (Red Ties)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Alamo
Posts: 63
dsirovica is on a distinguished road
Re: CANbus Jaguar control

Thanks for the feedback. I am curious to hear your opinion on what is the primary mission of FIRST ?

Really when I look at the thread on the bent pins on the Jaguars - that is criminal - there is no way TI would get away selling that into a supply chain - are they dumping sub-spec stuff into kids programs? At the very least the FIRST suppliers should deliver commercial grade goods. I would actually expect that the engineers behind this would give it an extra effort since it is for kids trying to follow in their footstep.

Back to the code: Yes we implemented our own PID since the built-in one we couldn't get stable. As a result it is not running in a separate thread. Sounds like you are advising us that if we put something into a thread (PID, Dashboard, DriveStation, etc.) then we should get much better performance for the rest of the code? we'll look into that thanks - though this is getting a bit advanced for our kid programmers...

How about the drift we see between set() and get() ? Maybe threading will solve that too as we can "flood" the Jag with keep alive CAN messages.

Basically we want to achieve fine motion control so we can rotate the whole robot to the target (no need for a lazy susan), and use the same for bridge balancing. We should be able to do better than a human driver - alas doing it in code is worse!

Thanks for the help!
Dean
Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2012, 16:30
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: CANbus Jaguar control

You seem to be a bit confused about what PID does.

A PID control loop tries to make the jaguars go a certain speed. For example, if you set it to make the motor spin at 1600RPM, that's not going to make the motor actually spin at 1600RPM (due to the fact that we do not live in a frictionless, air resistance-less, ideal world).

What the PID does is it takes the current speed, and tries to make the jaguars reach what YOU want it to be. So, there will be problems with overshooting, undershooting...etc unless you adjust the PID values.

To tune the PID values, I suggest looking into using BDC-Comm. That's what we're using to tune ours.

On an off-note: Primary mission of FIRST = For Inspiration and Recognition of Science and Tech. Education is a convenient biproduct of that. Or something like that. Hey, give me credit for sitting through Dean's entire speech.
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2012, 19:08
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: CANbus Jaguar control

Seems to me like you have the wrong attitude towards this whole thing. I'm one of the "kid programmers" and so far I've already figured out PID loops, distributed image processing across multiple platforms and languages across a wireless network, among much else. So you have a bent pin on the Jaguar, fix it and move on. You're going to run into a whole lot bigger problems than that at the competition.
Reply With Quote
  #6   Spotlight this post!  
Unread 14-02-2012, 16:51
dsirovica's Avatar
dsirovica dsirovica is offline
Programming and Electrical Mentor
AKA: Dean Sirovica
FRC #1458 (Red Ties)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Alamo
Posts: 63
dsirovica is on a distinguished road
Re: CANbus Jaguar control

Thanks for the feedback. JesusRambo - great name & great to hear you are conquering all obstacles - way to go!

I'm not confused with PID but with the set/get functions. We are using
CANJaguar.ControlMode.kPercentVbus
and implementing our own PID code in our main program. It all works fine and rather cool at MotorPowerLevels>0.2. The reason we went to our own PID is primarily because we have an old 2CIM on one gearbox robot and couldn't get either the Jag based PID nor the cRio based PID functions to work nicely.

The issue we have is at MotorPowerLevels <0.2 its erratic and the get() drifts away from what we set().

For the competition robot we have one CIM per side, so may try again with built-in PIDs.

Two Qs:
1. What do you recommend: using the Jaguar's PID, or the cRIO's?
2. How low RPM can one expect to get to with reasonable stability using a Jag & CIM?
Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2012, 10:41
Doc543's Avatar
Doc543 Doc543 is offline
Electrical, Pneumatics, Driver
AKA: Eric
FRC #1891 (BullBots)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Meridian Idaho
Posts: 63
Doc543 is an unknown quantity at this point
Re: CANbus Jaguar control

1. Ive used the PID on the Jags, I couldn't figure out how to run the WPI PID.
2. I got about 450 rpm with the KOP US encoders, setting them to 360 degrees per turn

How we initialized our Jags
Code:
      //Left Master, 360 Encoder 
        left_wheel1 = new CANJaguar(2);
        left_wheel1.changeControlMode(CANJaguar.ControlMode.kSpeed);
        left_wheel1.setPID(drive_p, drive_i, drive_d);
        left_wheel1.configEncoderCodesPerRev(encoder_rev);
        left_wheel1.setSpeedReference(CANJaguar.SpeedReference.kEncoder);
        left_wheel1.enableControl();

      //Left Slave
        left_wheel2 = new CANJaguar(3);
        left_wheel2.changeControlMode(CANJaguar.ControlMode.kVoltage);
        left_wheel2.enableControl();
How we ran our jags
Code:
        try{
            left_wheel1.setX(eft_motor);//master
            left_wheel2.setX(left_wheel1.getOutputVoltage());//slave
            
        }
    	catch(Exception ex){
		ex.printStackTrace();
	    }
master, slave style, works like a charm!
__________________

"Its just a prototype."
2011 Chairman's Award Utah Regional
2010 Gracious Perfectionism Utah Regional
2009 Gracious Perfectionism Portland Regional
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2012, 15:58
dsirovica's Avatar
dsirovica dsirovica is offline
Programming and Electrical Mentor
AKA: Dean Sirovica
FRC #1458 (Red Ties)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Alamo
Posts: 63
dsirovica is on a distinguished road
Re: CANbus Jaguar control

Thanks for the code sample - great idea to do Master-Slave via Voltage.
I am confused about Voltage vs. kPercentVbus. The latter is I assume the PWM duty cycle, the former surely cannot be analogue voltage driving the motor, as that would generate immense heat in the Jag. Again very inadequate documentation on this.

Q: why did you use 360 and not the full 1440 counts per revolution (the QuadEncoder max of the KOP encoder)?

I will try your approach and report back. It sure would be great to use the LM3S2616 puppy in the Jag!

Thnaks,
Dean
Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2012, 17:03
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: CANbus Jaguar control

Quote:
Originally Posted by dsirovica View Post
I am confused about Voltage vs. kPercentVbus
http://www.chiefdelphi.com/forums/sh...4&postcount=19

Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2012, 17:52
dsirovica's Avatar
dsirovica dsirovica is offline
Programming and Electrical Mentor
AKA: Dean Sirovica
FRC #1458 (Red Ties)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Alamo
Posts: 63
dsirovica is on a distinguished road
Re: CANbus Jaguar control

Ether, thanks for the useful pointer. FYI I will search for existing or open a new thread on Voltage vs. kPercentVbus as it is still unclear and may benefit others under its own thread.
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:44.

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