View Single Post
  #11   Spotlight this post!  
Unread 23-01-2011, 20:00
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Button programin C++

i tried to put in left motor and other stuff

here is the code

Code:
#include "WPILib.h"
#include "Vision/AxisCameraParams.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 leftstick; // only joystick
	Joystick rightstick; // only joystick 
	HSLImage image;

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

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		myRobot.SetSafetyEnabled(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)
	{
		myRobot.SetSafetyEnabled(true);
		AxisCamera &robocam = AxisCamera::GetInstance();
		robocam.WriteResolution((AxisCamera::Resolution_t)3);
		robocam.WriteBrightness(0);
		Wait(3.0);
		
		while (IsOperatorControl())
		{
			myRobot.MecanumDrive_Cartesian(leftstick.GetX(), leftstick.GetY(), rightstick.GetY(), 0); //Mecanum drice, float x,float y, float rotation, gyro
			bool GetTrigger(Joystick hand = leftstick);
			if (!leftstick.GetTrigger()){
				motors.Set(x));
			}
		else{
			motors.Set(x/2);
		}
			robocam.GetImage();
			image.GetImaqImage();
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);

Thanks for the help sorry to be a bothersum and ask so many question this is my first time using c++
Reply With Quote