mirror of
https://github.com/team2059/Dent
synced 2025-01-17 22:19:21 -05:00
Worked on Autonomous
This commit is contained in:
parent
e89fb650c3
commit
40da44008f
@ -1,18 +1,21 @@
|
|||||||
#include "AutoDrive.h"
|
#include "AutoDrive.h"
|
||||||
#include "../../DentRobot.h"
|
#include "../../DentRobot.h"
|
||||||
// Drive for a short while then stop. Just for testing
|
// 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);
|
Requires(DentRobot::drivetrain);
|
||||||
SetTimeout(duration);
|
SetTimeout(duration);
|
||||||
x=xtmp;
|
x=xtmp;
|
||||||
y=ytmp;
|
y=ytmp;
|
||||||
|
z=ztmp;
|
||||||
|
gyro=useGyro;
|
||||||
}
|
}
|
||||||
void AutoDrive::Initialize(){
|
void AutoDrive::Initialize(){
|
||||||
DentRobot::drivetrain->ResetGyro();
|
DentRobot::drivetrain->ResetGyro();
|
||||||
}
|
}
|
||||||
void AutoDrive::Execute(){
|
void AutoDrive::Execute(){
|
||||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle)
|
//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(){
|
bool AutoDrive::IsFinished(){
|
||||||
return IsTimedOut();
|
return IsTimedOut();
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
class AutoDrive: public Command{
|
class AutoDrive: public Command{
|
||||||
private:
|
private:
|
||||||
double x, //<! The x value of the simulated joystick value
|
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:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructs AutoDrive
|
* @brief Constructs AutoDrive
|
||||||
@ -22,8 +24,10 @@ 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 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
|
* @brief Initializes the class
|
||||||
*/
|
*/
|
||||||
|
@ -11,17 +11,16 @@
|
|||||||
#include "CollectTote.h"
|
#include "CollectTote.h"
|
||||||
#include "ReleaseTote.h"
|
#include "ReleaseTote.h"
|
||||||
Autonomous::Autonomous(int seq){
|
Autonomous::Autonomous(int seq){
|
||||||
//SmartDashboard::GetNumber("Auto Wait Time");
|
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
|
||||||
switch(seq){
|
switch(seq){
|
||||||
case 0:
|
case 0:
|
||||||
// Just for testing
|
// Just for testing
|
||||||
// Strafe at .25 power
|
// Turn testing
|
||||||
AddSequential(new AutoDrive(0.5, 0.25, 0.0));
|
AddSequential(new Turn(3.8));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Drive to Auto Zone (TM)
|
// Drive to Auto Zone (TM)
|
||||||
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
|
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.8, 0.01));
|
||||||
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.8));
|
|
||||||
AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount")));
|
AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount")));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -35,7 +34,6 @@ Autonomous::Autonomous(int seq){
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Collect a tote with BinElevator, turn, drive to Auto Zone (TM)
|
// 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 Turn(SmartDashboard::GetNumber("TurnAmount")));
|
||||||
AddSequential(new BinRaise(1.2));
|
AddSequential(new BinRaise(1.2));
|
||||||
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.75));
|
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.75));
|
||||||
@ -44,18 +42,17 @@ Autonomous::Autonomous(int seq){
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// Collect one, two, or three totes, drive to Auto Zone (TM), release totes
|
// Collect one, two, or three totes, drive to Auto Zone (TM), release totes
|
||||||
printf("Waiting: %f\n", SmartDashboard::GetNumber("Auto Wait Time"));
|
AddSequential(new CollectTote(SmartDashboard::GetNumber("CollectToteTurn")));
|
||||||
Wait(SmartDashboard::GetNumber("Auto Wait Time"));
|
|
||||||
printf("Done");
|
|
||||||
AddSequential(new CollectTote());
|
|
||||||
if(SmartDashboard::GetBoolean("Two totes")){
|
if(SmartDashboard::GetBoolean("Two totes")){
|
||||||
|
AddParallel(new Turn(0.81));
|
||||||
AddSequential(new Raise(3.5));
|
AddSequential(new Raise(3.5));
|
||||||
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0.0, 0.75));
|
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0.0, 0.75));
|
||||||
AddSequential(new CollectTote());
|
AddSequential(new CollectTote());
|
||||||
AddSequential(new Lower(3.0));
|
AddSequential(new Lower(3.0));
|
||||||
AddSequential(new Raise(3.5));
|
AddSequential(new Raise(3.5));
|
||||||
if(SmartDashboard::GetBoolean("Three totes")){
|
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 CollectTote());
|
||||||
AddSequential(new Lower(3.0));
|
AddSequential(new Lower(3.0));
|
||||||
AddSequential(new Raise(3.5));
|
AddSequential(new Raise(3.5));
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#include "../../DentRobot.h"
|
#include "../../DentRobot.h"
|
||||||
#include "AutoDrive.h"
|
#include "AutoDrive.h"
|
||||||
#include "../Collector/RollIn.h"
|
#include "../Collector/RollIn.h"
|
||||||
CollectTote::CollectTote(){
|
CollectTote::CollectTote(double z){
|
||||||
AddParallel(new AutoDrive(1.0, 0.0, 0.75));
|
AddParallel(new AutoDrive(SmartDashboard::GetNumber("DriveTime"), 0.0, 0.75, z, false));
|
||||||
AddSequential(new RollIn(1.0));
|
AddSequential(new RollIn(1.0));
|
||||||
}
|
}
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -15,8 +15,10 @@ class CollectTote: public CommandGroup{
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructs CollectTote
|
* @brief Constructs CollectTote
|
||||||
|
*
|
||||||
|
* @param z Joystick z value (default: 0.0)
|
||||||
*/
|
*/
|
||||||
CollectTote();
|
CollectTote(double z = 0.0);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -23,18 +23,24 @@ DentRobot::DentRobot(){
|
|||||||
void DentRobot::RobotInit(){
|
void DentRobot::RobotInit(){
|
||||||
SmartDashboard::PutNumber("CodeVersion", CODE_VERSION);
|
SmartDashboard::PutNumber("CodeVersion", CODE_VERSION);
|
||||||
// Autonomous
|
// 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
|
// Sequence of autonomous command
|
||||||
SmartDashboard::PutNumber("Auto Sequence", 1.0);
|
SmartDashboard::PutNumber("Auto Sequence", 4.0);
|
||||||
SmartDashboard::PutNumber("Auto Wait Time", 0.5);
|
SmartDashboard::PutNumber("Auto Wait Time", 0.5);
|
||||||
// If the robot will be picking up three totes in sequence 3
|
// 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);
|
SmartDashboard::PutBoolean("Three totes", false);
|
||||||
// Distance (in time) to auto zone
|
// Distance (in time) to auto zone
|
||||||
SmartDashboard::PutNumber("Auto Zone Distance", 2.1);
|
SmartDashboard::PutNumber("Auto Zone Distance", 2.1);
|
||||||
// Distance (in time) to auto tote (used in sequence 3)
|
// 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("Auto Bin Distance", 0.25);
|
||||||
SmartDashboard::PutNumber("TurnAmount", 1.8);
|
SmartDashboard::PutNumber("TurnAmount", 1.8);
|
||||||
|
|
||||||
// Elevators
|
// Elevators
|
||||||
SmartDashboard::PutBoolean("Bin Elevator Bottom", false);
|
SmartDashboard::PutBoolean("Bin Elevator Bottom", false);
|
||||||
SmartDashboard::PutBoolean("Bin Elevator Top", false);
|
SmartDashboard::PutBoolean("Bin Elevator Top", false);
|
||||||
|
2
Makefile
2
Makefile
@ -19,7 +19,7 @@ clean:
|
|||||||
$(CLEANSER) $(OBJECTS) bin/FRCUserProgram
|
$(CLEANSER) $(OBJECTS) bin/FRCUserProgram
|
||||||
|
|
||||||
deploy:
|
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:
|
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'
|
@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'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user