2
0
mirror of https://github.com/team2059/Dent synced 2024-12-18 20:52:29 -05:00

Documentation, formatting fixes

This commit is contained in:
Austen Adler 2015-03-23 10:52:02 -04:00
parent 3de6e0023c
commit d8f39bef0a
26 changed files with 88 additions and 89 deletions

View File

@ -4,10 +4,10 @@
AutoDrive::AutoDrive(double duration, double xtmp, double ytmp, double ztmp, bool useGyro): Command("AutoDrive"){ AutoDrive::AutoDrive(double duration, double xtmp, double ytmp, double ztmp, bool useGyro): Command("AutoDrive"){
Requires(DentRobot::drivetrain); Requires(DentRobot::drivetrain);
SetTimeout(duration); SetTimeout(duration);
x=xtmp; x = xtmp;
y=ytmp; y = ytmp;
z=ztmp; z = ztmp;
gyro=useGyro; gyro = useGyro;
} }
void AutoDrive::Initialize(){ void AutoDrive::Initialize(){
DentRobot::drivetrain->ResetGyro(); DentRobot::drivetrain->ResetGyro();

View File

@ -23,9 +23,9 @@ class AutoDrive: public Command{
* *
* @param duration Timeout in seconds * @param duration Timeout in seconds
* @param xtmp Joystick x value (default: 0.0) * @param xtmp Joystick x value (default: 0.0)
* @param ytmp Joystick y value (default: 0.75) * @param ytmp Joystick y value (default: -0.75)
* @param ztmp Joystick z value (default: 0.0) * @param ztmp Joystick z value (default: 0.0)
* @param useGyro Use the gyro when driving * @param useGyro Use the gyro when driving (default: true)
*/ */
AutoDrive(double duration, double xtmp = 0.0, double ytmp = -0.75, double ztmp = 0.0, bool useGyro = true); AutoDrive(double duration, double xtmp = 0.0, double ytmp = -0.75, double ztmp = 0.0, bool useGyro = true);
/** /**

View File

@ -37,9 +37,9 @@ class Autonomous: public CommandGroup{
/** /**
* @brief Constructs Autonomous * @brief Constructs Autonomous
* *
* @param seq The sequence to run * @param seq The sequence to run (default: 0)
*/ */
Autonomous(int seq=0); Autonomous(int seq = 0);
}; };
#endif #endif
// vim: ts=2:sw=2:et // vim: ts=2:sw=2:et

View File

@ -12,7 +12,6 @@
* Turns the robot until a timeout is reached * Turns the robot until a timeout is reached
*/ */
class Turn: public Command{ class Turn: public Command{
private:
public: public:
/** /**
* @brief Constructs Turn * @brief Constructs Turn

View File

@ -14,7 +14,7 @@ class BinCloseArms: public Command{
/** /**
* @brief Constructs BinCloseArms * @brief Constructs BinCloseArms
* *
* @param timeout The timeout * @param timeout Timeout in seconds (default: 0.5)
*/ */
BinCloseArms(double timeout = 0.5); BinCloseArms(double timeout = 0.5);
/** /**

View File

@ -12,7 +12,7 @@ class BinLower: public Command{
/** /**
* @brief Constructs BinLower * @brief Constructs BinLower
* *
* @param timeout The timeout * @param timeout Timeout in seconds
*/ */
BinLower(float timeout); BinLower(float timeout);
/** /**

View File

@ -12,7 +12,7 @@ class BinOpenArms: public Command{
/** /**
* @brief Constructs BinOpenArms * @brief Constructs BinOpenArms
* *
* @param timeout The timeout * @param timeout Timeout in seconds
*/ */
BinOpenArms(double timeout); BinOpenArms(double timeout);
/** /**

View File

@ -1,14 +1,14 @@
#include "RollIn.h" #include "RollIn.h"
RollIn::RollIn(double speed): Command("RollIn"){ RollIn::RollIn(double speed): Command("RollIn"){
rawSpeed=speed; rawSpeed = speed;
} }
void RollIn::Initialize(){ void RollIn::Initialize(){
printf("Initialized RollIn\n"); printf("Initialized RollIn\n");
SetTimeout(2.0); SetTimeout(2.0);
} }
void RollIn::Execute(){ void RollIn::Execute(){
//double cvt=(rawSpeed)*DentRobot::collector->GetSonarDistance()/0.4; //double cvt = (rawSpeed)*DentRobot::collector->GetSonarDistance()/0.4;
//if(cvt<=1.0){ //if(cvt <= 1.0){
// DentRobot::collector->MoveRollers(1.0); // DentRobot::collector->MoveRollers(1.0);
//}else{ //}else{
// DentRobot::collector->MoveRollers(cvt*1.5); // DentRobot::collector->MoveRollers(cvt*1.5);

View File

@ -14,9 +14,9 @@ class RollOut: public Command{
/** /**
* @brief Constructs RollOut * @brief Constructs RollOut
* *
* @param timeout The timeout * @param timeout Timeout in seconds (default: 2.0)
*/ */
RollOut(double timeout=2.0); RollOut(double timeout = 2.0);
/** /**
* @brief Initializes the class * @brief Initializes the class
*/ */

View File

@ -1,6 +1,6 @@
#include "RollVar.h" #include "RollVar.h"
RollVar::RollVar(double speedVal): Command("RollVar"){ RollVar::RollVar(double speedVal): Command("RollVar"){
speed=speedVal; speed = speedVal;
} }
void RollVar::Initialize(){ void RollVar::Initialize(){
printf("Initialized RollVar\n"); printf("Initialized RollVar\n");

View File

@ -12,10 +12,10 @@ void Drive::Execute(){
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
// Lock the x axis when not holding button 1 // Lock the x axis when not holding button 1
//if(DentRobot::oi->GetLeftStick()->GetRawButton(1)){ //if(DentRobot::oi->GetLeftStick()->GetRawButton(1)){
// x=0; // x = 0;
//} //}
//if(DentRobot::oi->GetLeftStick()->GetRawButton(2)){ //if(DentRobot::oi->GetLeftStick()->GetRawButton(2)){
// y=0; // y = 0;
//} //}
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle) //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle)
if(DentRobot::oi->GetLeftStick()->GetRawButton(11)){ if(DentRobot::oi->GetLeftStick()->GetRawButton(11)){

View File

@ -3,7 +3,6 @@
#include "Commands/Command.h" #include "Commands/Command.h"
#include "../../DentRobot.h" #include "../../DentRobot.h"
#include "../../DentRobot.h"
#include "WPILib.h" #include "WPILib.h"
/** /**

View File

@ -11,8 +11,10 @@ class Lower: public Command{
public: public:
/** /**
* @brief Constructs Lower * @brief Constructs Lower
*
* @param timeout Timeout in seconds (default: 3.0)
*/ */
Lower(double timeout=3.0); Lower(double timeout = 3.0);
/** /**
* @brief Initializes the class * @brief Initializes the class
*/ */

View File

@ -11,11 +11,11 @@ void Raise::Execute(){
} }
bool Raise::IsFinished(){ bool Raise::IsFinished(){
//if(!DentRobot::elevator->GetElevatorMiddle()){ //if(!DentRobot::elevator->GetElevatorMiddle()){
// DentRobot::elevator->stoppedAtSensor=true; // DentRobot::elevator->stoppedAtSensor = true;
//} //}
//if((DentRobot::elevator->stoppedAtSensor)){ //if((DentRobot::elevator->stoppedAtSensor)){
// printf("Stopped at the middle sensor\n"); // printf("Stopped at the middle sensor\n");
// DentRobot::elevator->stoppedAtSensor=false; // DentRobot::elevator->stoppedAtSensor = false;
// return true; // return true;
//}else if(!DentRobot::elevator->GetElevatorTop()){ //}else if(!DentRobot::elevator->GetElevatorTop()){
if(!DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle()||IsTimedOut()){ if(!DentRobot::elevator->GetElevatorTop()||!DentRobot::elevator->GetElevatorMiddle()||IsTimedOut()){

View File

@ -11,8 +11,10 @@ class Raise: public Command{
public: public:
/** /**
* @brief Constructs Raise * @brief Constructs Raise
*
* @param timeout Timeout in seconds (default: 3.5)
*/ */
Raise(double timeout=3.5); Raise(double timeout = 3.5);
/** /**
* @brief Initializes the class * @brief Initializes the class
*/ */

View File

@ -2,20 +2,20 @@
#include "OI.h" #include "OI.h"
#include "RobotMap.h" #include "RobotMap.h"
#include "Commands/Autonomous/Autonomous.h" #include "Commands/Autonomous/Autonomous.h"
OI* DentRobot::oi=NULL; OI* DentRobot::oi = NULL;
Collector* DentRobot::collector=NULL; Collector* DentRobot::collector = NULL;
Drivetrain* DentRobot::drivetrain=NULL; Drivetrain* DentRobot::drivetrain = NULL;
Elevator* DentRobot::elevator=NULL; Elevator* DentRobot::elevator = NULL;
BinElevator* DentRobot::binElevator=NULL; BinElevator* DentRobot::binElevator = NULL;
CommandGroup* DentRobot::aut=NULL; CommandGroup* DentRobot::aut = NULL;
Pneumatics* DentRobot::pneumatics=NULL; Pneumatics* DentRobot::pneumatics = NULL;
DentRobot::DentRobot(){ DentRobot::DentRobot(){
oi=new OI(); oi = new OI();
collector=new Collector(); collector = new Collector();
drivetrain=new Drivetrain(); drivetrain = new Drivetrain();
elevator=new Elevator(); elevator = new Elevator();
binElevator=new BinElevator(); binElevator = new BinElevator();
pneumatics=new Pneumatics(); pneumatics = new Pneumatics();
//CameraServer::GetInstance()->SetQuality(25); //CameraServer::GetInstance()->SetQuality(25);
//CameraServer::GetInstance()->StartAutomaticCapture("cam0"); //CameraServer::GetInstance()->StartAutomaticCapture("cam0");
printf("The robot is on\n"); printf("The robot is on\n");
@ -55,7 +55,7 @@ void DentRobot::DisabledPeriodic(){
Scheduler::GetInstance()->Run(); Scheduler::GetInstance()->Run();
} }
void DentRobot::AutonomousInit(){ void DentRobot::AutonomousInit(){
aut=new Autonomous(SmartDashboard::GetNumber("Auto Sequence")); aut = new Autonomous(SmartDashboard::GetNumber("Auto Sequence"));
printf("Enabling Auto Sequence %f\n", SmartDashboard::GetNumber("Auto Sequence")); printf("Enabling Auto Sequence %f\n", SmartDashboard::GetNumber("Auto Sequence"));
if(aut != NULL){ if(aut != NULL){
aut->Start(); aut->Start();
@ -72,7 +72,7 @@ void DentRobot::TeleopInit(){
} }
void DentRobot::TeleopPeriodic(){ void DentRobot::TeleopPeriodic(){
Scheduler::GetInstance()->Run(); Scheduler::GetInstance()->Run();
if(elevator->GetUseEncoder()&&elevator->GetHeight()<=-1.0){ if(elevator->GetUseEncoder()&&elevator->GetHeight() <= -1.0){
// Raise the elevator if it dips below elevatorTop // Raise the elevator if it dips below elevatorTop
oi->raise->Start(); oi->raise->Start();
} }

32
OI.cpp
View File

@ -12,40 +12,40 @@
#include "Commands/Autonomous/ReleaseTote.h" #include "Commands/Autonomous/ReleaseTote.h"
OI::OI(){ OI::OI(){
// Joysticks // Joysticks
leftStick=new Joystick(0); leftStick = new Joystick(0);
rightStick=new Joystick(1); rightStick = new Joystick(1);
// Collector // Collector
JoystickButton *left1=new JoystickButton(leftStick, 1); JoystickButton *left1 = new JoystickButton(leftStick, 1);
JoystickButton *left2=new JoystickButton(leftStick, 2); JoystickButton *left2 = new JoystickButton(leftStick, 2);
JoystickButton *left7=new JoystickButton(leftStick, 7); JoystickButton *left7 = new JoystickButton(leftStick, 7);
left1->WhileHeld(new RollIn(GetLeftThrottle())); left1->WhileHeld(new RollIn(GetLeftThrottle()));
left2->WhileHeld(new RollOut(2.0)); left2->WhileHeld(new RollOut(2.0));
// 0.8 is the multiplier, so they roll at 80% power // 0.8 is the multiplier, so they roll at 80% power
left7->WhileHeld(new RollVar(0.8)); left7->WhileHeld(new RollVar(0.8));
// Elevator // Elevator
raise=new Raise(3.5); raise = new Raise(3.5);
lower=new Lower(3.0); lower = new Lower(3.0);
JoystickButton *right4=new JoystickButton(rightStick, 4); JoystickButton *right4 = new JoystickButton(rightStick, 4);
JoystickButton *right6=new JoystickButton(rightStick, 6); JoystickButton *right6 = new JoystickButton(rightStick, 6);
right4->WhenPressed(lower); right4->WhenPressed(lower);
right4->CancelWhenPressed(raise); right4->CancelWhenPressed(raise);
right6->WhenPressed(raise); right6->WhenPressed(raise);
right6->CancelWhenPressed(lower); right6->CancelWhenPressed(lower);
// BinElevator // BinElevator
JoystickButton *right3=new JoystickButton(rightStick, 3); JoystickButton *right3 = new JoystickButton(rightStick, 3);
JoystickButton *right5=new JoystickButton(rightStick, 5); JoystickButton *right5 = new JoystickButton(rightStick, 5);
//JoystickButton *right7=new JoystickButton(rightStick, 7); //JoystickButton *right7 = new JoystickButton(rightStick, 7);
//JoystickButton *right8=new JoystickButton(rightStick, 8); //JoystickButton *right8 = new JoystickButton(rightStick, 8);
//right7->WhenPressed(new BinOpenArms()); //right7->WhenPressed(new BinOpenArms());
//right8->WhenPressed(new BinCloseArms()); //right8->WhenPressed(new BinCloseArms());
binRaise=new BinRaise(3.0); binRaise = new BinRaise(3.0);
binLower=new BinLower(2.0); binLower = new BinLower(2.0);
right3->WhileHeld(binLower); right3->WhileHeld(binLower);
right3->CancelWhenPressed(binRaise); right3->CancelWhenPressed(binRaise);
right5->WhileHeld(binRaise); right5->WhileHeld(binRaise);
right5->CancelWhenPressed(binLower); right5->CancelWhenPressed(binLower);
// Cancel // Cancel
JoystickButton *right12=new JoystickButton(rightStick, 12); JoystickButton *right12 = new JoystickButton(rightStick, 12);
right12->CancelWhenPressed(raise); right12->CancelWhenPressed(raise);
right12->CancelWhenPressed(lower); right12->CancelWhenPressed(lower);
} }

11
OI.h
View File

@ -9,16 +9,17 @@
*/ */
class OI{ class OI{
private: private:
Joystick *leftStick, *rightStick; Joystick *leftStick, //<! Left joystick
*rightStick; //<! Right joystick
public: public:
/** /**
* @brief Constructs OI * @brief Constructs OI
*/ */
OI(); OI();
Command *raise, //!< Raise command Command *raise, //<! Raise command
*lower, //!< Lower command *lower, //<! Lower command
*binLower, //!< BinLower command *binLower, //<! BinLower command
*binRaise; //!< BinRaise command *binRaise; //<! BinRaise command
/** /**
* @brief Returns the right joystick * @brief Returns the right joystick
* *

View File

@ -1,10 +1,10 @@
#include "BinElevator.h" #include "BinElevator.h"
#include "../RobotMap.h" #include "../RobotMap.h"
BinElevator::BinElevator(){ BinElevator::BinElevator(){
motor=new CANTalon(BINELEVATOR_CAN); motor = new CANTalon(BINELEVATOR_CAN);
elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA, BINELEVATOR_ENCODERB, false); elevatorEncoder = new Encoder(BINELEVATOR_ENCODERA, BINELEVATOR_ENCODERB, false);
elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO); elevatorBottom = new DigitalInput(BINELEVATOR_BOTTOM_DIO);
elevatorTop=new DigitalInput(BINELEVATOR_TOP_DIO); elevatorTop = new DigitalInput(BINELEVATOR_TOP_DIO);
} }
void BinElevator::InitDefaultCommand(){ void BinElevator::InitDefaultCommand(){
} }

View File

@ -24,9 +24,7 @@ class BinElevator{
/** /**
* @brief Runs the bin elevator * @brief Runs the bin elevator
* *
* @param power The power to run the bin elevator * @param power The power to run the bin elevator (-1.0 to 1.0)
*
* Ranges from -1.0 to 1.0
*/ */
void Run(double power); void Run(double power);
/** /**

View File

@ -2,11 +2,11 @@
#include "../RobotMap.h" #include "../RobotMap.h"
Collector::Collector(): Subsystem("Collector"){ Collector::Collector(): Subsystem("Collector"){
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN); collectorMotorLeft = new CANTalon(COLLECTOR_LEFT_CAN);
collectorMotorBottom=new CANTalon(COLLECTOR_BOTTOM_CAN); collectorMotorBottom = new CANTalon(COLLECTOR_BOTTOM_CAN);
collectorMotorRamp=new CANTalon(COLLECTOR_RAMP_CAN); collectorMotorRamp = new CANTalon(COLLECTOR_RAMP_CAN);
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN); collectorMotorRight = new CANTalon(COLLECTOR_RIGHT_CAN);
sonarAnalog=new AnalogInput(COLLECTOR_SONAR_ANALOG); sonarAnalog = new AnalogInput(COLLECTOR_SONAR_ANALOG);
} }
void Collector::InitDefaultCommand(){ void Collector::InitDefaultCommand(){
} }

View File

@ -33,25 +33,25 @@ class Collector: public Subsystem{
/** /**
* @brief Moves the collectors * @brief Moves the collectors
* *
* @param power The speed to run the collectors * @param power The power to run the collectors
*/ */
void MoveRollers(double power); void MoveRollers(double power);
/** /**
* @brief Moves the left roller * @brief Moves the left roller
* *
* @param power The speed to run the left roller * @param power The power to run the left roller
*/ */
void MoveLeftRoller(double power); void MoveLeftRoller(double power);
/** /**
* @brief Moves the right roller * @brief Moves the right roller
* *
* @param power The speed to run the right roller * @param power The power to run the right roller
*/ */
void MoveRightRoller(double power); void MoveRightRoller(double power);
/** /**
* @brief Moves the bottom rollers * @brief Moves the bottom rollers
* *
* @param power The speed to run the bottom rollers * @param power The power to run the bottom rollers
*/ */
void MoveBottomRollers(double power); void MoveBottomRollers(double power);
/** /**

View File

@ -13,7 +13,7 @@ void Drivetrain::InitDefaultCommand(){
SetDefaultCommand(new Drive()); SetDefaultCommand(new Drive());
} }
void Drivetrain::DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight){ void Drivetrain::DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight){
double kP=SmartDashboard::GetNumber("Gyro kP"); double kP = SmartDashboard::GetNumber("Gyro kP");
double correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x); double correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x);
double correctY = -(sensitivity*(pow(y, 3))+(1-sensitivity)*y); double correctY = -(sensitivity*(pow(y, 3))+(1-sensitivity)*y);
double correctZ; double correctZ;

View File

@ -39,9 +39,9 @@ class Drivetrain: public Subsystem{
* @param y Joystick y value (-1.0 to 1.0) * @param y Joystick y value (-1.0 to 1.0)
* @param z Joystick z value (-1.0 to 1.0) * @param z Joystick z value (-1.0 to 1.0)
* @param sensitivity Sensitivity (0.0 to 1.0) * @param sensitivity Sensitivity (0.0 to 1.0)
* @param driveStraight Overrides z value to correct for motor lag * @param driveStraight Overrides z value to correct for motor lag (default: false)
*/ */
void DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight=false); void DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight = false);
/** /**
* @brief Tests one motor * @brief Tests one motor
* *

View File

@ -1,13 +1,13 @@
#include "Elevator.h" #include "Elevator.h"
#include "../RobotMap.h" #include "../RobotMap.h"
Elevator::Elevator(){ Elevator::Elevator(){
motor=new CANTalon(ELEVATOR_CAN); motor = new CANTalon(ELEVATOR_CAN);
elevatorEncoder=new Encoder(ELEVATOR_ENCODERA, ELEVATOR_ENCODERB, false); elevatorEncoder = new Encoder(ELEVATOR_ENCODERA, ELEVATOR_ENCODERB, false);
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); elevatorBottom = new DigitalInput(ELEVATOR_BOTTOM_DIO);
elevatorMiddle=new DigitalInput(ELEVATOR_MIDDLE_DIO); elevatorMiddle = new DigitalInput(ELEVATOR_MIDDLE_DIO);
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); elevatorTop = new DigitalInput(ELEVATOR_TOP_DIO);
// Checks if the elevator is drifting // Checks if the elevator is drifting
useEncoder=false; useEncoder = false;
} }
void Elevator::InitDefaultCommand(){ void Elevator::InitDefaultCommand(){
} }
@ -36,7 +36,7 @@ bool Elevator::GetElevatorTop(){
return elevatorTop->Get(); return elevatorTop->Get();
} }
void Elevator::SetUseEncoder(bool use){ void Elevator::SetUseEncoder(bool use){
useEncoder=use; useEncoder = use;
} }
bool Elevator::GetUseEncoder(){ bool Elevator::GetUseEncoder(){
return useEncoder; return useEncoder;

View File

@ -24,8 +24,6 @@
* -# @ref Autonomous * -# @ref Autonomous
* -# @ref CollectTote * -# @ref CollectTote
* -# @ref ReleaseTote * -# @ref ReleaseTote
* -# @ref CheckDrive
* -# @ref CheckRobot
* *
* Note: Recycling containers are referred to bins throughout the project * Note: Recycling containers are referred to bins throughout the project
*/ */