Thread: windriver c++?
View Single Post
  #3   Spotlight this post!  
Unread 06-01-2010, 06:11
yara92's Avatar
yara92 yara92 is offline
M.Fawdah Mechanical engineering
AKA: Mohamed
FRC #1946 (Mechka Monster)
Team Role: RoboCoach
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Israel
Posts: 236
yara92 will become famous soon enoughyara92 will become famous soon enough
Re: windriver c++?

hello Eric

Thank you for your help we were able to insert the code you sent us into RobotDemo however we are not sure if the mecanum wheels are fully doing all the right moves (it works fine in all direction except to the sides) we think that it could be a problem with not having a gray area specified ?!!!
Let us know what you think!!
the code,
Code:
#include "WPILib.h"

/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */ 
class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick; // only joystick 
	{
	public:
		typedef enum
		{
			kFrontLeftMotor = 0,
			kFrontRightMotor = 1,
			kRearLeftMotor = 2,
			kRearRightMotor = 3
		} MotorType;
public:
	RobotDemo(void):
		myRobot(1, 2, 3, 4),	// 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);
		myRobot.Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		myRobot.Drive(0.0, 0.0); 	// stop robot
	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			Wait(0.005);				// wait for a motor update time
		}
		//INSERT IN: TeleopPeriodic or main loop
		float X = m_leftStick->GetZ();
		float Y = m_leftStick->GetY();
		float Z = m_leftStick->GetX();
					
		Y *= -1;
		X *= -1;
		float FrontLeft = Y + X + Z;
		float FrontRight = Y - X - Z;
		float RearLeft = Y - X + Z;
		float RearRight = Y + X - Z;
					
		FrontRight *= -1;
		KFrontLeftMotor->Set(FrontLeft);
		KFrontRightMotor->Set(FrontRight);
		KRearLeftMotor->Set(RearLeft);
		KRearRigtMotor->Set(RearRigt);
	}
};

START_ROBOT_CLASS(RobotDemo);

ps open the attachment
Thank you again
from
1946 programming team
Attached Thumbnails
Click image for larger version

Name:	mecanum11.gif
Views:	44
Size:	70.4 KB
ID:	8234  
__________________
TEAM 1946-Tamra
Reply With Quote