Need help with RobotBase

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?

It doesn’t look like you ever set the motor speeds for left or right, except in Test(), which doesn’t seem to be called.

Test should be called when I set it to test mode on the driver station as per the bottom bit which frankly terrifies me

Just so you’re aware, allocating stuff with new like that is against best practices in modern C++. Prefer allocating on the stack, or use smart pointers if you need heap allocation (which you almost never need in typical FRC code). You shouldn’t need any pointers for this stuff.

If I were you, I’d use TimedRobot because it handles the consistent process scheduling you’re going to need later anyway.

I know it is. Thats how they do it in the FRC documentation, and it doesn’t work otherwise - strange errors which I can’t debug. C++ is my best language - its just that FRC is broken.

Since you’re inheriting from TimedRobot, you don’t need to implement StartCompetition or EndCompetition at all (these are implemented for you by TimedRobot). Also, you’re overriding the Test() function, where TimedRobot expects you to override TestPeriodic().

Whoops thats a broken code, will edit. Should be RobotBase

Edited because it was inheriting from TimedRobot rather than RobotBase

Link please? That needs to be fixed. Was this based on an example project?

Yes, it was an example. I said that wrong :frowning:

A CTRE example, I might add if it changes anything

Oh, yea… CTRE’s examples have lots of antiquated C++. There’s a tracking issue open to fix them.

WPILib’s examples are better in that regard, but they don’t cover anything vendor-specific (which is unfortunate given how most teams need vendor-specific docs for their hardware).

I tried the more efficient way, but it gives a slew of errors that don’t make much sense.

I can try to make sense of them for you, if you’d like.

Here are the errors:

    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:22:20: error: 'CANMOTOR_RIGHTMASTER' is not a type
        TalonSRX right(CANMOTOR_RIGHTMASTER); // Master-slave pairs. You really, really don't want to run them in the wrong directions!
                        ^~~~~~~~~~~~~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:23:26: error: 'CANMOTOR_RIGHTSLAVE' is not a type
        VictorSPX rightSlave(CANMOTOR_RIGHTSLAVE);
                            ^~~~~~~~~~~~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:24:19: error: 'CANMOTOR_LEFTMASTER' is not a type
        TalonSRX left(CANMOTOR_LEFTMASTER); // This one is for left, the other one is for right. Don't screw up! (no pressure!)
                    ^~~~~~~~~~~~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:25:25: error: 'CANMOTOR_LEFTSLAVE' is not a type
        VictorSPX leftSlave(CANMOTOR_LEFTSLAVE);
                            ^~~~~~~~~~~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp: In member function 'virtual void Robot::RobotInit()':
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:32:9: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::VictorSPX Robot::rightSlave(int)' (did you forget the '()' ?)
            rightSlave -> Follow(*right); // "->" is like "." but for pointers
            ^~~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:32:20: error: base operand of '->' is not a pointer
            rightSlave -> Follow(*right); // "->" is like "." but for pointers
                        ^~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:32:31: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::TalonSRX Robot::right(int)' (did you forget the '()' ?)
            rightSlave -> Follow(*right); // "->" is like "." but for pointers
                                ^~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:33:9: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::VictorSPX Robot::leftSlave(int)' (did you forget the '()' ?)
            leftSlave -> Follow(*left);
            ^~~~~~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:33:19: error: base operand of '->' is not a pointer
            leftSlave -> Follow(*left);
                    ^~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:33:30: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::TalonSRX Robot::left(int)' (did you forget the '()' ?)
            leftSlave -> Follow(*left);
                                ^~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp: In member function 'void Robot::Test()':
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:51:9: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::TalonSRX Robot::right(int)' (did you forget the '()' ?)
            right -> Set(percentOutput, 0.1);
            ^~~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:51:15: error: base operand of '->' is not a pointer
            right -> Set(percentOutput, 0.1);
                ^~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:52:9: error: invalid use of member function 'ctre::phoenix::motorcontrol::can::TalonSRX Robot::left(int)' (did you forget the '()' ?)
            left -> Set(percentOutput, 0.1); // Make both the left and the right move at 10% power.
            ^~~~
    /home/awesome/desk/programs/git/Socialbot/Rio/src/main/cpp/Robot.cpp:52:14: error: base operand of '->' is not a pointer
            left -> Set(percentOutput, 0.1); // Make both the left and the right move at 10% power.
                ^~

And this is the (modified) code that causes them:

    // 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::TimedRobot {
    private:
        std::atomic<bool> m_exit{false};
        TalonSRX right(CANMOTOR_RIGHTMASTER); // Master-slave pairs. You really, really don't want to run them in the wrong directions!
        VictorSPX rightSlave(CANMOTOR_RIGHTSLAVE);
        TalonSRX left(CANMOTOR_LEFTMASTER); // This one is for left, the other one is for right. Don't screw up! (no pressure!)
        VictorSPX leftSlave(CANMOTOR_LEFTSLAVE);
        ControlMode percentOutput = ctre::phoenix::motorcontrol::ControlMode::PercentOutput;

    public:
        void RobotInit(){
            // Called when the robot turns on

            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

Oh yucky preformatted text didn’t work on the errors. It would be nice if CD had formatting more like SO

Use triple backticks for code. You can put “cpp” after the first set of backticks on the same line to enable syntax highlighting.

Oh you can do triple backticks! It says to do 4 spaces

The two most obvious things to me are use . instead of -> when calling functions on non-pointer objects. It looks like you never defined CANMOTOR_RIGHTMASTER and other integer constants, which is what the VictorSPX constructor needs. You can either define those or use integers directly.