2
0
mirror of https://github.com/team2059/Dent synced 2025-01-07 22:14:14 -05:00

Worked on Autonomous

This commit is contained in:
Austen Adler 2015-03-17 09:50:38 -04:00
parent e89fb650c3
commit 40da44008f
7 changed files with 34 additions and 22 deletions

View File

@ -1,18 +1,21 @@
#include "AutoDrive.h"
#include "../../DentRobot.h"
// Drive for a short while then stop. Just for testing
AutoDrive::AutoDrive(double duration, double xtmp, double ytmp): Command("AutoDrive"){
AutoDrive::AutoDrive(double duration, double xtmp, double ytmp, double ztmp, bool useGyro): Command("AutoDrive"){
Requires(DentRobot::drivetrain);
SetTimeout(duration);
x=xtmp;
y=ytmp;
z=ztmp;
gyro=useGyro;
}
void AutoDrive::Initialize(){
DentRobot::drivetrain->ResetGyro();
}
void AutoDrive::Execute(){
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle)
DentRobot::drivetrain->DriveMecanum(x, y, 0.0, 0.9, true);
printf("z: %f\n", z);
DentRobot::drivetrain->DriveMecanum(x, y, z, 0.9, gyro);
}
bool AutoDrive::IsFinished(){
return IsTimedOut();

View File

@ -14,7 +14,9 @@
class AutoDrive: public Command{
private:
double x, //<! The x value of the simulated joystick value
y; //<! The y value of the simulated joystick value
y, //<! The y value of the simulated joystick value
z; //<! The z value of the simulated joystick value
bool gyro;
public:
/**
* @brief Constructs AutoDrive
@ -22,8 +24,10 @@ class AutoDrive: public Command{
* @param duration Timeout in seconds
* @param xtmp Joystick x value (default: 0.0)
* @param ytmp Joystick y value (default: 0.75)
* @param ztmp Joystick z value (default: 0.0)
* @param useGyro Use the gyro when driving
*/
AutoDrive(double duration, double xtmp = 0.0, double ytmp = -0.75);
AutoDrive(double duration, double xtmp = 0.0, double ytmp = -0.75, double ztmp = 0.0, bool useGyro = true);
/**
* @brief Initializes the class
*/

View File

@ -11,17 +11,16 @@
#include "CollectTote.h"
#include "ReleaseTote.h"
Autonomous::Autonomous(int seq){
//SmartDashboard::GetNumber("Auto Wait Time");
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
switch(seq){
case 0:
// Just for testing
// Strafe at .25 power
AddSequential(new AutoDrive(0.5, 0.25, 0.0));
// Turn testing
AddSequential(new Turn(3.8));
break;
case 1:
// Drive to Auto Zone (TM)
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.8));
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.8, 0.01));
AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount")));
break;
case 2:
@ -35,7 +34,6 @@ Autonomous::Autonomous(int seq){
break;
case 3:
// Collect a tote with BinElevator, turn, drive to Auto Zone (TM)
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount")));
AddSequential(new BinRaise(1.2));
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.75));
@ -44,18 +42,17 @@ Autonomous::Autonomous(int seq){
break;
case 4:
// Collect one, two, or three totes, drive to Auto Zone (TM), release totes
printf("Waiting: %f\n", SmartDashboard::GetNumber("Auto Wait Time"));
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
printf("Done");
AddSequential(new CollectTote());
AddSequential(new CollectTote(SmartDashboard::GetNumber("CollectToteTurn")));
if(SmartDashboard::GetBoolean("Two totes")){
AddParallel(new Turn(0.81));
AddSequential(new Raise(3.5));
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0.0, 0.75));
AddSequential(new CollectTote());
AddSequential(new Lower(3.0));
AddSequential(new Raise(3.5));
if(SmartDashboard::GetBoolean("Three totes")){
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0.0, 0.75));
AddSequential(new Turn(3.8));
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance")*2.5, 0.0, 0.75));
AddSequential(new CollectTote());
AddSequential(new Lower(3.0));
AddSequential(new Raise(3.5));

View File

@ -2,8 +2,8 @@
#include "../../DentRobot.h"
#include "AutoDrive.h"
#include "../Collector/RollIn.h"
CollectTote::CollectTote(){
AddParallel(new AutoDrive(1.0, 0.0, 0.75));
CollectTote::CollectTote(double z){
AddParallel(new AutoDrive(SmartDashboard::GetNumber("DriveTime"), 0.0, 0.75, z, false));
AddSequential(new RollIn(1.0));
}
// vim: ts=2:sw=2:et

View File

@ -15,8 +15,10 @@ class CollectTote: public CommandGroup{
public:
/**
* @brief Constructs CollectTote
*
* @param z Joystick z value (default: 0.0)
*/
CollectTote();
CollectTote(double z = 0.0);
};
#endif
// vim: ts=2:sw=2:et

View File

@ -23,18 +23,24 @@ DentRobot::DentRobot(){
void DentRobot::RobotInit(){
SmartDashboard::PutNumber("CodeVersion", CODE_VERSION);
// Autonomous
// Calibration
// Amount to turn while collecting the initial tote in auto 4
SmartDashboard::PutNumber("CollectToteTurn", 0.25);
// Amount of time to collect a tote
SmartDashboard::PutNumber("DriveTime", 1.3);
// Sequence of autonomous command
SmartDashboard::PutNumber("Auto Sequence", 1.0);
SmartDashboard::PutNumber("Auto Sequence", 4.0);
SmartDashboard::PutNumber("Auto Wait Time", 0.5);
// If the robot will be picking up three totes in sequence 3
SmartDashboard::PutBoolean("Two totes", true);
SmartDashboard::PutBoolean("Two totes", false);
SmartDashboard::PutBoolean("Three totes", false);
// Distance (in time) to auto zone
SmartDashboard::PutNumber("Auto Zone Distance", 2.1);
// Distance (in time) to auto tote (used in sequence 3)
SmartDashboard::PutNumber("Auto Tote Distance", 0.5);
SmartDashboard::PutNumber("Auto Tote Distance", 1.0);
SmartDashboard::PutNumber("Auto Bin Distance", 0.25);
SmartDashboard::PutNumber("TurnAmount", 1.8);
// Elevators
SmartDashboard::PutBoolean("Bin Elevator Bottom", false);
SmartDashboard::PutBoolean("Bin Elevator Top", false);

View File

@ -19,7 +19,7 @@ clean:
$(CLEANSER) $(OBJECTS) bin/FRCUserProgram
deploy:
@cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) '(rm /home/lvuser/FRCUserProgram)</dev/null;cat > /home/lvuser/FRCUserProgram;chmod a+x /home/lvuser/FRCUserProgram'
@/home/stonewareslord/git/pv-1.5.7/pv bin/FRCUserProgram | ssh admin@$(REMOTEIP) '(rm /home/lvuser/FRCUserProgram)</dev/null;cat > /home/lvuser/FRCUserProgram;chmod a+x /home/lvuser/FRCUserProgram'
debug:
@cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) '(rm /home/lvuser/FRCUserProgram)</dev/null;cat > /home/lvuser/FRCUserProgram;chmod a+x /home/lvuser/FRCUserProgram;/home/lvuser/run.sh'