本文整理汇总了C++中Joystick::GetRawAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ Joystick::GetRawAxis方法的具体用法?C++ Joystick::GetRawAxis怎么用?C++ Joystick::GetRawAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joystick
的用法示例。
在下文中一共展示了Joystick::GetRawAxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TeleopPeriodic
void TeleopPeriodic() {
if(m_driver->GetRawButton(BUTTON_LB)) {
// PYRAMID
m_PIDController->SetSetpoint(PLATE_PYRAMID_THREE_POINT);
m_PIDController->Enable();
} else if(m_driver->GetRawButton(BUTTON_RB)) {
// FEEDER
m_PIDController->SetSetpoint(PLATE_FEEDER_THREE_POINT);
m_PIDController->Enable();
} else if(m_driver->GetRawAxis(TRIGGERS) > 0.5) {
m_PIDController->SetSetpoint(PLATE_TEN_POINT_CLIMB);
m_PIDController->Enable();
} else {
// MANUAL CONTROL
m_PIDController->Disable();
m_plate1->Set(-deadband(m_driver->GetRawAxis(LEFT_Y)));
m_plate2->Set(-deadband(m_driver->GetRawAxis(LEFT_Y)));
}
// ----- PRINT -----
SmartDashboard::PutNumber("Plate Position: ", m_plateSensor->GetVoltage());
SmartDashboard::PutNumber("PID GET: ", m_plateSensor->PIDGet());
} // TeleopPeriodic()
示例2: TeleopPeriodic
void TeleopPeriodic()
{
myRobot.ArcadeDrive(-gPad.GetRawAxis(GP_RSTICK_YAXIS)*ROBOT_START_SPEED, -gPad.GetRawAxis(GP_RSTICK_XAXIS)*ROBOT_START_SPEED ); // drive with arcade style (use right stick)
if(gPad.GetRawButton(GP_Y_BUTTON) == true && yButton == false)
{
if(driveSpeed + 0.25 < 1 && driveSpeed - 0.25 > 0)
{
yButton = true;
driveSpeed = driveSpeed + 0.25;
}
else
{
yButton = false;
}
}
if(gPad.GetRawButton(GP_A_BUTTON) == true && aButton == false)
{
if(driveSpeed + 0.25 < 1 && driveSpeed - 0.25 > 0)
{
aButton = true;
driveSpeed = driveSpeed + 0.25;
}
else
{
aButton = false;
}
}
}
示例3: Execute
void ArcadeDriveWithJoystick::Execute() {
Joystick* stick = CommandBase::oi->GetJoystick();
float moveValue = stick->GetRawAxis(1);
float rotateValue = stick->GetRawAxis(4);
CommandBase::drivetrain->Drive(moveValue, rotateValue);
CommandBase::drivetrain->Log();
}
示例4: OperatorControl
/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
while (IsOperatorControl())
{
left.Set(cont.GetRawAxis(2));
right.Set(cont.GetRawAxis(4));
}
}
示例5: TeleopPeriodic
//void StartAutomaticCapture(std::shared_ptr<USBCamera>cam0);
void TeleopPeriodic() {
// ui.GetData(&wui);
// m_tank.Drive(wui.LeftSpeed, wui.RightSpeed);
//
// m_shooter.Rotate(wui.RotateSpeed*3); //70 degrees per second at full value
// m_shooter.Lift(wui.LiftSpeed*1.193); //4 seconds for 180 degree revolution
// if(wui.SpinUp) {
// m_shooter.Spinup(1);
// }
// if(wui.Shoot) {
// m_shooter.Shoot();
// }
// if(wui.Pickup) {
// m_shooter.Pickup();
// }
//
// m_suspension.SetFrontLeft(wui.DropFL);
// m_suspension.SetBackLeft(wui.DropBL);
// m_suspension.SetFrontRight(wui.DropFR);
// m_suspension.SetBackRight(wui.DropBR);
// m_leddar.GetDetections();
// m_shooter.Update();
//float RTrigger = m_lStick->GetRawAxis(3);
//float LTrigger = m_lStick->GetRawAxis(2);
//if (m_PWMTalonLeftFrontTop == .5)
//if (abs(RTrigger) < 0.2)
//RTrigger = 0;
//if (abs(LTrigger) < 0.2)
//LTrigger = 0;
float leftSpeed = m_lStick->GetRawAxis(1);
float rightSpeed = m_lStick->GetRawAxis(5);
if (abs(leftSpeed) < 0.2)
leftSpeed = 0;
if (abs(rightSpeed) < 0.2)
rightSpeed = 0;
//float LTrigger = m_lStick->GetRawAxis(3);
//float RTrigger = m_lStick->GetRawAxis(2);
SmartDashboard::PutNumber("Left Stick", leftSpeed);
SmartDashboard::PutNumber("Right Stick", rightSpeed);
//SmartDashboard::PutNumber("L Trigger", LTrigger);
//SmartDashboard::PutNumber("R Trigger", RTrigger);
SmartDashboard::PutNumber("Left Encoder", leftEncoder->Get());
SmartDashboard::PutNumber("Right Encoder", rightEncoder->Get());
drive->TankDrive(leftSpeed, rightSpeed, true);
//drive->TankDrive(RTrigger, LTrigger, true);
LEFTDRIVE1->Set(leftSpeed);
LEFTDRIVE2->Set(leftSpeed);
RIGHTDRIVE1->Set(rightSpeed);
RIGHTDRIVE2->Set(rightSpeed);
//m_PWMTalonLeftFrontTop->Set(RTrigger);
//m_PWMTalonRightFrontTop->Set(RTrigger);
//m_PWMTalonRightRearTop->Set(LTrigger);
//m_PWMTalonLeftRearTop->Set(LTrigger);
}
示例6: TeleopContinuous
void TeleopContinuous(void) {
printf("Running in teleop continuous...\n");
GetWatchdog().Feed();
//Drive the robot
drivetrain->ArcadeDrive(driverJoystick->GetRawAxis(2) * -1,driverJoystick->GetRawAxis(4) * -1);
//Run the kicker
kicker->Act();
}
示例7: OperatorControl
void OperatorControl(void) {
while(!IsDisabled()) {
GetWatchdog().Feed();
float speed = stick.GetRawAxis(2);
float strafe = -1*stick.GetRawAxis(1);
float turn = -1*stick.GetRawAxis(3);
Dlf->Set(speed + turn + strafe);
Dlb->Set(speed + turn - strafe);
Drf->Set(-speed + turn + strafe);
Drb->Set(-speed + turn - strafe);
Wait(.05);
}
}
示例8: move
void Intake::move (const Joystick& joystick) {
float left = joystick.GetRawAxis (OI::kIntakeTake);
float right = joystick.GetRawAxis (OI::kIntakeGive);
if (left > right)
move (left);
else if (right > left)
move (right * -1);
else
move (0);
}
示例9: TeleopPeriodic
virtual void TeleopPeriodic() {
rightDrive->SetSpeed(-(Driver->GetRawAxis(2)));
leftDrive->SetSpeed((Driver->GetRawAxis(5)));
shooterFWD->SetSpeed(-(Operator->GetRawAxis(2)));
shooterRear->SetSpeed(-(Operator->GetRawAxis(2)));
//shoioter angle
if(Operator->GetRawButton(5))
{
cout<<"Relay 1 forward"<<endl;
shooterAngle->Set(Relay::kForward);
}
if(Operator->GetRawButton(6))
{
cout<<"Relay 1 Reverse"<<endl;
shooterAngle->Set(Relay::kReverse);
}
//Fire button
if(Operator->GetRawButton(1))
{
cout<<"Relay 1 forward"<<endl;
shooterFire->Set(Relay::kForward);
}
if(Operator->GetRawButton(2))
{
cout<<"Relay 1 Reverse"<<endl;
shooterFire->Set(Relay::kReverse);
}
if(CompressorSwitch->Get() == 0){
CompressorRelay->Set(Relay::kForward);
}else{
CompressorRelay->Set(Relay::kOff);
}
//if(canPDP == 0){
// cout << "NULL" << endl;
//}else{
//canPDP->GetVoltage(Voltage) ;
//cout << "0" << endl;
//}
}
示例10: getStickValues
/* gets stick values into the x y and z values, these values are not returned by this but rather stored into the respective variables, the values are filtered*/
void RawControl::getStickValues(float &x, float &y, float &z) {
x=(fabs(stick->GetRawAxis(1))<.3 ? 0 : stick->GetRawAxis(1));
y=(fabs(stick->GetRawAxis(2))<.3 ? 0 : stick->GetRawAxis(2));
z=(fabs(stick->GetRawAxis(3))<.3 ? 0 : stick->GetRawAxis(3));
x=x*x*x*x*x*x*x;
y=y*y*y*y*y*y*y;
z*=.9;
z=z*z*z;
//y*=.9;
//stick->GetRawButton(2) ? z=0 : z=z;
//theres a lot more filtering of axes after this....but with comments on top of comments i dont remember what actually worked. Any other
//manipulation of joystick input for x-y-z axes goes here.
}
示例11: Print
void Print ()
{
if (PrintTime.Get() > PRINT_TIME)
{
lcd->Clear();
lcd->Printf(DriverStationLCD::kUser_Line1, 1, "Left Speed = %5.4f", PrimaryController.GetRawAxis(LEFT_JOYSTICK));
lcd->Printf(DriverStationLCD::kUser_Line2, 1, "Right Speed = %5.4f", PrimaryController.GetRawAxis(RIGHT_JOYSTICK));
lcd->Printf(DriverStationLCD::kUser_Line3, 1, "Charge State = %d", (int)Shooter.chargestate);
//lcd->Printf(DriverStationLCD::kUser_Line4, 1, "Collector speed= %d", Collector.CollectorSpeed());
lcd->UpdateLCD();
PrintTime.Reset();
PrintTime.Start();
}
}
示例12: OperatorControl
/**
* Runs the motors with arcade steering.
*/
void OperatorControl()
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled())
{
leftIntake.Set(0.8);
rightIntake.Set(0.8);
leftLift.Set(operatorStick.GetRawAxis(1));
rightLift.Set(operatorStick.GetRawAxis(1));
myRobot.TankDrive(driverStick.GetRawAxis(5), driverStick.GetRawAxis(1), true); // drive with arcade style (use right stick)
Wait(0.005); // wait for a motor update time
}
}
示例13: DriveControl
void DriveControl() { //Drives la wheels of the robot
flightX = flightStick->GetRawAxis(0); //Pull joystick side motion for later use
flightY = flightStick->GetRawAxis(1); //Pull joystick forward motion for later use (forward is -, backwards is +)
flightZ = flightStick->GetRawAxis(4); //Pull joystick twist motion for later use
flightThrottle = ((((shootStick->GetThrottle() - 1)*-1)/2) * .8 + .2); //Pull throttle to modify drive variables
//Throttle value is between .2 and 1.0
if (fabs(flightX) < deadZone) { //Deaden x
flightX = 0;
}
if (fabs(flightY) < deadZone) { //Deaden y
flightY = 0;
}
if (fabs(flightZ) < deadZone) { //Deaden z
flightZ = 0;
}
if (flightStick->GetRawButton(strafeButtonChannel)){ //Set drive to strafe mode
driveMode = 0;
}
if (flightStick->GetRawButton(arcadeButtonChannel)){ //Set drive to arcade mode
driveMode = 1;
}
if (flightStick->GetRawButton(fieldButtonChannel)){ //Set drive to field-centric mode
driveMode = 2;
}
if (shootStick->GetRawButton(gyroResetChannel)){ //Reset gyro with the trigger
yawGyro->Reset();
}
flightX = flightX * flightThrottle;
flightY = flightY * flightThrottle;
flightZ = flightZ * flightThrottle;
if(driveMode == 1){
robotDrive->MecanumDrive_Cartesian(flightZ, flightY, flightX, 0);
SmartDashboard::PutString("DriveMode", "Arcade");
}
else if(driveMode == 2){
robotDrive->MecanumDrive_Cartesian(flightX, flightY, flightZ, yawGyro->GetAngle());
SmartDashboard::PutString("DriveMode", "Field");
}
else{
robotDrive->MecanumDrive_Cartesian(flightX, flightY, flightZ, 0);
SmartDashboard::PutString("DriveMode", "Strafe");
}
SmartDashboard::PutNumber("GyroAngle", yawGyro->GetAngle());
}
示例14: GetRawAxis
/**
* Get the value of the axis.
*
* @param port The USB port for this joystick.
* @param axis The axis to read [1-6].
* @return The value of the axis.
*/
float GetRawAxis(UINT32 port, UINT32 axis)
{
Joystick *stick = getJoystick(port);
if (stick == NULL)
return 0;
return stick->GetRawAxis(axis);
}
示例15: OperatorControl
void OperatorControl(void)
{
OperatorControlInit();
compressor.Start();
testActuator.Start();
while (IsOperatorControl())
{
ProgramIsAlive();
//No need to do waits because ProgramIsAlive function does a wait. //Wait(0.005);
bool isButtonPressed = stick.GetRawButton(3);
SmartDashboard::PutNumber("Actuator Button Status",isButtonPressed);
if (isButtonPressed)
{
testActuator.Go();
}
float leftYaxis = stick.GetY();
float rightYaxis = stick.GetRawAxis(5); //RawAxis(5);
TankDrive(leftYaxis,rightYaxis); // drive with arcade style (use right stick)for joystick 1
SmartDashboard::PutNumber("Left Axis",leftYaxis);
SmartDashboard::PutNumber("Right Axis",rightYaxis);
}
}