File tree Expand file tree Collapse file tree 10 files changed +166
-4
lines changed
Expand file tree Collapse file tree 10 files changed +166
-4
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ namespace TeamOKC {
1919 return true ;
2020 }
2121} // namespace TeamOKC
22+
Original file line number Diff line number Diff line change 1+
2+ #include " io/ClawIO.h"
3+
4+ void ClawIO::Periodic () {
5+ // Process all the inputs and outputs to/from high level software.
6+ VOKC_CALL (ProcessIO ());
7+ }
8+
9+ void ClawIO::SimulationPeriodic () {
10+ // SimulationPeriodic
11+ }
12+
13+ bool ClawIO::ProcessIO () {
14+ OKC_CHECK (sw_interface_ != nullptr );
15+ OKC_CHECK (hw_interface_ != nullptr );
16+ OKC_CHECK (hw_interface_->claw_open_and_close_encoder != nullptr );
17+
18+ // Set the software outputs
19+ // If the encoder should be reset, reset it
20+ if (sw_interface_->reset_claw_open_and_close ) {
21+ hw_interface_->claw_open_and_close_encoder ->SetPosition (0 );
22+ // Lower the encoder reset flag
23+ sw_interface_->reset_claw_open_and_close = false ;
24+ }
25+ hw_interface_->claw_open_and_close_motor ->Set (sw_interface_->claw_open_and_close_power );
26+ sw_interface_->encoder_reading = hw_interface_->claw_open_and_close_encoder ->GetPosition ();
27+
28+ return true ;
29+ }
30+
Original file line number Diff line number Diff line change 1+ #include " subsystems/Claw.h"
2+
3+ bool Claw::Init (){
4+ return true ;
5+ }
6+
7+ bool Claw::ResetPositionEncoder (){
8+ return true ;
9+ }
10+ bool Claw::ResetPositionPID (){
11+ return true ;
12+ }
13+ bool Claw::SetPosition (){
14+ // SetPosition (30); //cone
15+ // SetPosition (0); //close
16+ // SetPosition (50);//cube
17+ return true ;
18+ }
19+ bool Claw::Reset (){
20+ return true ;
21+ }
22+ void Claw::Periodic (){
23+ return ;
24+ }
25+ void Claw::SimulationPeriodic (){
26+ return ;
27+ }
Original file line number Diff line number Diff line change @@ -26,3 +26,4 @@ namespace RobotParams {
2626 return true ;
2727 }
2828} // namespace RobotParams
29+
Original file line number Diff line number Diff line change 4545#include " commands/arm/ManualArmCommand.h"
4646
4747
48-
4948/* *
5049 * This class is where the bulk of the robot should be declared. Since
5150 * Command-based is a "declarative" paradigm, very little robot logic should
Original file line number Diff line number Diff line change 22
33#include < memory>
44#include < rev/CANSparkMax.h>
5+ #include " frc/DigitalInput.h"
56
67
78
@@ -44,4 +45,8 @@ typedef struct actuators_t {
4445 std::unique_ptr<rev::CANSparkMax> arm_up_motor;
4546 std::unique_ptr<rev::CANSparkMax> arm_extend_motor;
4647
48+ // Claw things
49+ std::unique_ptr<rev::CANSparkMax> claw_motor;
50+ std::unique_ptr<frc::DigitalInput> claw_IR_sensor;
51+
4752} Actuators;
Original file line number Diff line number Diff line change 11#pragma once
22
3-
43#include < frc/motorcontrol/MotorControllerGroup.h>
54
65#include " hardware/Actuators.h"
Original file line number Diff line number Diff line change 33#include < memory>
44
55#include " AHRS.h"
6- #include " frc/AnalogEncoder.h"
6+
7+ #include < frc/DigitalInput.h>
78#include < rev/RelativeEncoder.h>
9+ #include " frc/AnalogEncoder.h"
10+
11+ // == sensor ports ==
12+ #define DEPLOY_LIMIT_SWITCH 2
13+ #define RETRACTED_LIMIT_SWITCH 3
14+
15+ #define BALL_DETECTOR 9
816
917// == sensor ports ==
1018#define LEFT_FRONT_STEER_ENCODER 0
@@ -16,6 +24,7 @@ typedef struct sensors_t {
1624 // navX IMU
1725 std::unique_ptr<AHRS> ahrs;
1826
27+
1928 // swerve drive drive encoders
2029 std::unique_ptr<rev::SparkMaxRelativeEncoder> left_front_drive_encoder;
2130 std::unique_ptr<rev::SparkMaxRelativeEncoder> left_back_drive_encoder;
@@ -37,4 +46,4 @@ typedef struct sensors_t {
3746 // arm encoders
3847 std::unique_ptr<rev::SparkMaxRelativeEncoder> arm_lift_encoder;
3948
40- } Sensors;
49+ } Sensors;
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < memory>
4+
5+ #include < frc/motorcontrol/MotorControllerGroup.h>
6+ #include < frc2/command/SubsystemBase.h>
7+ #include < frc/DigitalInput.h>
8+ #include < rev/CANSparkMax.h>
9+
10+ #include " Utils.h"
11+
12+
13+ typedef struct claw_config_t {
14+
15+ } ClawConfig;
16+
17+ typedef struct claw_hardware_interface_t {
18+ rev::CANSparkMax *const claw_open_and_close_motor;
19+ rev::SparkMaxRelativeEncoder *const claw_open_and_close_encoder;
20+ } ClawHardware;
21+
22+ typedef struct claw_software_interface_t {
23+
24+ // actuator outputs
25+ double claw_open_and_close_power;
26+ double encoder_reading;
27+ bool reset_claw_open_and_close;
28+ } ClawSoftware;
29+
30+ class ClawIO : public frc2 ::SubsystemBase {
31+ public:
32+ ClawIO (ClawHardware *hw_interface,
33+ ClawSoftware *sw_interface)
34+ : hw_interface_(hw_interface), sw_interface_(sw_interface) {}
35+
36+ /* *
37+ * Will be called periodically whenever the CommandScheduler runs.
38+ */
39+ void Periodic () override ;
40+
41+ /* *
42+ * Will be called periodically whenever the CommandScheduler runs during
43+ * simulation.
44+ */
45+ void SimulationPeriodic () override ;
46+
47+ bool ProcessIO ();
48+
49+ private:
50+ ClawHardware *const hw_interface_;
51+ ClawSoftware *const sw_interface_;
52+ };
Original file line number Diff line number Diff line change 1+ // Copyright (c) FIRST and other WPILib contributors.
2+ // Open Source Software; you can modify and/or share it under the terms of
3+ // the WPILib BSD license file in the root directory of this project.
4+
5+ #pragma once
6+
7+ #include < frc2/command/SubsystemBase.h>
8+
9+ class Claw : public frc2 ::SubsystemBase {
10+ public:
11+ Claw ();
12+ ~Claw ();
13+
14+ bool Init ();
15+
16+ bool ResetPositionEncoder ();
17+ bool ResetPositionPID ();
18+
19+ bool SetPosition ();
20+ bool Reset ();
21+
22+ /* *
23+ * Will be called periodically whenever the CommandScheduler runs.
24+ */
25+ void Periodic () override ;
26+
27+ /* *
28+ * Will be called periodically whenever the CommandScheduler runs during
29+ * simulation.
30+ */
31+ void SimulationPeriodic () override ;
32+
33+ private:
34+ // Components (e.g. motor controllers and sensors) should generally be
35+ // declared private and exposed only through public methods.
36+
37+ };
38+
39+
You can’t perform that action at this time.
0 commit comments