diff --git a/src/CommandBase.cpp b/src/CommandBase.cpp index 7c8c4d5..3d51e70 100644 --- a/src/CommandBase.cpp +++ b/src/CommandBase.cpp @@ -2,7 +2,6 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" #include "Commands/Raise.h" diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp deleted file mode 100644 index e901aa6..0000000 --- a/src/Commands/Drive.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Drive.h" -Drive::Drive(){ -} -void Drive::Initialize(){ -} -void Drive::Execute(){ -} -bool Drive::IsFinished(){ - return false; -} -void Drive::End(){ - -} -void Drive::Interrupted(){ -} diff --git a/src/Commands/Drive.h b/src/Commands/Drive.h deleted file mode 100644 index 7d8e070..0000000 --- a/src/Commands/Drive.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DRIVE_H -#define DRIVE_H - -#include "../CommandBase.h" -#include "WPILib.h" - -class Drive: public CommandBase{ - public: - Drive(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); -}; - -#endif diff --git a/src/Commands/Eject.cpp b/src/Commands/Eject.cpp index 4ac7f59..98fdf0d 100644 --- a/src/Commands/Eject.cpp +++ b/src/Commands/Eject.cpp @@ -1,9 +1,11 @@ #include "Eject.h" +#include "../DentRobot.h" Eject::Eject(){ } void Eject::Initialize(){ } void Eject::Execute(){ + DentRobot::collector->Set(oi->GetLeftStick()->GetThrottle()); } bool Eject::IsFinished(){ return false; diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp index f34e638..ad9a71b 100644 --- a/src/DentRobot.cpp +++ b/src/DentRobot.cpp @@ -1,11 +1,16 @@ #include "DentRobot.h" -DentRobot::DentRobot(): - driveCommand(new Drive()){ +OI* DentRobot::oi=NULL; +Collector* DentRobot::collector=NULL; +Drivetrain* DentRobot::drivetrain=NULL; +Elevator* DentRobot::elevator=NULL; +DentRobot::DentRobot(){ + oi=new OI(); + collector=new Collector(); + drivetrain=new Drivetrain(); + elevator=new Elevator(); printf("Initialized"); } void DentRobot::RobotInit(){ - printf("Initializing"); - CommandBase::init(); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/src/DentRobot.h b/src/DentRobot.h index 2ec1f47..cd88121 100644 --- a/src/DentRobot.h +++ b/src/DentRobot.h @@ -1,15 +1,18 @@ #ifndef DENTROBOT_H #define DENTROBOT_H #include "WPILib.h" -#include "Commands/Drive.h" -#include "Commands/Collect.h" -#include "Commands/Eject.h" -#include "Commands/Raise.h" -#include "Commands/Lower.h" +#include "OI.h" +#include "Subsystems/Elevator.h" +#include "Subsystems/Drivetrain.h" +#include "Subsystems/Collector.h" class DentRobot: public IterativeRobot { private: Command *driveCommand = NULL; public: + static OI* oi; + static Collector* collector; + static Drivetrain* drivetrain; + static Elevator* elevator; DentRobot(); void RobotInit(); void DisabledPeriodic(); diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..a1c6857 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,27 @@ +REMOTEIP=10.20.59.2 +CC=arm-frc-linux-gnueabi-g++ +CFLAGS=-std=c++11 -O0 -g3 -Wall -c -fmessage-length=0 +LDFLAGS=-Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a +SOURCES=$(shell find -type f -name "*.cpp") +OBJECTS=$(SOURCES:.cpp=.o) +WPILIB=/home/stonewareslord/Applications/vagrant/frc-cpp-vagrantfile/wpilib +EXEC=bin/FRCUserProgram +CLEANSER=rm -r + +all : $(OBJECTS) + $(CC) -L$(WPILIB)/lib $(LDFLAGS) -o $(EXEC) $(OBJECTS) -lwpi + +%.o : %.cpp + $(CC) $(CFLAGS) -I$(WPILIB)/include $^ -o $@ + +clean: + $(CLEANSER) $(OBJECTS) bin/FRCUserProgram + +deploy: + @cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram;/usr/local/frc/bin/frcKillRobot.sh -t -r' + +putkey: + @test -d ~/.ssh||mkdir ~/.ssh;test -f ~/.ssh/id_rsa||ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -q -N '';cat ~/.ssh/id_rsa.pub|ssh -v admin@$(REMOTEIP) 'cat >> /tmp/key;mkdir -p ~/.ssh;cat /tmp/key >> ~/.ssh/authorized_keys;rm /tmp/key' + +updatemakefile: + @curl -s https://raw.githubusercontent.com/int0x191f2/nameless/master/configure.sh | sh diff --git a/src/OI.cpp b/src/OI.cpp index 8425006..dc5f0f2 100644 --- a/src/OI.cpp +++ b/src/OI.cpp @@ -1,4 +1,20 @@ #include "OI.h" +#include "Commands/Lower.h" +#include "Commands/Raise.h" +#include "Commands/Collect.h" +#include "Commands/Eject.h" OI::OI() { + leftStick=new Joystick(0); + rightStick=new Joystick(1); + JoystickButton *left10=new JoystickButton(leftStick, 10); + JoystickButton *left11=new JoystickButton(leftStick, 11); + left10->WhenPressed(new Eject()); + left11->WhenPressed(new Collect()); +} +Joystick* OI::GetRightStick(){ + return rightStick; +} +Joystick* OI::GetLeftStick(){ + return leftStick; } diff --git a/src/OI.h b/src/OI.h index 01b5823..e89ec0a 100644 --- a/src/OI.h +++ b/src/OI.h @@ -6,7 +6,10 @@ class OI { private: + Joystick *leftStick, *rightStick; public: OI(); + Joystick* GetRightStick(); + Joystick* GetLeftStick(); }; #endif diff --git a/src/Subsystems/Collector.cpp b/src/Subsystems/Collector.cpp index 443c99d..9180975 100644 --- a/src/Subsystems/Collector.cpp +++ b/src/Subsystems/Collector.cpp @@ -2,6 +2,12 @@ #include "../RobotMap.h" Collector::Collector() : Subsystem("Collector") { + motor1=new Talon(0); + motor2=new Talon(1); } void Collector::InitDefaultCommand() { } +void Collector::Set(float power){ + motor1->Set(power); + motor2->Set(power); +} diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h index c9026ce..9308d15 100644 --- a/src/Subsystems/Collector.h +++ b/src/Subsystems/Collector.h @@ -5,8 +5,10 @@ class Collector: public Subsystem { private: + Talon *motor1, *motor2; public: Collector(); void InitDefaultCommand(); + void Set(float); }; #endif diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index c152a4a..da53fde 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -1,14 +1,14 @@ #include "Drivetrain.h" #include "../RobotMap.h" -Drivetrain::Drivetrain() : Subsystem("Drivetrain") { +Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ frontLeft=new Talon(0); frontRight=new Talon(1); backLeft=new Talon(2); backRight=new Talon(3); drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); } -void Drivetrain::InitDefaultCommand() { +void Drivetrain::InitDefaultCommand(){ } void Drivetrain::DriveMecanum(float x, float y, float rotation){ drive->MecanumDrive_Cartesian(x, y, rotation); diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp index cf37a88..2aa7368 100644 --- a/src/Subsystems/Elevator.cpp +++ b/src/Subsystems/Elevator.cpp @@ -1,12 +1,13 @@ #include "Elevator.h" #include "../RobotMap.h" -Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ +//Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ +Elevator::Elevator() : Subsystem("Elevator"){ pot=new AnalogPotentiometer(0); leftMotor=new Talon(1); rightMotor=new Talon(0); - SetAbsoluteTolerance(0.004); + //SetAbsoluteTolerance(0.004); } -void Elevator::InitDefaultCommand() { +void Elevator::InitDefaultCommand(){ } float Elevator::GetPotValue(){ return pot->Get(); diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index 2ed8c01..9108aa5 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -2,9 +2,9 @@ #define ELEVATOR_H #include "WPILib.h" -#include "Commands/PIDSubsystem.h" -class Elevator: public PIDSubsystem -{ +//#include "Commands/PIDSubsystem.h" +//class Elevator: public PIDSubsystem{ +class Elevator: public Subsystem{ private: AnalogPotentiometer *pot; Talon *leftMotor, *rightMotor;