Go to Post A big bowl of popcorn and FIRST. It doesn't get much better than that. - Warren Boudreau [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
  #7   Spotlight this post!  
Unread 08-09-2013, 16:30
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Controlling the individual speed of mecanum wheels within the main programme

Thank you!! Since we just finished the chassis, we're trying to get it working using the library code... and there have been some complications. We can rotate flawlessly, and we can drive in a more-or-less straight line (probably due to our ancient 2 axis joystick with no deadzone). The problem we're having is that we can't strafe (and the x axis, y axis, and rotation are all mixed up). When we try to strafe, the robot simply spins the wheels towards or away from the central point of the robot (i.e the front two wheels spin inwards and the back two wheels spin inwards xor vice versa) and it stays in place or runs in circles. The rollers are arranged in an "X" pattern when viewed from the top. Here's the code we're using, in case it's related to that...
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{	
	Joystick *Saitek;
	Talon *frontLeft;
	Talon *frontRight;
	Talon *backLeft;
	Talon *backRight;
	RobotDrive *myRobot;
public:
	DefaultRobot(void)
	{	//these must be called in the same order as initialized
		Saitek     = new Joystick(1);
		frontLeft  = new Talon(2,1);
		backLeft   = new Talon(2,2);
		frontRight = new Talon(2,3);		
		backRight  = new Talon(2,4);
		myRobot = new RobotDrive(frontLeft,  backLeft,
				                 frontRight, backRight);
	}
	void Autonomous(void)
	{
		while(IsAutonomous())
		{
		}				
	}
	void OperatorControl(void)
	{
		float tval, sval; 
		while (IsOperatorControl())
		{	
			float xVal = Saitek->GetRawAxis(1);
			float yVal = Saitek->GetRawAxis(2);
			bool trigButton  = Saitek->GetRawButton(1);
			bool leftButton  = Saitek->GetRawButton(2);
			bool midlButton  = Saitek->GetRawButton(3);
			bool rightButton = Saitek->GetRawButton(4);
			myRobot->MecanumDrive_Cartesian(sval*0.5, tval*0.25, -yVal*0.25, 0.0);
			
			if      (leftButton  && !rightButton){ tval = -1; }
			else if (rightButton && !leftButton) { tval =  1; }
			else if (leftButton  && rightButton) { tval =  0; }
			else tval = 0;
					
			if      (midlButton  && !trigButton) { sval = -1; }
			else if (trigButton  && !midlButton) { sval =  1; }
			else if (trigButton  && midlButton)  { sval =  0; }
			else sval = 0;
			//backRight->Set(0.25);
			//backLeft->Set(0.25);
			//frontRight->Set(0.25);
			//frontLeft->Set(0.25);
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
Thanks!

[edit] Also, if we tell an individual motor to do something (i.e just sending a value to a single motor controller), the other motors move and twitch... I have no idea how to fix this

Last edited by ekapalka : 08-09-2013 at 16:51.
 


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

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