Looking for some help getting the new Rev Robotics Spark Max motor controller, connected to the brushless motor.
We have the following code in a subsystem, wheelsubsystem
speedMax.reset(new rev::CANSparkMax:CANSparkMax(10));
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
// speedMax.reset(new WPI_TalonSRX(0));
I have modeled the creation of a spark max in a similar fashion as a Talon, but I can’t seem to get the motor controller created.
I believe the vscode rev spark dependencies are installed correctly and I have tried a few things with namespaces etc, but I am missing something.
Any ideas? Any hints from any of the beta teams that actually have gotten these motor controllers to work? I am confident that if I can get the motor object created, the rest will fall into place.
Many thanks.
however, the VSCode IDE says…
identifier “CANSparkMax” is undefined
class std::shared_ptr<>
I have made some headway,
- you must include the rev robotics include file and after doing this I am no longer getting undefined messages.
However the CANSparkMax must have both a device id and a motor type as part of its parameter, but I have not be able to determine what the Motortype enum parameter should be. With only one parameter I get…
Executing task: gradlew build -Dorg.gradle.java.home=“C:\Users\Public\frc2019\jdk” <
Task :compileFrcUserProgramReleaseExecutableFrcUserProgramCpp
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp: In constructor ‘WheelSubsystem::WheelSubsystem()’:
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp:23:45: error: no matching function for call to ‘rev::CANSparkMax::CANSparkMax(int)’
speedMax11.reset(new rev::CANSparkMax(11));
^
In file included from C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\include/Subsystems/WheelSubsystem.h:17:0,
from C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp:12:
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\build\tmp\expandedArchives\SparkMax-cpp-1.0.24-headers.zip_315b3de7e270a0c0d9dce78c6b504185/rev/CANSparkMax.h:94:14: note: candidate: rev::CANSparkMax::CANSparkMax(int, rev::CANSparkMaxLowLevel::MotorType)
explicit CANSparkMax(int deviceID, MotorType type);
^~~~~~~~~~~
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\build\tmp\expandedArchives\SparkMax-cpp-1.0.24-headers.zip_315b3de7e270a0c0d9dce78c6b504185/rev/CANSparkMax.h:94:14: note: candidate expects 2 arguments, 1 provided
Task :compileFrcUserProgramDebugExecutableFrcUserProgramCpp FAILED
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp: In constructor ‘WheelSubsystem::WheelSubsystem()’:
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp:23:45: error: no matching function for call to ‘rev::CANSparkMax::CANSparkMax(int)’
speedMax11.reset(new rev::CANSparkMax(11));
^
In file included from C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\include/Subsystems/WheelSubsystem.h:17:0,
from C:\Users\Team772\Documents\VSCode\SparkMaxRB3\src\main\cpp\Subsystems\WheelSubsystem.cpp:12:
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\build\tmp\expandedArchives\SparkMax-cpp-1.0.24-headers.zip_315b3de7e270a0c0d9dce78c6b504185/rev/CANSparkMax.h:94:14: note: candidate: rev::CANSparkMax::CANSparkMax(int, rev::CANSparkMaxLowLevel::MotorType)
explicit CANSparkMax(int deviceID, MotorType type);
^~~~~~~~~~~
C:\Users\Team772\Documents\VSCode\SparkMaxRB3\build\tmp\expandedArchives\SparkMax-cpp-1.0.24-headers.zip_315b3de7e270a0c0d9dce78c6b504185/rev/CANSparkMax.h:94:14: note: candidate expects 2 arguments, 1 provided
Task :compileFrcUserProgramReleaseExecutableFrcUserProgramCpp FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
- What went wrong:
Execution failed for task ‘:compileFrcUserProgramDebugExecutableFrcUserProgramCpp’.
A build operation failed.
C++ compiler failed while compiling WheelSubsystem.cpp.
See the complete log at: file:///C:/Users/Team772/Documents/VSCode/SparkMaxRB3/build/tmp/compileFrcUserProgramDebugExecutableFrcUserProgramCpp/output.txt
- 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’.
A build operation failed.
C++ compiler failed while compiling WheelSubsystem.cpp.
See the complete log at: file:///C:/Users/Team772/Documents/VSCode/SparkMaxRB3/build/tmp/compileFrcUserProgramReleaseExecutableFrcUserProgramCpp/output.txt
-
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.
==============================================================================
-
Get more help at https://help.gradle.org
BUILD FAILED in 27s
I am reaching out to REV for assistance, and if they could comment to help everyone out that would be great.
The enum type is ‘MotorType’ and can be accessed as:
rev::CANSparkMax::MotorType::kBrushless
So you can do something like below:
rev::CANSparkMax(11, rev::CANSparkMax::MotorType::kBrushless)
Thanks will, just as you were typing, I also made the same headway, for everyone, below is a spark, as well as a “poorly named” talon constuctor for comparison.
md
#include “ctre/Phoenix.h”
#include “rev/CANSparkMax.h”
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=INCLUDES
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=INCLUDES
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS
WheelSubsystem::WheelSubsystem() : frc::Subsystem(“WheelSubsystem”) {
speedMax11.reset(new rev::CANSparkMax(11,rev::CANSparkMaxLowLevel::MotorType::kBrushless));
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
speedMax10.reset(new WPI_TalonSRX(10));
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
}
Glad you got it working! Also you can simply use CANSparkMax
instead of CANSparkMaxLowLevel
speedMax11.reset(new rev::CANSparkMax(11, rev::CANSparkMax::MotorType::kBrushless));