• aditya mehrotra.

scout updates: motor controllers! [updates]

So the motor controllers came in today! 12 Spark Max Motor Controllers from REV robotics! So tonight we definitely aren't getting to wiring all 12 of these controllers, we don't have the encoder wires from DigiKey yet. But we can plug in the software and test some basic things about functionality.



Step 1: http://www.revrobotics.com/rev-11-2158/

Download the spark max client from the link above so we can start running firmware updates and etc. After downloading the client and the drivers, restart your computer, plug the spark max into the USB port, and then run the client.



Step 2: Update the Firmware and when you do you'll get a lovely error that says your device hasn't been configured (duh). Just go to the "Basic" tab and change the CAN ID to "1" and it will work just fine.


Step 3: We're going to start setting the settings of the Spark MAX. Start with making sure the Motor Type is REV NEO Brushless which should automatically set the encoder type and the CPR. We aren't going to touch the limit switches the soft limits or the ramp rates at the moment. We're going to try to set the motor controller to PIDVelocityControl for the motor.


The first thing we are going to do is set the motor controller to brake mode which take the motor to a full stop when zero velocity command is reached. This allows for no drift for the legged system. We don't need to turn off limit switches because we aren't connecting them and it won't affect anything.


Now to activate velocity control: we go here http://www.revrobotics.com/sparkmax-users-manual/#appendix-a and notice that we just need to change the parameter kCtrlType to 3. This may not work considering the control type says it's a read only parameter. So for now we're going to leave it at zero. We really want to use this position control mode that the spark max controller has, it would be ideal.



At the very least, right now we need to change the input to PWM input for now. We can test to see what happens if we just give it PWM control.


So if we look through the REV Robotics Github.

We can go to https://github.com/REVrobotics/CANBridge and notice that there is a CAN Bridge API that may allow us to communicate with the SPARK MAX Controller over straight USB CAN to control it from non-roborio devices. Then maybe we will be able to use https://github.com/REVrobotics/SPARK-MAX-Examples to actually control the SPARKMAX controller via our PC and then the computer on-board the robot, which is a Jetson TX1.


So the first thing we will do, is go to installing https://docs.wpilib.org/en/latest/docs/getting-started/getting-started-frc-control-system/wpilib-setup.html WPILib and VSCode like recommended in the above. I already have GIT installed so we have that. Follow basically EXACTLY these instructions above first. Then we will get the Java API for the Spark Max, and then we will get the REV Robotics CAN Bridge.


Now what we are going to do is Git Clone https://github.com/REVrobotics/CANBridge.git into our downloads folder and follow the instructions to install that! BEFORE YOU DO THIS, I WOULD INSTALL THE JDK-11.0.2 or 11.0.5! Installing the latest JDK will allow the system to BUILD. Do NOT put this into any sub folders or etc, it will NOT work. Make sure to run this as root.


We get the following error:

"""

FAILURE: Build failed with an exception.


* What went wrong:

A problem occurred configuring root project 'CANBridge'.

> Exception thrown while executing model rule: ComponentModelBasePlugin.PluginRules#createSourceTransformTasks(TaskContainer, ModelMap<B

inarySpecInternal>, LanguageTransformContainer, ServiceRegistry)

> Could not create task ':compileCANBridgeLinuxaarch64bionicDebugSharedLibraryCANBridgeLibuvCpp'.

> Could not create task of type 'CCompile'.

> Could not create service of type DefaultCompilationStateCacheFactory.


* 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 fu

ll insights.


* Get more help at https://help.gradle.org


BUILD FAILED in 13s

(base) dhcp-18-20-196-241:CANBridge andromeda$ ./gradlew build


FAILURE: Build failed with an exception.


* What went wrong:

A problem occurred configuring root project 'CANBridge'.

> Exception thrown while executing model rule: ComponentModelBasePlugin.PluginRules#createSourceTransformTasks(TaskContainer, ModelMap<B

inarySpecInternal>, LanguageTransformContainer, ServiceRegistry)

> Could not create task ':compileCANBridgeLinuxaarch64bionicDebugSharedLibraryCANBridgeLibuvCpp'.

> Could not create task of type 'CCompile'.

> Could not create service of type DefaultCompilationStateCacheFactory.


* 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 fu

ll insights.


* Get more help at https://help.gradle.org


BUILD FAILED in 3s

"""


So I took the suggestion of running the command with the --scan command. It says the error resides here:

"""

compiling CANBridge.cpp failed.

In file included from /Users/andromeda/Downloads/CANBridge/src/main/native/cpp/CANBridge.cpp:46:

/Users/andromeda/Downloads/CANBridge/src/main/native/include/rev/Drivers/SerialPort/SerialDriver.h:44:25: error: 'GetName' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]

virtual std::string GetName() const {return "Legacy";}

^

/Users/andromeda/Downloads/CANBridge/src/main/native/include/rev/CANDriver.h:51:25: note: overridden virtual function is here

virtual std::string GetName() const = 0;

^

1 error generated.

"""


After a google it might have to do with this: http://docs.wpilib.org/en/latest/docs/software/wpilib-overview/importing-gradle-project.html



We're going to try this using my old FRC team's number... It also asked me to update my "insiders" version so I did that.


Now it told me "no toolchain found! Run ./gradlew installRoboRioToolchain" so I am doing and trying that. So now we are going to run the build again ./gradlew build. Remember, we are still running everything in the sudo -s (root directory).


AND WE GET BUILD SUCCESSFUL!!! I think we just needed to tell VS Code it was doing something for WPILIB. Either way, this toolchain should be ready to use now.


Now What We'll Do is get the Java API:

http://www.revrobotics.com/sparkmax-software/#java-api just go here and download the latest Java API! All the API Stuff is under the Java Folder.


Now that we have all of this figured out. Tomorrow we will WIRE IN SOME OF THE SPARK MAXs and then repeat this process, cleanly, on the Nvidia Jetson controller and see if we can connect to the Spark Max.


#updates #scout #frc #wow_that_was_complex

5 views0 comments
© copyright 2019 | aditya mehrotra