Coding a robot in c++, trying to implement my own drive type with the RobotBase. Attempting to control two Victors and two Talons. The Victors are following the Talons.
However, when I compile, it doesn’t do anything.
// 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.
// #include "Robot.h" For more control over my own code, I just copy-pasted the code from Robot.h into this code. So don't include it.
#include <frc/DriverStation.h>
#include <frc/livewindow/LiveWindow.h>
#include <frc/shuffleboard/Shuffleboard.h>
#include <hal/DriverStation.h>
#include <networktables/NetworkTable.h>
#include <frc/TimedRobot.h>
#include <atomic>
#include <ctre/Phoenix.h>
#include "devices.h"
// Devices.h is a definitions file for CAN id numbers. Angle brackets "<>" are for project-level includes, double quotes are for sibling includes.
class Robot : public frc::RobotBase {
private:
std::atomic<bool> m_exit{false};
TalonSRX *right; // Master-slave pairs. You really, really don't want to run them in the wrong directions!
VictorSPX *rightSlave;
TalonSRX *left; // This one is for left, the other one is for right. Don't screw up! (no pressure!)
VictorSPX *leftSlave;
ControlMode percentOutput = ctre::phoenix::motorcontrol::ControlMode::PercentOutput;
public:
void RobotInit(){
// Called when the robot turns on
right = new TalonSRX(CANMOTOR_RIGHTMASTER);
rightSlave = new VictorSPX(CANMOTOR_RIGHTSLAVE);
left = new TalonSRX(CANMOTOR_RIGHTMASTER);
leftSlave = new VictorSPX(CANMOTOR_RIGHTSLAVE);
rightSlave -> Follow(*right); // "->" is like "." but for pointers
leftSlave -> Follow(*left);
// Oh, how I love c++.
}
void Teleop(){
// This will quite probabalistically break something.
}
void Disabled(){
}
void Autonomous(){
}
void Test(){
right -> Set(percentOutput, 0.1);
left -> Set(percentOutput, 0.1); // Make both the left and the right move at 10% power.
}
void StartCompetition();
void EndCompetition();
};
void Robot::StartCompetition() {
auto& lw = *frc::LiveWindow::GetInstance();
RobotInit();
// Tell the DS that the robot is ready to be enabled
HAL_ObserveUserProgramStarting();
while (!m_exit) {
if (IsDisabled()) {
m_ds.InDisabled(true);
Disabled();
m_ds.InDisabled(false);
while (IsDisabled()) {
m_ds.WaitForData();
}
} else if (IsAutonomous()) {
m_ds.InAutonomous(true);
Autonomous();
m_ds.InAutonomous(false);
while (IsAutonomousEnabled()) {
m_ds.WaitForData();
}
} else if (IsTest()) {
lw.SetEnabled(true);
frc::Shuffleboard::EnableActuatorWidgets();
m_ds.InTest(true);
Test();
m_ds.InTest(false);
while (IsTest() && IsEnabled()) {
m_ds.WaitForData();
}
lw.SetEnabled(false);
frc::Shuffleboard::DisableActuatorWidgets();
} else {
m_ds.InOperatorControl(true);
Teleop();
m_ds.InOperatorControl(false);
while (IsOperatorControlEnabled()) {
m_ds.WaitForData();
}
}
}
}
void Robot::EndCompetition() {
m_exit = true;
}
// Frankly, no idea.
#ifndef RUNNING_FRC_TESTS
int main() {
return frc::StartRobot<Robot>();
}
#endif
Why does this not make the robot move?