Go to Post if you do make a marshmallow robot, that would be pretty sweet. - smurfgirl [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
  #31   Spotlight this post!  
Unread 17-01-2012, 19:17
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: New to 2CAN and Jaguar

So does it mean I can only call SetPID after I call ChangeControlMode to a close-loop mode? And I assume I have to call SetPID every time after I change to a close-loop mode. In other words, the PID constants will be cleared on every mode change?
Hmm, thinking about it some more, it makes sense. Since the PID constants are different for different close-loop mode, it makes sense to set them after a close-loop mode is set.
Thanks for the info. Learn something today :-)
__________________

Last edited by mikets : 17-01-2012 at 19:26.
Reply With Quote
  #32   Spotlight this post!  
Unread 17-01-2012, 19:20
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: New to 2CAN and Jaguar

Quote:
Originally Posted by mikets View Post
So does it mean I can only call SetPID after I call ChangeControlMode to a close-loop mode? And I assume I have to call SetPID every time after I change to a close-loop mode. In other words, the PID constants will be cleared on every mode change?
The Jaguar has separate messages for setting each control mode's PID constants, so the CANJaguar class has no message ID that it can use to send those PID constants if you are not in a closed-loop mode.

I don't believe they are cleared... they are stored as separate variables in the Jaguar. That could be easily tested by setting one mode, calling SetPID, changing modes, calling SetPID again, then switching modes back and calling GetPID.
Reply With Quote
  #33   Spotlight this post!  
Unread 17-01-2012, 19:23
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: New to 2CAN and Jaguar

Yes, I remember now. I saw that behavior in bdc-comm tool.
__________________
Reply With Quote
  #34   Spotlight this post!  
Unread 17-01-2012, 20:02
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: New to 2CAN and Jaguar

I have another issue. I am also experimenting with kSpeed mode. No code this time. I am playing with the bdc-comm tool.
- I set one of the Jags to kSpeed mode
- Set the speed to 30 rpm.
- I kept Ki and Kd zero and was playing with Kp only.
- The wheel moved very jerkily (i.e. jerk forward, stop, jerk forward stop, ...) so it is making a loud clunging noise.
- I tried Kp = 1.0 and up. The larger Kp, the louder is the clunging noise.
My theory was that the Kp was too strong. It started too strong and because of the "brake" mode, it also stopped too suddenly. Basically, the "speed" was oscillating. So I cranked down Kp. Eventually, when Kp is 0.35, the wheel seems to turn smoothly. But when looking at the speed, it was very far from the target. For example if I set target to 70 rpm, it comes back with 30. When I set it to 60 rpm, it came back at 25. Am I interpreting this correctly? I am not sure about the units because the bdc-comm tool does not show me the units in Speed mode. It looks like the target value box can only accept a maximum value of 100 (may be it's a percentage? But percentage of what?).
__________________
Reply With Quote
  #35   Spotlight this post!  
Unread 17-01-2012, 20:10
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: New to 2CAN and Jaguar

Quote:
Originally Posted by jhersh View Post
If you get an error that is not "Time-out", the CANJaguar object will stop trying to talk to the device, since the calling code is clearly broken.

Is this still true with v101 of the firmware? I think this version of the firmware will bring the Jaguar back online after such a fault? Or is this a different set of circumstances?


Quote:
Originally Posted by jhersh View Post
I clearly need to write some examples for using CANJaguar in C++. Feel free to contribute some if you like.
I did spend an hour last night figuring out that I needed to call EnableControl() before it would respond to my Set() commands.

This is the code I was playing with last night to get familiar with the Jaguar closed loop current control. Basically a tank drive that commands current:

Code:
#include "testBot.h"
#include "CANJaguar.h"
#include "Joystick.h"


testBot::testBot()
{
}

testBot::~testBot()
{
}	

void testBot::OperatorControl()
{
	printf("Entering Operator Control\n");

	GetWatchdog().SetEnabled(true);	

	CANJaguar* pJag2 = new CANJaguar(2,CANJaguar::kCurrent);
	CANJaguar* pJag3 = new CANJaguar(3,CANJaguar::kCurrent);
	CANJaguar* pJag4 = new CANJaguar(4,CANJaguar::kCurrent);
	CANJaguar* pJag5 = new CANJaguar(5,CANJaguar::kCurrent);
	
	Joystick* pDriveStick1 = new Joystick(1);
	Joystick* pDriveStick2 = new Joystick(2);

	pJag2->SetPID(0.01,0.05,0);
	pJag3->SetPID(0.01,0.05,0);
	pJag4->SetPID(0.01,0.05,0);
	pJag5->SetPID(0.01,0.05,0);
	
	pJag2->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
	pJag3->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
	pJag4->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);
	pJag5->ConfigNeutralMode(CANJaguar::kNeutralMode_Coast);

	pJag2->EnableControl();
	pJag3->EnableControl();
	pJag4->EnableControl();
	pJag5->EnableControl();
		
	pJag2->Set(0, 0);
	pJag3->Set(0, 0);
	pJag4->Set(0, 0);
	pJag5->Set(0, 0);
	
	while(IsOperatorControl() && IsEnabled())
	{
		GetWatchdog().Feed();
		pJag2->Set(pDriveStick1->GetY() * 50);
		pJag4->Set(pDriveStick1->GetY() * 50);
		pJag5->Set(pDriveStick2->GetY() * -1 * 50);
		pJag3->Set(pDriveStick2->GetY() * -1 * 50);
	}
	

	printf("Leaving Operator Control\n");
}

void testBot::Autonomous()
{
	GetWatchdog().SetEnabled(false);
	
	while(IsAutonomous() && IsEnabled())
	{
	}
}

START_ROBOT_CLASS(testBot);
Reply With Quote
  #36   Spotlight this post!  
Unread 17-01-2012, 20:45
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: New to 2CAN and Jaguar

Quote:
Originally Posted by mikets View Post
For example if I set target to 70 rpm, it comes back with 30. When I set it to 60 rpm, it came back at 25. Am I interpreting this correctly? I am not sure about the units because the bdc-comm tool does not show me the units in Speed mode. It looks like the target value box can only accept a maximum value of 100 (may be it's a percentage? But percentage of what?).
Since I don't know what are the units in the bdc-comm tool, I started to play with code again setting the Jags to Speed mode and calling jag.Set(300.0) for setting 300 rpm (I think... since that's what the documentation said the unit is). But I also call jag.GetSpeed() and it came back about half. So if the set was 300, I got the speed back 150. If I set 120.0, I got back about 60.0. Is this expected?
__________________
Reply With Quote
  #37   Spotlight this post!  
Unread 18-01-2012, 01:49
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: New to 2CAN and Jaguar

Quote:
Originally Posted by mikets View Post
I have another issue. I am also experimenting with kSpeed mode. No code this time. I am playing with the bdc-comm tool.
- I set one of the Jags to kSpeed mode
- Set the speed to 30 rpm.
- I kept Ki and Kd zero and was playing with Kp only.
- The wheel moved very jerkily (i.e. jerk forward, stop, jerk forward stop, ...) so it is making a loud clunging noise.
- I tried Kp = 1.0 and up. The larger Kp, the louder is the clunging noise.
My theory was that the Kp was too strong. It started too strong and because of the "brake" mode, it also stopped too suddenly. Basically, the "speed" was oscillating. So I cranked down Kp. Eventually, when Kp is 0.35, the wheel seems to turn smoothly. But when looking at the speed, it was very far from the target. For example if I set target to 70 rpm, it comes back with 30. When I set it to 60 rpm, it came back at 25. Am I interpreting this correctly? I am not sure about the units because the bdc-comm tool does not show me the units in Speed mode. It looks like the target value box can only accept a maximum value of 100 (may be it's a percentage? But percentage of what?).
You should probably look at these threads:

http://www.chiefdelphi.com/forums/sh...d.php?t=100135
http://www.chiefdelphi.com/forums/sh...ad.php?t=90508
Reply With Quote
  #38   Spotlight this post!  
Unread 15-02-2012, 17:49
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: New to 2CAN and Jaguar

We have the same issue on jerkyness at low speed. Still trying to figure that one out... see other threads on CANbus Control. We wrote our own PID code, but may move to the Jag intrenal PID to offload cRio.

But on the Kp we had the same result as others. Kp alone will always yields a top speed of approx 1/2 setpoint. Ki however, does a beatiful job at reaching setpoint and (in our configuration) became the dominant control force.
Reply With Quote
  #39   Spotlight this post!  
Unread 15-02-2012, 19:11
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: New to 2CAN and Jaguar

In order to get a stable speed control using PID, you need to integrate the PID controller. That's why we can't use the Jaguar's built-in PID. There shouldn't be any problem with the cRIO. It would just be an extra PID calculation in the main robot loop.
__________________
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 12:45.

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