View Single Post
  #14   Spotlight this post!  
Unread 23-01-2011, 20:17
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: Button programin C++

You just need to replace the motor.set() with myRobot.Drive().

Here is your code with the replacements made. It compiles.


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()){
				myRobot.Drive(1.0,0.0);
			}
		else{
			myRobot.Drive(0.5,1.0);
		}
			robocam.GetImage();
			image.GetImaqImage();
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote