DeepSpace  2019
Leg.cpp
Go to the documentation of this file.
1 #include "Subsystems/Leg.h"
2 
3 Leg::Leg() : Subsystem("Leg Subsystem") {
4  // Initialize the motors
5  this->pLegMotor = new can::WPI_TalonSRX(CLIMB_LEG_MOTOR);
6 
7  this->pLegMotor->SetNeutralMode(NeutralMode::Brake);
8 
9  this->pLegMotor->SetSafetyEnabled(false);
10 
11  this->pTopHall = new frc::DigitalInput(LEG_PIN_TOP);
12 
13  this->pMiddleHall = new frc::DigitalInput(LEG_PIN_MIDDLE);
14 
15  this->pBottomHall = new frc::DigitalInput(LEG_PIN_BOTTOM);
16 }
17 
19  // Set the default command for a subsystem here.
20  // SetDefaultCommand(new MySpecialCommand());
21 }
22 
23 void Leg::MoveLeg(double spd)
24 {
25  if (spd > 0.0 && this->AtTop()
26  || spd < 0.0 && this->AtBottom())
27  spd = 0.0 ;
28 
29  this->pLegMotor->Set(spd) ;
30 }
31 
32 bool Leg::AtTop(void)
33 {
34  return ! this->pTopHall->Get() ;
35 }
36 
37 bool Leg::AtMiddle(void)
38 {
39  return ! this->pMiddleHall->Get() ;
40 }
41 
42 bool Leg::AtBottom(void)
43 {
44  return ! this->pBottomHall->Get() ;
45 }
void MoveLeg(double Speed)
Move climb leg up or down.
Definition: Leg.cpp:23
frc::DigitalInput * pMiddleHall
Sensor for when the leg is at the middle position If this sensor is tripped, the robot is above the l...
Definition: Leg.h:71
#define LEG_PIN_BOTTOM
Definition: RobotMap.h:76
#define LEG_PIN_TOP
Definition: RobotMap.h:74
bool AtBottom(void)
Returns whether the legs are at the bottom most position.
Definition: Leg.cpp:42
frc::DigitalInput * pBottomHall
Sensor for when the leg is as far down as it can go If this sensor is tripped, the robot is above the...
Definition: Leg.h:78
bool AtMiddle(void)
Returns whether the legs are at the middle position.
Definition: Leg.cpp:37
#define LEG_PIN_MIDDLE
Definition: RobotMap.h:75
Leg(void)
Construct a new Leg object.
Definition: Leg.cpp:3
frc::DigitalInput * pTopHall
Sensor for when the leg is as far up as it can go If this sensor is tripped, the legs are above the w...
Definition: Leg.h:65
can::WPI_TalonSRX * pLegMotor
Pointer for the climb leg motor Works off a winch system to pull up and down But is used like a talon...
Definition: Leg.h:57
void InitDefaultCommand() override
Who uses this? You dont need to.
Definition: Leg.cpp:18
bool AtTop(void)
Returns whether the legs are at the top most position.
Definition: Leg.cpp:32
#define CLIMB_LEG_MOTOR
Definition: RobotMap.h:58