mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Rename GearsBotNew example to GearsBot
This commit is contained in:
committed by
Peter Johnson
parent
c9f9feff1f
commit
2250b7fbe3
@@ -0,0 +1,26 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
#include "subsystems/DriveTrain.h"
|
||||
#include "subsystems/Elevator.h"
|
||||
#include "subsystems/Wrist.h"
|
||||
|
||||
/**
|
||||
* The main autonomous command to pickup and deliver the soda to the box.
|
||||
*/
|
||||
class Autonomous
|
||||
: public frc2::CommandHelper<frc2::SequentialCommandGroup, Autonomous> {
|
||||
public:
|
||||
Autonomous(Claw* claw, Wrist* wrist, Elevator* elevator,
|
||||
DriveTrain* drivetrain);
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
|
||||
/**
|
||||
* Opens the claw for one second. Real robots should use sensors, stalling
|
||||
* motors is BAD!
|
||||
*/
|
||||
class CloseClaw : public frc2::CommandHelper<frc2::CommandBase, CloseClaw> {
|
||||
public:
|
||||
explicit CloseClaw(Claw* claw);
|
||||
void Initialize() override;
|
||||
bool IsFinished() override;
|
||||
void End(bool interrupted) override;
|
||||
|
||||
private:
|
||||
Claw* m_claw;
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/PIDCommand.h>
|
||||
|
||||
#include "subsystems/DriveTrain.h"
|
||||
|
||||
/**
|
||||
* Drive the given distance straight (negative values go backwards).
|
||||
* Uses a local PID controller to run a simple PID loop that is only
|
||||
* enabled while this command is running. The input is the averaged
|
||||
* values of the left and right encoders.
|
||||
*/
|
||||
class DriveStraight
|
||||
: public frc2::CommandHelper<frc2::PIDCommand, DriveStraight> {
|
||||
public:
|
||||
explicit DriveStraight(double distance, DriveTrain* drivetrain);
|
||||
void Initialize() override;
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
DriveTrain* m_drivetrain;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/WaitCommand.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
|
||||
/**
|
||||
* Opens the claw for one second. Real robots should use sensors, stalling
|
||||
* motors is BAD!
|
||||
*/
|
||||
class OpenClaw : public frc2::CommandHelper<frc2::WaitCommand, OpenClaw> {
|
||||
public:
|
||||
explicit OpenClaw(Claw* claw);
|
||||
void Initialize() override;
|
||||
void End(bool interrupted) override;
|
||||
|
||||
private:
|
||||
Claw* m_claw;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
#include "subsystems/Elevator.h"
|
||||
#include "subsystems/Wrist.h"
|
||||
|
||||
/**
|
||||
* Pickup a soda can (if one is between the open claws) and
|
||||
* get it in a safe state to drive around.
|
||||
*/
|
||||
class Pickup
|
||||
: public frc2::CommandHelper<frc2::SequentialCommandGroup, Pickup> {
|
||||
public:
|
||||
Pickup(Claw* claw, Wrist* wrist, Elevator* elevator);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
#include "subsystems/Elevator.h"
|
||||
#include "subsystems/Wrist.h"
|
||||
|
||||
/**
|
||||
* Place a held soda can onto the platform.
|
||||
*/
|
||||
class Place : public frc2::CommandHelper<frc2::SequentialCommandGroup, Place> {
|
||||
public:
|
||||
Place(Claw* claw, Wrist* wrist, Elevator* elevator);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
|
||||
#include "subsystems/Claw.h"
|
||||
#include "subsystems/Elevator.h"
|
||||
#include "subsystems/Wrist.h"
|
||||
|
||||
/**
|
||||
* Make sure the robot is in a state to pickup soda cans.
|
||||
*/
|
||||
class PrepareToPickup : public frc2::CommandHelper<frc2::SequentialCommandGroup,
|
||||
PrepareToPickup> {
|
||||
public:
|
||||
PrepareToPickup(Claw* claw, Wrist* wrist, Elevator* elevator);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/PIDCommand.h>
|
||||
|
||||
#include "subsystems/DriveTrain.h"
|
||||
|
||||
/**
|
||||
* Drive until the robot is the given distance away from the box. Uses a local
|
||||
* PID controller to run a simple PID loop that is only enabled while this
|
||||
* command is running. The input is the averaged values of the left and right
|
||||
* encoders.
|
||||
*/
|
||||
class SetDistanceToBox
|
||||
: public frc2::CommandHelper<frc2::PIDCommand, SetDistanceToBox> {
|
||||
public:
|
||||
explicit SetDistanceToBox(double distance, DriveTrain* drivetrain);
|
||||
void Initialize() override;
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
DriveTrain* m_drivetrain;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/Elevator.h"
|
||||
|
||||
/**
|
||||
* Move the elevator to a given location. This command finishes when it is
|
||||
* within
|
||||
* the tolerance, but leaves the PID loop running to maintain the position.
|
||||
* Other
|
||||
* commands using the elevator should make sure they disable PID!
|
||||
*/
|
||||
class SetElevatorSetpoint
|
||||
: public frc2::CommandHelper<frc2::CommandBase, SetElevatorSetpoint> {
|
||||
public:
|
||||
explicit SetElevatorSetpoint(double setpoint, Elevator* elevator);
|
||||
void Initialize() override;
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
double m_setpoint;
|
||||
Elevator* m_elevator;
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/Wrist.h"
|
||||
|
||||
/**
|
||||
* Move the wrist to a given angle. This command finishes when it is within
|
||||
* the tolerance, but leaves the PID loop running to maintain the position.
|
||||
* Other commands using the wrist should make sure they disable PID!
|
||||
*/
|
||||
class SetWristSetpoint
|
||||
: public frc2::CommandHelper<frc2::CommandBase, SetWristSetpoint> {
|
||||
public:
|
||||
explicit SetWristSetpoint(double setpoint, Wrist* wrist);
|
||||
void Initialize() override;
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
double m_setpoint;
|
||||
Wrist* m_wrist;
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/DriveTrain.h"
|
||||
|
||||
/**
|
||||
* Have the robot drive tank style using the PS3 Joystick until interrupted.
|
||||
*/
|
||||
class TankDrive : public frc2::CommandHelper<frc2::CommandBase, TankDrive> {
|
||||
public:
|
||||
TankDrive(DriveTrain* drivetrain, std::function<double()> left,
|
||||
std::function<double()> right);
|
||||
void Execute() override;
|
||||
bool IsFinished() override;
|
||||
void End(bool interrupted) override;
|
||||
|
||||
private:
|
||||
DriveTrain* m_drivetrain;
|
||||
std::function<double()> m_left;
|
||||
std::function<double()> m_right;
|
||||
};
|
||||
Reference in New Issue
Block a user