Go to Post Someone wake me up the day of Kickoff. - Andrew Schreiber [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2010, 02:44
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Motor Code Help

Hi, I would like to do something like:

Joystick1yaxis = Motor[1];
Joystick1yaxis = Motor[2];
Joystick2yaxis = Motor[3];
Joystick2yaxis = Motor[4];


how would I go about this?
Thanks
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2010, 10:22
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Motor Code Help

have you read http://first.wpi.edu/Images/CMS/Firs...artedWithC.pdf and http://first.wpi.edu/Images/CMS/Firs...sers_Guide.pdf?
I would assume you want something more like this:
Code:
robotDrive.TankDrive(stick1,stick2);
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #3   Spotlight this post!  
Unread 14-02-2010, 13:56
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Re: Motor Code Help

But I need two joysticks running 4 motors, 2 motors to each joystick.
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 14-02-2010, 14:46
buddyb's Avatar
buddyb buddyb is offline
Registered User
FRC #1885 (ILITE)
Team Role: Programmer
 
Join Date: Dec 2009
Rookie Year: 2008
Location: Haymarket, VA
Posts: 65
buddyb has a spectacular aura aboutbuddyb has a spectacular aura aboutbuddyb has a spectacular aura about
Re: Motor Code Help

Quote:
Originally Posted by odel View Post
But I need two joysticks running 4 motors, 2 motors to each joystick.
Like ByteIt said, you'll want to do robotDrive.TankDrive(leftJoystick, rightJoystick);

But, the constructor you'll want to use is:
Code:
RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor, float sensitivity=0.5)
This will give you tank drive for 4 motors from two joysticks.

Good luck!
__________________
FRC - Team 1885 - Programmer.

Last edited by buddyb : 14-02-2010 at 14:49.
Reply With Quote
  #5   Spotlight this post!  
Unread 14-02-2010, 14:55
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Re: Motor Code Help

So now I have:
Code:
class RobotDemo : public SimpleRobot
{
	Jaguar frontLeftMotor(1);
	RobotDrive drivetrain(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor, float sensitivity=0.5)
	Joystick stick; // only joystick

public:
	RobotDemo(void):
		myRobot(1, 2),	// these must be initialized in the same order
		stick(1)		// as they are declared above.
	{
		GetWatchdog().SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);
		drivetrain.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		drivetrain.Drive(0.0, 0.0); 	// stop robot
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			robotDrive.TankDrive(stick1,stick2);
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
I need help declaring the Jaguars now
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 14-02-2010, 15:18
buddyb's Avatar
buddyb buddyb is offline
Registered User
FRC #1885 (ILITE)
Team Role: Programmer
 
Join Date: Dec 2009
Rookie Year: 2008
Location: Haymarket, VA
Posts: 65
buddyb has a spectacular aura aboutbuddyb has a spectacular aura aboutbuddyb has a spectacular aura about
Re: Motor Code Help

Quote:
Originally Posted by odel View Post
So now I have:
<CODE>
I need help declaring the Jaguars now
This *should* work. Change the values under RobotDemo(void): to change the slots.
Code:
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
	RobotDrive robotDrive;
	Joystick stick1, stick2;

public:
	RobotDemo(void):
		robotDrive(1,				//Front Left motor port
				2,	//Back left motor port
				3,	//Front right motor port
				4),	//Back right motor port
		stick1(1),		//Joystick 1 in slot 1
		stick2(2)		//Joystick 2 in slot 2
	{
		GetWatchdog().SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);
		robotDrive.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 						//    for 2 seconds
		robotDrive.Drive(0.0, 0.0); 	// stop robot
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			robotDrive.TankDrive(stick1,stick2);
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
If it works, yay! If not, play around with the ports, and make sure everything's wired correctly. If all of that is correct, I probably did something stupid. XD
__________________
FRC - Team 1885 - Programmer.
Reply With Quote
  #7   Spotlight this post!  
Unread 14-02-2010, 18:04
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Re: Motor Code Help

So this is what I have right now, we plugged the left motors into pwm 1 and the right ones into pwm 2 using pwm splitter, and still no luck

Code:
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
	RobotDrive robotDrive;
	Joystick stick1, stick2;

public:
	RobotDemo(void):
		robotDrive(1,2),	
		stick1(1),		//Joystick 1 in slot 1
		stick2(2)		//Joystick 2 in slot 2
	{
		GetWatchdog().SetExpiration(0.1);
	}

	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);
		robotDrive.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 						//    for 2 seconds
		robotDrive.Drive(0.0, 0.0); 	// stop robot
	}

	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			robotDrive.TankDrive(stick1,stick2);
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
__________________
Reply With Quote
  #8   Spotlight this post!  
Unread 14-02-2010, 18:22
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Motor Code Help

are the joysticks configured correctly on the driverstation?
go to setup tab, and on the right side, drag the joysticks to 1 and 2
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #9   Spotlight this post!  
Unread 14-02-2010, 18:24
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Re: Motor Code Help

Got things working now, thanks for all the help guys!
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 16-02-2010, 20:31
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Motor Code Help

might i suggest using an ancient technology of split PWM's the go from one port to 2 jaguars or victors. they are extremely helpful.
Reply With Quote
  #11   Spotlight this post!  
Unread 19-02-2010, 13:23
odel's Avatar
odel odel is offline
Registered User
FRC #2990 (Hotwire Robotics)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Oregon
Posts: 8
odel is an unknown quantity at this point
Send a message via Yahoo to odel
Re: Motor Code Help

Quote:
Originally Posted by whatabouteve View Post
might i suggest using an ancient technology of split PWM's the go from one port to 2 jaguars or victors. they are extremely helpful.
We may or may not have ended up doing this...
__________________
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
4 motor Mecanum wheel code request inventor1254 NI LabVIEW 17 23-02-2010 08:45
ADC code effecting motor outs??? Kyveck Programming 16 28-03-2006 15:12
Adding a motor to code sirbleedsalot Programming 1 27-01-2005 23:02
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 12: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