Creating Classes with a Timed Robot Errors

So my team is trying to create different classes for a timed based robot. When we tried to build the robot we got a lot of build errors. I was wondering how to use classes in a Timed Based Robot so that everything isn’t on one file.

Here are the errors I get.

Executing task: gradlew build generateVsCodeConfig -Dorg.gradle.java.home=“C:\Users\Public\wpilib\2020\jdk” <

Task :compileFrcUserProgramDebugExecutableFrcUserProgramCpp
In file included from C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:2:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:7:30: error: ISO C++ forbids declaration of ‘setSpeed’ with no type [-fpermissive]
setSpeed(double speed);
^
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:9:9: error: ‘Spark’ does
not name a type
Spark *m_spark;
^~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp: In constructor ‘Motor::Motor(int)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:5: error: ‘m_spark’ was not declared in this scope
m_spark = new Spark(port);
^~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:5: note: suggested alternative: ‘wcspbrk’
m_spark = new Spark(port);
^~~~~~~
wcspbrk
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:19: error: expected type-specifier before ‘Spark’
m_spark = new Spark(port);
^~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp: At global scope:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:9:6: error: prototype for ‘void Motor::setSpeed(double)’ does not match any in class ‘Motor’
void Motor::setSpeed(double speed)
^~~~~
In file included from C:\2020-Season-

Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:2:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:7:9: error: candidate is: int Motor::setSpeed(double)
setSpeed(double speed);
^~~~~~~~

In file included from C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:4:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/DriveTrain.h:10:9: error: ‘DifferentialDrive’ does not name a type
DifferentialDrive *m_robotDrive;
^~~~~~~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp: In constructor ‘DriveTrain::DriveTrain(int, int)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:5: error: ‘m_robotDrive’ was not declared in this scope
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:5: note: suggested
alternative: ‘arcadeDrive’
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~
arcadeDrive
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:24: error: expected type-specifier before ‘DifferentialDrive’
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp: In member function ‘void DriveTrain::arcadeDrive(double, double)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:15:5: error: ‘m_robotDrive’ was not declared in this scope
m_robotDrive->ArcadeDrive(x,y);
^~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:15:5: note: suggested
alternative: ‘arcadeDrive’
m_robotDrive->ArcadeDrive(x,y);
^~~~~~~~~~~~
arcadeDrive

Task :compileFrcUserProgramDebugExecutableFrcUserProgramCpp FAILED

Task :compileFrcUserProgramReleaseExecutableFrcUserProgramCpp
In file included from C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:4:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/DriveTrain.h:10:9: error: ‘DifferentialDrive’ does not name a type
DifferentialDrive *m_robotDrive;
^~~~~~~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp: In constructor ‘DriveTrain::DriveTrain(int, int)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:5: error: ‘m_robotDrive’ was not declared in this scope
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:5: note: suggested
alternative: ‘arcadeDrive’
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~
arcadeDrive
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:11:24: error: expected type-specifier before ‘DifferentialDrive’
m_robotDrive = new DifferentialDrive(m_left, m_right);
^~~~~~~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp: In member function ‘void DriveTrain::arcadeDrive(double, double)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:15:5: error: ‘m_robotDrive’ was not declared in this scope
m_robotDrive->ArcadeDrive(x,y);
^~~~~~~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\DriveTrain.cpp:15:5: note: suggested
alternative: ‘arcadeDrive’
m_robotDrive->ArcadeDrive(x,y);
^~~~~~~~~~~~
arcadeDrive

In file included from C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:2:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:7:30: error: ISO C++ forbids declaration of ‘setSpeed’ with no type [-fpermissive]
setSpeed(double speed);
^
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:9:9: error: ‘Spark’ does
not name a type
Spark *m_spark;
^~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp: In constructor ‘Motor::Motor(int)’:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:5: error: ‘m_spark’ was not declared in this scope
m_spark = new Spark(port);
^~~~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:5: note: suggested alternative: ‘wcspbrk’
m_spark = new Spark(port);
^~~~~~~
wcspbrk
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:6:19: error: expected type-specifier before ‘Spark’
m_spark = new Spark(port);
^~~~~
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp: At global scope:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:9:6: error: prototype for ‘void Motor::setSpeed(double)’ does not match any in class ‘Motor’
void Motor::setSpeed(double speed)
^~~~~
In file included from C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\cpp\Motor.cpp:2:0:
C:\2020-Season-Code\DevelopmentPart1Test\TimedRobotAdvanced\TimedRobotAdvancedTest\src\main\include/Motor.h:7:9: error: candidate is: int Motor::setSpeed(double)
setSpeed(double speed);
^~~~~~~~

Task :compileFrcUserProgramReleaseExecutableFrcUserProgramCpp FAILED
Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileFrcUserProgramDebugExecutableFrcUserProgramCpp).
Check that all your files are saved, then scroll up in this log for more information.
Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileFrcUserProgramReleaseExecutableFrcUserProgramCpp).
Check that all your files are saved, then scroll up in this log for more information.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.


  • What went wrong:
    Execution failed for task ‘:compileFrcUserProgramDebugExecutableFrcUserProgramCpp’.
    Multiple build operations failed.
    C++ compiler failed while compiling Motor.cpp.
    C++ compiler failed while compiling DriveTrain.cpp.
    See the complete log at: file:///C:/2020-Season-Code/DevelopmentPart1Test/TimedRobotAdvanced/TimedRobotAdvancedTest/build/tmp/compileFrcUserProgramDebugExecutableFrcUserProgramCpp/output.txt
    C++ compiler failed while compiling Motor.cpp.
    C++ compiler failed while compiling DriveTrain.cpp.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

2: Task failed with an exception.


  • What went wrong:
    Execution failed for task ‘:compileFrcUserProgramReleaseExecutableFrcUserProgramCpp’.
    Multiple build operations failed.
    C++ compiler failed while compiling DriveTrain.cpp.
    C++ compiler failed while compiling Motor.cpp.
    See the complete log at: file:///C:/2020-Season-Code/DevelopmentPart1Test/TimedRobotAdvanced/TimedRobotAdvancedTest/build/tmp/compileFrcUserProgramReleaseExecutableFrcUserProgramCpp/output.txt
    C++ compiler failed while compiling DriveTrain.cpp.
    C++ compiler failed while compiling Motor.cpp.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

BUILD FAILED in 21s
3 actionable tasks: 2 executed, 1 up-to-date
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

The issue is that DifferentialDrive is in the frc namespace. There used to be a shim that added using namespace frc; but it was removed. You can either add this line yourself, or change all usage of WPILib classes to put frc:: in front, e.g. frc::DifferentialDrive.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.