mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal] Add a unified PCM object (#3331)
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
using namespace HatchConstants;
|
||||
|
||||
HatchSubsystem::HatchSubsystem()
|
||||
: m_hatchSolenoid{kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
|
||||
: m_hatchSolenoid{m_pneumaticsModule, kHatchSolenoidPorts[0],
|
||||
kHatchSolenoidPorts[1]} {}
|
||||
|
||||
void HatchSubsystem::GrabHatch() {
|
||||
m_hatchSolenoid.Set(frc::DoubleSolenoid::kForward);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <frc/DoubleSolenoid.h>
|
||||
#include <frc/PneumaticsControlModule.h>
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
|
||||
#include "Constants.h"
|
||||
@@ -28,5 +29,6 @@ class HatchSubsystem : public frc2::SubsystemBase {
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
frc::PneumaticsControlModule m_pneumaticsModule;
|
||||
frc::DoubleSolenoid m_hatchSolenoid;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
using namespace HatchConstants;
|
||||
|
||||
HatchSubsystem::HatchSubsystem()
|
||||
: m_hatchSolenoid{kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
|
||||
: m_hatchSolenoid{m_pneumaticsModule, kHatchSolenoidPorts[0],
|
||||
kHatchSolenoidPorts[1]} {}
|
||||
|
||||
void HatchSubsystem::GrabHatch() {
|
||||
m_hatchSolenoid.Set(frc::DoubleSolenoid::kForward);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <frc/DoubleSolenoid.h>
|
||||
#include <frc/PneumaticsControlModule.h>
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
|
||||
#include "Constants.h"
|
||||
@@ -28,5 +29,6 @@ class HatchSubsystem : public frc2::SubsystemBase {
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
frc::PneumaticsControlModule m_pneumaticsModule;
|
||||
frc::DoubleSolenoid m_hatchSolenoid;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <frc/livewindow/LiveWindow.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
|
||||
#include "PneumaticsModule.h"
|
||||
|
||||
DriveTrain Robot::drivetrain;
|
||||
Pivot Robot::pivot;
|
||||
Collector Robot::collector;
|
||||
@@ -81,6 +83,11 @@ void Robot::Log() {
|
||||
drivetrain.GetRightEncoder().GetDistance());
|
||||
}
|
||||
|
||||
frc::PneumaticsControlModule* pac::GetPneumatics() {
|
||||
static frc::PneumaticsControlModule pcm;
|
||||
return &pcm;
|
||||
}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
|
||||
#include "PneumaticsModule.h"
|
||||
|
||||
Pneumatics::Pneumatics() : frc::Subsystem("Pneumatics") {
|
||||
AddChild("Pressure Sensor", m_pressureSensor);
|
||||
}
|
||||
@@ -16,7 +18,7 @@ void Pneumatics::InitDefaultCommand() {
|
||||
|
||||
void Pneumatics::Start() {
|
||||
#ifndef SIMULATION
|
||||
m_compressor.Start();
|
||||
pac::GetPneumatics()->SetClosedLoopControl(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/PneumaticsControlModule.h>
|
||||
|
||||
namespace pac {
|
||||
frc::PneumaticsControlModule* GetPneumatics();
|
||||
} // namespace pac
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/PneumaticsControlModule.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/commands/Command.h>
|
||||
#include <frc/smartdashboard/SendableChooser.h>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <frc/commands/Subsystem.h>
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
|
||||
#include "PneumaticsModule.h"
|
||||
|
||||
/**
|
||||
* The Collector subsystem has one motor for the rollers, a limit switch for
|
||||
* ball
|
||||
@@ -68,6 +70,6 @@ class Collector : public frc::Subsystem {
|
||||
// Subsystem devices
|
||||
frc::PWMSparkMax m_rollerMotor{6};
|
||||
frc::DigitalInput m_ballDetector{10};
|
||||
frc::Solenoid m_piston{1};
|
||||
frc::Solenoid m_piston{pac::GetPneumatics(), 1};
|
||||
frc::DigitalInput m_openDetector{6};
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <frc/AnalogInput.h>
|
||||
#include <frc/Compressor.h>
|
||||
#include <frc/commands/Subsystem.h>
|
||||
|
||||
/**
|
||||
@@ -42,9 +41,5 @@ class Pneumatics : public frc::Subsystem {
|
||||
private:
|
||||
frc::AnalogInput m_pressureSensor{3};
|
||||
|
||||
#ifndef SIMULATION
|
||||
frc::Compressor m_compressor{1}; // TODO: (1, 14, 1, 8);
|
||||
#endif
|
||||
|
||||
static constexpr double kMaxPressure = 2.55;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <frc/Solenoid.h>
|
||||
#include <frc/commands/Subsystem.h>
|
||||
|
||||
#include "PneumaticsModule.h"
|
||||
|
||||
/**
|
||||
* The Shooter subsystem handles shooting. The mechanism for shooting is
|
||||
* slightly complicated because it has to pneumatic cylinders for shooting, and
|
||||
@@ -114,9 +116,9 @@ class Shooter : public frc::Subsystem {
|
||||
|
||||
private:
|
||||
// Devices
|
||||
frc::DoubleSolenoid m_piston1{3, 4};
|
||||
frc::DoubleSolenoid m_piston2{5, 6};
|
||||
frc::Solenoid m_latchPiston{1, 2};
|
||||
frc::DoubleSolenoid m_piston1{pac::GetPneumatics(), 3, 4};
|
||||
frc::DoubleSolenoid m_piston2{pac::GetPneumatics(), 5, 6};
|
||||
frc::Solenoid m_latchPiston{pac::GetPneumatics(), 2};
|
||||
frc::DigitalInput m_piston1ReedSwitchFront{9};
|
||||
frc::DigitalInput m_piston1ReedSwitchBack{11};
|
||||
frc::DigitalInput m_hotGoalSensor{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <frc/DoubleSolenoid.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/PneumaticsControlModule.h>
|
||||
#include <frc/Solenoid.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
|
||||
@@ -53,11 +54,13 @@ class Robot : public frc::TimedRobot {
|
||||
private:
|
||||
frc::Joystick m_stick{0};
|
||||
|
||||
frc::PneumaticsControlModule m_pneumaticsModule;
|
||||
|
||||
// Solenoid corresponds to a single solenoid.
|
||||
frc::Solenoid m_solenoid{0};
|
||||
frc::Solenoid m_solenoid{m_pneumaticsModule, 0};
|
||||
|
||||
// DoubleSolenoid corresponds to a double solenoid.
|
||||
frc::DoubleSolenoid m_doubleSolenoid{1, 2};
|
||||
frc::DoubleSolenoid m_doubleSolenoid{m_pneumaticsModule, 1, 2};
|
||||
|
||||
static constexpr int kSolenoidButton = 1;
|
||||
static constexpr int kDoubleSolenoidForward = 2;
|
||||
|
||||
Reference in New Issue
Block a user