Go to Post Remember the volunteering is not mandatory for the people to do it. It IS mandatory if FIRST is to survive and the regionals to leave a positive impact on everybody. - Alavinus [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 05-02-2015, 10:09
kmateti kmateti is offline
Registered User
FRC #3494
 
Join Date: May 2014
Location: United States
Posts: 2
kmateti is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Please post your progress... we have the same exact need, and are hard coding our drive code currently... CAN has so many benefits, but so does using RobotDrive...

Thanks!
  #17   Spotlight this post!  
Unread 05-02-2015, 10:15
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by kmateti View Post
Please post your progress... we have the same exact need, and are hard coding our drive code currently... CAN has so many benefits, but so does using RobotDrive...

Thanks!
We haven't had any time to test really, so we have just hardcoded the Mecanum drive with no gyro. I hope that we can get RobotDrive sorted out later today, but I'm not too sure. Of course I'll post the solution here though if we find it!
  #18   Spotlight this post!  
Unread 05-02-2015, 11:43
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 531
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: [C++] Use CAN Talons in RobotDrive

This might help, I ran this code on my mec bot, with gyro and CANTalons. I use IterativeRobot (it's just my preference).

http://www.chiefdelphi.com/forums/sh...3&postcount=20
  #19   Spotlight this post!  
Unread 05-02-2015, 12:08
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by ozrien View Post
This might help, I ran this code on my mec bot, with gyro and CANTalons. I use IterativeRobot (it's just my preference).

http://www.chiefdelphi.com/forums/sh...3&postcount=20
Thanks! I'll have to try this later. I did just get RobotDrive working by putting this before the drive function:
Code:
leftFront->SetControlMode(CANSpeedController::kPercentVbus);
leftBack->SetControlMode(CANSpeedController::kPercentVbus);
rightFront->SetControlMode(CANSpeedController::kPercentVbus);
rightBack->SetControlMode(CANSpeedController::kPercentVbus);
There are problems with this solution though. For example, I can't reverse the motors anymore (it doesn't drive as soon as I add SetInvertedMotor in). I have another idea though that I will try later.
  #20   Spotlight this post!  
Unread 05-02-2015, 20:41
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Ok I got it working! It's kind of an unusual workaround, but it works fine for us. Basically, create 4 fake motor controllers on unused PWM ports, and pass those to RobotDrive. From there, set the values of the real motor controllers to the values of the fake ones. Here is part of the code we used:
Code:
CANTalon *leftFront = new CANTalon(1); //Real ones
CANTalon *leftBack = new CANTalon(5);
CANTalon *rightFront = new CANTalon(2);
CANTalon *rightBack = new CANTalon(6);

TalonSRX *PWMlf = new TalonSRX(0); //Fake ones
TalonSRX *PWMlb = new TalonSRX(1);
TalonSRX *PWMrf = new TalonSRX(2);	
TalonSRX *PWMrb = new TalonSRX(3);	

void TeleopPeriodic()
{
	drive->MecanumDrive_Cartesian(driveStick->GetX(), driveStick->GetY(), driveStick->GetZ(), gyro->GetAngle());
	leftFront->Set(PWMlf->Get());
	leftBack->Set(PWMlb->Get());
	rightFront->Set(PWMrf->Get());
	rightBack->Set(PWMrb->Get());
}
  #21   Spotlight this post!  
Unread 05-02-2015, 21:27
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 531
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: [C++] Use CAN Talons in RobotDrive

The problem looks like it's motor safety tripping. I reproduced the symptom with a similar project. Either the robot hits the motor safety trip once it boots up, or it fires during disable-to-enable transitions. When this happens the driver station will throw the MotorSafetyHelper assert (Section 16.14 in Talon SRX software reference manual), and the self-test will report "No-drive ".

I bet if you just called m_robotDrive->SetLeftRightMotorOutputs(0,0) in the disabled loop, that will keep feeding the motor safety object often enough to prevent your problem.

Or alternatively just TURN OFF the feature with...
m_robotDrive->SetSafetyEnabled(false)

Using dummy PWM objects seems like a drastic workaround.

Here's what I tested. If you comment out DisabledPeriodic(), you can reproduce the problem.

Code:
#include "WPILib.h"
class MecanumDefaultCode : public IterativeRobot
{
	CANTalon lf; /*left front */
	CANTalon lr;/*left rear */
	CANTalon rf; /*right front */
	CANTalon rr; /*right rear */
public:
	RobotDrive *m_robotDrive;		// RobotDrive object using PWM 1-4 for drive motors
	Joystick *m_driveStick;			// Joystick object on USB port 1 (mecanum drive)public:
	Gyro gyro;
	/**
	 * Constructor for this "MecanumDefaultCode" Class.
	 */
	MecanumDefaultCode(void) : lf(3), lr(1), rf(4), rr(5),  gyro(0)
	{
		// Create a RobotDrive object using PWMS 1, 2, 3, and 4
		m_robotDrive = new RobotDrive(lf, lr, rf, rr);

		/* alternatively you can disable safety features if you are not source-level debugging.
		 * uncomment this line to disable safety features. */
		//m_robotDrive->SetSafetyEnabled(false);

		// Define joystick being used at USB port #0 on the Drivers Station
		m_driveStick = new Joystick(0);
	}
	void TeleopInit()
	{
		gyro.Reset();
	}
	/** @return 10% deadband */
	double Db(double axisVal)
	{
		if(axisVal < -0.10)
			return axisVal;
		if(axisVal > +0.10)
			return axisVal;
		return 0;
	}

	void DisabledPeriodic(void)
	{
		/* while we are disabled, keep calling robotDrive's
		 * set routine to keep feeding the safety helper */
		m_robotDrive->SetLeftRightMotorOutputs(0,0);
	}
	/**
	 * Gets called once for each new packet from the DS.
	 */
	void TeleopPeriodic(void)
	{
		/* grab angle */
		float angle = gyro.GetAngle();

		/* printf for debugging - leave commented so it does affect performance. */
		//std::cout << "Angle : " << angle << std::endl;

		/* use angle with mec drive */
		m_robotDrive->MecanumDrive_Cartesian(	Db(m_driveStick->GetX()),
												Db(m_driveStick->GetY()),
												Db(m_driveStick->GetZ()),
												angle);

		/* my right side motors need to drive negative to move robot forward */
		m_robotDrive->SetInvertedMotor(RobotDrive::kFrontRightMotor,true);
		m_robotDrive->SetInvertedMotor(RobotDrive::kRearRightMotor,true);
	}
};
START_ROBOT_CLASS(MecanumDefaultCode);
  #22   Spotlight this post!  
Unread 05-02-2015, 23:19
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

I tried turning the safeties off already and it didn't work, but I'll try the disabled loop tomorrow and get back. I agree that dummy PWMs is a bad solution, but we're going all CAN this year so it shouldn't really affect anything, and we will probably revert to it if your solution doesn't work because we've spent too long trying to get this to work. Thanks for the help though!
  #23   Spotlight this post!  
Unread 07-02-2015, 21:14
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 531
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by 1452-Leo View Post
I tried turning the safeties off already and it didn't work, but I'll try the disabled loop tomorrow and get back. I agree that dummy PWMs is a bad solution, but we're going all CAN this year so it shouldn't really affect anything, and we will probably revert to it if your solution doesn't work because we've spent too long trying to get this to work. Thanks for the help though!
Turning off the safeties in the CANTalons is not sufficient. They are already off (they default off). The problem is RobotDrive has it's own safety enable.

Anyway if you are still seeing the EXACT symptom of "...Motor Safety Timeout..." errors in the DS then you need to remedy it. Even with the PWM workaround (eek) you're still generating errors in your DS log. That's going to prevent your drive team from seeing other reported errors (because they will get used to seeing errors in that area of the DS".

m_robotDrive->SetSafetyEnabled(false); will absolutely prevent MS errors. If you are still seeing them then something is very wrong, and it will likely be a problem throughout the season.
  #24   Spotlight this post!  
Unread 13-02-2015, 17:54
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: [C++] Use CAN Talons in RobotDrive

Definitely turn off the motor safety on the RobotDrive object, not the individual motor controllers and see if that fixes the problem. In the library, RobotDrive is the only place where the motor safety stuff is enabled by default, and as Omar said, it is part of the RobotDrive class as a whole. The thought was that it would stopping the runaway program from driving on it's own was the highest priority.

Use something like:
drive.SetSafetyEnabled(false);

Please let us know if does it for you.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Closed Thread


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 21:11.

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