View Single Post
  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());
}