DeepSpace  2019
Arm.cpp
Go to the documentation of this file.
1 #include "Subsystems/Arm.h"
2 
3 Arm::Arm() : Subsystem("Arm") {
4  // Initialize the motors
5  this->pArmMotor = new can::WPI_TalonSRX(CLIMB_ARM_MOTOR);
6  this->pArmMotor->SetNeutralMode(NeutralMode::Brake);
7 
8  this->pArmMotor->SetSafetyEnabled(false);
9 
10  this->pArmMotor2 = new can::WPI_TalonSRX(CLIMB_ARM_MOTOR_2);
11  this->pArmMotor2->SetNeutralMode(NeutralMode::Brake);
12 
13  this->pArmMotor2->SetSafetyEnabled(false);
14 
15  this->pArmHall = new frc::DigitalInput(ARM_PIN_LOWERED) ;
16 
17  // Current limiting for motor 1
18  this->pArmMotor->ConfigPeakCurrentLimit(ARM_CURRENT_THRESHOLD, ARM_PEAK_TIMEOUT);
19  this->pArmMotor->ConfigPeakCurrentDuration(ARM_CURRENT_TIMEOUT, ARM_PEAK_TIMEOUT);
20  this->pArmMotor->ConfigContinuousCurrentLimit(ARM_CURRENT_HOLD, ARM_PEAK_TIMEOUT);
21 
22  // Current limiting for motor 2
23  this->pArmMotor2->ConfigPeakCurrentLimit(ARM_CURRENT_THRESHOLD, ARM_PEAK_TIMEOUT);
24  this->pArmMotor2->ConfigPeakCurrentDuration(ARM_CURRENT_TIMEOUT, ARM_PEAK_TIMEOUT);
25  this->pArmMotor2->ConfigContinuousCurrentLimit(ARM_CURRENT_HOLD, ARM_PEAK_TIMEOUT);
26 
27  // Enable current limiting on each motor
28  this->pArmMotor->EnableCurrentLimit(true);
29  this->pArmMotor2->EnableCurrentLimit(true);
30 }
31 
33  // Set the default command for a subsystem here.
34  // SetDefaultCommand(new MySpecialCommand());
35 }
36 
37 void Arm::MoveArm(double speed)
38 {
39  this->pArmMotor->Set(speed);
40  this->pArmMotor2->Set(speed);
41 }
42 
43 bool Arm::GetSensor(void)
44 {
45  return ! this->pArmHall->Get() ;
46 }
#define ARM_PIN_LOWERED
Definition: RobotMap.h:77
Arm()
Definition: Arm.cpp:3
#define ARM_CURRENT_HOLD
Definition: RobotMap.h:21
#define ARM_CURRENT_THRESHOLD
Definition: RobotMap.h:20
#define ARM_PEAK_TIMEOUT
Definition: RobotMap.h:22
frc::DigitalInput * pArmHall
hall effects for arm is lowered enough
Definition: Arm.h:39
can::WPI_TalonSRX * pArmMotor2
Pointer for Arm arm motor.
Definition: Arm.h:37
#define CLIMB_ARM_MOTOR_2
Definition: RobotMap.h:57
#define CLIMB_ARM_MOTOR
Definition: RobotMap.h:56
#define ARM_CURRENT_TIMEOUT
Definition: RobotMap.h:23
bool GetSensor(void)
Returns whether the hall effects is tripped This is the sensor for when the arm is lowered...
Definition: Arm.cpp:43
can::WPI_TalonSRX * pArmMotor
Pointer for Arm arm motor.
Definition: Arm.h:36
void MoveArm(double Speed)
Move Arm arm up or down.
Definition: Arm.cpp:37
void InitDefaultCommand() override
Initalizes the default command for this subsystem (Arm)
Definition: Arm.cpp:32