|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Recently, I have been dealing with newly written pneumatics code not actuating Cylinders for a gear holder and shifters.
This is what I am trying to do PHP Code:
Please ignore spelling mistakes in comments in code If there is any other mistakes in the code that are not related to Pneumatics, feel free to say so. Robot Code \/ Code:
#include <iostream>
#include <memory>
#include <string>
#include <IterativeRobot.h>
#include <LiveWindow/LiveWindow.h>
#include <SmartDashboard/SendableChooser.h>
#include <SmartDashboard/SmartDashboard.h>
#include "WPILib.h"
#include "CANTalon.h"
class Robot: public frc::IterativeRobot {
public:
//-------------------------------------------------------//
// Other Decerations //
//-------------------------------------------------------//
bool shifter_varable = true;
bool gear_enabled = false;
//-------------------------------------------------------//
// Deceration of Objects //
//-------------------------------------------------------//
Joystick *driver;
Joystick *driverV2;
Joystick *op;
CANTalon *drive_right_a, *drive_right_b, *drive_left_a, *drive_left_b;
CANTalon *intake;
CANTalon *aggitater;
CANTalon *shooter;
CANTalon *climber;
RobotDrive *drive_base;
Compressor *compressor;
DoubleSolenoid *gear;
DoubleSolenoid *shifter;
//WIP \/
//Encoder *shooter_encoder;
Robot() {
//-------------------------------------------------------//
// Asigning Objects to Componints and Electronics //
//-------------------------------------------------------//
driver = new Joystick(0);
op = new Joystick(1);
driverV2 = new Joystick(2);
drive_right_a = new CANTalon(8);
drive_right_b = new CANTalon(9);
drive_left_a = new CANTalon(1);
drive_left_b = new CANTalon(2);
intake = new CANTalon(4);
shooter = new CANTalon(7);
climber = new CANTalon(6);
aggitater = new CANTalon(3);
drive_base = new RobotDrive(drive_right_a, drive_right_b, drive_left_a, drive_left_b);
compressor = new Compressor(0);
gear = new DoubleSolenoid(1, 3);
shifter = new DoubleSolenoid(2, 4);
}
void RobotInit() {
//-------------------------------------------------------//
// Robot vision Code //
//-------------------------------------------------------//
auto cam = frc::CameraServer::GetInstance();
cam->StartAutomaticCapture();
//-------------------------------------------------------//
// Robot Compressor //
//-------------------------------------------------------//
compressor->SetClosedLoopControl(true);
}
void AutonomousInit() override {}
void AutonomousPeriodic() {
drive_right_a->Set(1.0);
}
void TeleopInit() {}
void TeleopPeriodic() {
// drive train; (left joystick; y axis; left drive) (right joystick: y axis; right drive)
drive_base->TankDrive(-driver->GetRawAxis(1), -driver->GetRawAxis(5));
//-------------------------------------------------------//
// Drive Remote //
//-------------------------------------------------------//
//shooter; left bumper
if(driver->GetRawButton(5)) {
shooter->Set(0.60);
}else{
shooter->Set(0.0);
}
//intake in; right trigger
if (driver->GetRawButton(7)) {
intake->Set(-1.0);
}else{
intake->Set(0.0);
}
//aggitator; "B" button
if (driver->GetRawButton(3)){
aggitater->Set(1.0);
}else{
aggitater->Set(0.0);
}
//shifters; "A" button
if (driver->GetRawButton(2)){
if (shifter_varable==true){
shifter->Set(DoubleSolenoid::Value::kReverse);
shifter_varable = false;
}else{
shifter->Set(DoubleSolenoid::Value::kForward);
shifter_varable = true;
}
}
//Gear open close; "Y" button
if (driver->GetRawButton(4)){
if (gear_enabled == true){
gear->Set(DoubleSolenoid::Value::kReverse);
gear_enabled = false;
}else{
gear->Set(DoubleSolenoid::Value::kForward);
gear_enabled = true;
}
}
//-------------------------------------------------------//
// Operator Remote //
//-------------------------------------------------------//
//climber up; right bumper; op
if (op->GetRawAxis(1)){
climber->Set(1.0);
}
}
private:
};
START_ROBOT_CLASS(Robot);
Thx. |
|
#2
|
||||
|
||||
|
Re: Pneumatics code problems.
Pneumatics are run through a manifold.
If this ends up being some thing non related to programming, I will reply if it is. Thx. |
|
#3
|
||||
|
||||
|
Re: Pneumatics code problems.
Code:
bool wasAPressed = false;
// then in in teleopPeriodic...
if (driver->GetRawButton(2)) {
if (!wasAPressed) {
wasAPressed = true;
shifter->Set(shifter->Get() == DoubleSolenoid::Value::kReverse ? DoubleSolenoid::Value::kForward : DoubleSolenoid::Value::kReverse);
}
} else {
wasAPressed = false;
}
Last edited by euhlmann : 08-02-2017 at 23:09. |
|
#4
|
||||
|
||||
|
Re: Pneumatics code problems.
Does the word "Value" in
DoubleSolenoid::Value::kReverse ? represents the value in the Double Solenoid is pluged into the PCM or something else? Thx. |
|
#5
|
||||
|
||||
|
Re: Pneumatics code problems.
Never mind what I said. I found out what it means
Thx. |
|
#6
|
||||
|
||||
|
Re: Pneumatics code problems.
Quote:
Thx. |
|
#7
|
||||
|
||||
|
Re: Pneumatics code problems.
Quote:
|
|
#8
|
||||
|
||||
|
Re: Pneumatics code problems.
Quote:
Code:
bool shifter_varable = true;
//later in teleopPeriodic
if (driver->GetRawButton(2)){
if (!shifter_varable){
shifter_varable = true;
shifter->Set(shifter->Get() ==
DoubleSolenoid::Value::kReverse ?
DoubleSolenoid::Value::kForward :
DoubleSolenoid::Value::kReverse);
}else{
shifter_varable = false;
}
}
|
|
#9
|
||||
|
||||
|
Re: Pneumatics code problems.
Quote:
Code:
// File: Robot.cpp
class Robot: public IterativeRobot {
public:
bool wasAPressed = false; // MEMBER VARIABLE. not local variable
// robotInit, teleopInit, autonomousInit, autonomousPeriodic, etc
void teleopPeriodic() {
if (driver->GetRawButton(2)) {
if (!wasAPressed) {
wasAPressed = true;
shifter->Set(shifter->Get() == DoubleSolenoid::Value::kReverse ? DoubleSolenoid::Value::kForward : DoubleSolenoid::Value::kReverse);
}
} else {
wasAPressed = false;
}
}
}
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|