Go to Post Also you NEVER need to apologize for asking questions. Asking questions is how you learn. - akoscielski3 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 31-01-2015, 19:40
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
[C++] Use CAN Talons in RobotDrive

We are using CAN for the first time and after a few hours of learning how to do it, wiring, and formatting the Talons, our drive code didn't work. I tried controlling each motor individually and it works perfectly, but we would like to use RobotDrive because we are using Mecanum wheels with a gyro. Here is the non-working code:
Code:
class Robot: public SampleRobot {
	Joystick driveStick;
	CANTalon leftFront;
	CANTalon leftBack;
	CANTalon rightFront;
	CANTalon rightBack;
	RobotDrive drive;
	Gyro gyro;
public:
	Robot() :
		driveStick(1),
		leftFront(1),
		leftBack(5),
		rightFront(2),
		rightBack(6),
		drive(leftFront, leftBack, rightFront, rightBack),
		gyro(0)
{}
	void OperatorControl() {
		gyro.InitGyro();
		gyro.Reset();
		while (IsOperatorControl() && IsEnabled()) {
			drive.MecanumDrive_Cartesian(driveStick.GetX(),driveStick.GetY(),driveStick.GetThrottle(),gyro.GetAngle());
		}
	}
};
And here is the working code (I used tank drive to make it easier):
Code:
class Robot: public SampleRobot {
	Joystick driveStick;
	CANTalon leftFront;
	CANTalon leftBack;
	CANTalon rightFront;
	CANTalon rightBack;
	Gyro gyro;
public:
	Robot() :
		driveStick(1),
		leftFront(1),
		leftBack(5),
		rightFront(2),
		rightBack(6),
		gyro(0)
{}
	void OperatorControl() {
		gyro.InitGyro();
		gyro.Reset();
		while (IsOperatorControl() && IsEnabled()) {
			leftFront.Set(-driveStick.GetY());
			leftBack.Set(-driveStick.GetY());
			rightFront.Set(driveStick.GetThrottle());
			rightBack.Set(driveStick.GetThrottle());
		}
	}
};
Does anyone know why this doesn't work? Thanks!
 


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 01:49.

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