当前位置: 首页>>代码示例>>C++>>正文


C++ Joystick::GetTrigger方法代码示例

本文整理汇总了C++中Joystick::GetTrigger方法的典型用法代码示例。如果您正苦于以下问题:C++ Joystick::GetTrigger方法的具体用法?C++ Joystick::GetTrigger怎么用?C++ Joystick::GetTrigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joystick的用法示例。


在下文中一共展示了Joystick::GetTrigger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TeleopPeriodic

	void TeleopPeriodic()
	{
		//printf("I done it\n");
		//put the values of both the solenoids on SmartDashboard
		SmartDashboard::PutBoolean("Solenoid One", singOne->GetState());
		SmartDashboard::PutBoolean("Solenoid Two", singTwo->GetState());

		// Piston One goes out when any of the top buttons are pressed
        if (GetTopButtons() == true)
        {
        	singOne->OverrideEnable();
        	printf("Piston One Out\n");
        }
        // if none of the top buttons are pressed then Piston One comes in
        else if(GetTopButtons() == false)
        {
        	singOne->OverrideDisable();
        }
        // Piston Two goes out if Piston One is out and the trigger is pulled
        if (stick->GetTrigger() == true && GetTopButtons()==true)
            {
            		 singTwo->OverrideEnable();
            		 printf("Piston Two Out\n");
             }
        //If the trigger is not pulled or none of the top buttons are pushed Piston Two comes in
        else if (stick->GetTrigger() == false || GetTopButtons()== false)
        {
        	singTwo->OverrideDisable();
        }

	}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:31,代码来源:Robot.cpp

示例2: GetTrigger

/**
 * Read the state of the trigger on the joystick.
 *
 * Look up which button has been assigned to the trigger and read its state.
 *
 * @param port The USB port for this joystick.
 * @param hand This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.
 * @return The state of the trigger.
 */
bool GetTrigger(UINT32 port, JoystickHand hand)
{
    Joystick *stick = getJoystick(port);
    if (stick == NULL)
        return 0;
    return stick->GetTrigger((Joystick::JoystickHand) hand);
}
开发者ID:FRC980,项目名称:FRC-Team-980,代码行数:16,代码来源:CJoystick.cpp

示例3: SetJoystick

/**
 * @brief Sets a cached joystick value.
 * @param joy_id Which joystick to set the cached value for.
 * @param stick A Joystick object with the X, Y, and Z axes set, as well as each of the buttons.
 */
void Proxy::SetJoystick(int joy_id, Joystick & stick)
{
	wpi_assert(joy_id < NUMBER_OF_JOYSTICKS+1 && joy_id >= 0);
	char tmp[32];
	sprintf(tmp, "Joy%d", joy_id);
	string name = tmp;
	if(!disableAxes[joy_id-1]) {
		set(name + 'X', stick.GetX());
		set(name + 'Y', stick.GetY());
		set(name + 'Z', stick.GetZ());
		set(name + 'R', stick.GetTwist());
		set(name + 'T', stick.GetThrottle());
		for(int AxisId=1; AxisId<=6; AxisId++) {
			sprintf(tmp, "%sA%d", name.c_str(), AxisId);
			set(tmp, stick.GetRawAxis(AxisId));
		}
	} else {
		if(!stick.GetRawButton(disableAxes[joy_id-1])) {
			set(name + 'X', stick.GetX());
			set(name + 'Y', stick.GetY());
			set(name + 'Z', stick.GetZ());
			set(name + 'R', stick.GetTwist());
			set(name + 'T', stick.GetThrottle());
			for(int AxisId=1; AxisId<=6; AxisId++) {
				sprintf(tmp, "%sA%d", name.c_str(), AxisId);
				set(tmp, stick.GetRawAxis(AxisId));
			}
		}
	}
	
	if(!disableButtons[joy_id-1]) {
		for(unsigned i=1;i<=NUMBER_OF_JOY_BUTTONS;i++) {
			sprintf(tmp, "%sB%d", name.c_str(), i);
			set(tmp,stick.GetRawButton(i));
		}
		set(name + "BT", stick.GetTrigger());
	} else {
		if(!stick.GetRawButton(disableButtons[joy_id-1])) {
			for(unsigned i=1;i<=NUMBER_OF_JOY_BUTTONS;i++) {
				sprintf(tmp, "%sB%d", name.c_str(), i);
				set(tmp,stick.GetRawButton(i));
			}
			set(name + "BT", stick.GetTrigger());
		}
	}
}
开发者ID:chopshop-166,项目名称:framework166,代码行数:51,代码来源:Proxy.cpp

示例4: OperatorControl

	void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		printf("Entered OperatorControl\n");
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			
			// use the trigger to start recording.. at the moment,
			// it just gets ignored if you call it more than once
			if (stick.GetTrigger())
				recorder.StartRecording();
	
			myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			
			// always call the recording routine
			recorder.Record();
		}
	}
开发者ID:frc2423,项目名称:2008-2012,代码行数:19,代码来源:MyRobot.cpp

示例5: TeleopPeriodic

	void TeleopPeriodic(void) {
		// increment the number of teleop periodic loops completed
		GetWatchdog().Feed();
		m_telePeriodicLoops++;

		/*
		 * No longer needed since periodic loops are now synchronized with incoming packets.
		if (m_ds->GetPacketNumber() != m_priorPacketNumber) {
		*/
			/* 
			 * Code placed in here will be called only when a new packet of information
			 * has been received by the Driver Station.  Any code which needs new information
			 * from the DS should go in here
			 */
			 
			m_dsPacketsReceivedInCurrentSecond++;					// increment DS packets received
						
			// put Driver Station-dependent code here

			// Demonstrate the use of the Joystick buttons
//			DemonstrateJoystickButtons(m_rightStick, m_rightStickButtonState, "Right Stick", &m_solenoids[1]);
//			DemonstrateJoystickButtons(m_leftStick, m_leftStickButtonState, "Left Stick ", &m_solenoids[5]);
		/***
			// determine if tank or arcade mode, based upon position of "Z" wheel on kit joystick
			if (m_rightStick->GetZ() <= 0) {    // Logitech Attack3 has z-polarity reversed; up is negative
				// use arcade drive
				m_robotDrive->ArcadeDrive(m_rightStick);			// drive with arcade style (use right stick)
				if (m_driveMode != ARCADE_DRIVE) {
					// if newly entered arcade drive, print out a message
					printf("Arcade Drive\n");
					m_driveMode = ARCADE_DRIVE;
				}
			} else {
				// use tank drive
				m_robotDrive->TankDrive(m_leftStick, m_rightStick);	// drive with tank style
				if (m_driveMode != TANK_DRIVE) {
					// if newly entered tank drive, print out a message
					printf("Tank Drive\n");
					m_driveMode = TANK_DRIVE;
				}
			}
***/
			
		/* Grab z-wheel value and transform from [1, -1] to [0,4600] 
		 * 4600 rpm is a guess */ 
		float rawZ, transformedZ;
		rawZ = m_leftStick->GetZ();
//		transformedZ = (1.0 - rawZ)/(-2.0);
		transformedZ = -2300.0 * rawZ + 2300.0;
		
		/* Driver station display output. */
		char msg[256];
static	DriverStationLCD *dsLCD = DriverStationLCD::GetInstance();
		sprintf(msg, "Launcher Speed = %f RPM", transformedZ);
		dsLCD->Printf(DriverStationLCD::kUser_Line1, 1, msg);
		sprintf(msg, "Loader Limit = %u", m_loaderLimit->Get());
		dsLCD->Printf(DriverStationLCD::kUser_Line2, 1, msg);
		sprintf(msg, "Loader Trigger = %u", m_leftStick->GetTrigger());
		dsLCD->Printf(DriverStationLCD::kUser_Line3, 1, msg);
					// line number (enum), starting col, format string, args for format string ...
		dsLCD->UpdateLCD();
		
		// use arcade drive
		//m_driveGain = (1.0 - m_rightStick->GetZ())/(-2.0);
		m_robot->ArcadeDrive(m_rightStick);			// drive with arcade style (use right stick)
//		m_robotFrontDrive->Drive(-m_driveGain*m_rightStick->GetY(),-m_driveGain*m_rightStick->GetX());	// negative sign to fix bug in turn
//		m_robotRearDrive->Drive(m_driveGain*m_rightStick->GetY(),-m_driveGain*m_rightStick->GetX());	// negative sign to fix bug in turn
		
		// -Add an elevation control, add a motor controller to port 8, and add a joystick button pair to control up/down
		if (m_rightStick->GetRawButton(m_elevatorUpButton)){
			m_elevatorMotor->Set(m_elevatorUpSpeed);
		}
		else if (m_rightStick->GetRawButton(m_elevatorDownButton)){
			m_elevatorMotor->Set(m_elevatorDownSpeed);
		}
		else {
			m_elevatorMotor->Set(0.0);
		}
		// trigger button activates feeding and loading mechanisms
		if ((m_leftStick->GetTop() || m_feeding) && (!m_loading) && (m_feedCounter <= m_feedCount)){
			m_feeding = true;
			m_feedCounter++;  
			m_feedMotor->Set(m_feedSpeed);
		}
		else {
			m_feeding = false;
			m_feedCounter = 0;
			m_feedMotor->Set(0.);
			}
		m_loaderLimit->Get(); //just testing digital input port 1
		
		// top(2) button uses the Z wheel to control the speed of the loading mechanisms
		if (((m_leftStick->GetTrigger() || m_loading) && (!m_feeding)) && (m_loadCounter <= m_loadCount)){//comment out this line
//		if (((m_leftStick->GetTrigger() || m_loading) && (!m_feeding)) && (bool) m_loaderLimit->Get()){  //uncomment this line
			m_loading = true;
			m_loadCounter++; // comment out this line
			m_loadMotor->Set(m_loadSpeed);	// load breech
			} 
		else if ((m_loading && (!m_feeding)) && (m_loadCounter > m_loadCount) && (m_loadCounter <= ((m_loadCount+m_loadPauseCount)))) { // comment out the pause logic
			m_loading = true;// comment out the pause logic
//.........这里部分代码省略.........
开发者ID:team4243,项目名称:ua,代码行数:101,代码来源:BuiltinDefaultCode.cpp

示例6: OperatorControl


//.........这里部分代码省略.........
				SmartDashboard::PutBoolean("Reverse",true);
				GetWatchdog().Feed();
			}
			myRobot.ArcadeDrive(fltStick1Y,fltStick1X);
			//myRobot.ArcadeDrive(stick1);
			GetWatchdog().Feed(); // Feed hungary demonic Watchdog.


			SmartDashboard::PutBoolean("Touching Tower?",LimitSwitch->Get());
			SmartDashboard::PutNumber("Throttle (%)",stick1->GetY()*(-100));
			SmartDashboard::PutNumber("Steering (%)",stick1->GetX()*(100));

			GetWatchdog().Feed();
			//End Stick1 arcade drive code.

			GetWatchdog().Feed();

			fltShoot = (((-(stick2->GetRawAxis(3)))+1)/2);

			GetWatchdog().Feed();

			SmartDashboard::PutNumber("Shooter Power (%)", fltShoot);
			SmartDashboard::PutNumber("Shooter Set Speed (%)", (fltSpeed*100));



			//float fltPressureSwitch = m_pressureSwitch;
			//float fltRelay = m_relay;
			//SmartDashboard::PutNumber("Demo",3);

			GetWatchdog().Feed();
			if(timerShift.Get() > 0.2)
			{
				if(stick1->GetRawButton(7) || stick1->GetTrigger())
				{
					if(blnShift == false)
					{
						GetWatchdog().Feed();
						s[0]->Set(false);
						s[1]->Set(true);
						SmartDashboard::PutString("Gear","Low");
						blnShift = true;
						timerShift.Stop();
						timerShift.Reset();
						timerShift.Start();
						GetWatchdog().Feed();
					}	
					else if (blnShift == true)
					{
						GetWatchdog().Feed();
						s[0]->Set(true);
						s[1]->Set(false);
						SmartDashboard::PutString("Gear","High");
						blnShift = false;
						timerShift.Stop();
						timerShift.Reset();
						timerShift.Start();
						GetWatchdog().Feed();
					}
				}		
			}
			if(stick1->GetRawButton(2) && blnLowHang == false && timerLowHang.Get() > 0.5)
			{
				blnLowTime = true;
				blnLowHang = true;
				timerLowHang.Stop();
开发者ID:highlandprogramming,项目名称:WIP-2014-Code-FRC,代码行数:67,代码来源:MyRobot.cpp


注:本文中的Joystick::GetTrigger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。