Arm

We will learn how to program an Arm!

Intro

At the end of this tutorial you will have an Arm that will work in both real life and simulation with the same code!

Simulation

Real Life

Details

This Arm will be using the following hardware specs and control details

  • SparkMax controlling the Arm

  • 12:1 GearBox on the Arm

  • Pressing A will make the Arm go to -5deg

  • Pressing B will make the Arm go to 15deg

  • Pressing X will make the Arm go up.

  • Pressing Y will make the Arm go down.

Lets create a WPILib Command-Based Project!

Setup our Command-Based Project

Here we will follow WPILib's tutorial on how to create a Command-Based project.

Bring up the Visual Studio Code command palette with Ctrl+Shift+P. Then, type “WPILib” into the prompt. Since all WPILib commands start with “WPILib”, this will bring up the list of WPILib-specific VS Code commands. Now, select the “Create a new project” command:

This will bring up the “New Project Creator Window:”

  1. Click on Select a project type (Example or Template)

  2. Select Template then Java then Command Robot

  3. Click on Select a new project folder and select a folder to store your robot project in.

  4. Fill in Project Name with the name of your robot code project.

  5. Enter your Team Number in so you can deploy to your robot.

  6. Be sure to check Enable Desktop Support so we can run simulations!

If you followed these instructions it should look something like whats filled out below.

Congratulations! You now have a Command Based robot project!

Install YAMS!

Click on the WPILib logo on the left pane. Scroll down to Yet Another Mechanism System and click Install!

Congratulations you have now installed YAMS! 🎉

Lets make an Arm move!

1

Create a SmartMotorControllerConfig

We are going to start by configuring out motor controller.

2

Create our motor controller

To control our Arm motor we will create the vendor motor controller object.

First we install REVLib by clicking on the WPILib logo in the left bar.

Now we add it to the ExampleSubsystem.java

3

Create our SmartMotorController

Our SmartMotorController will easily configure and interface with the vendor motor controller object.

4

Create and Configure our Arm

Our Arm will easily configure the SmartMotorController and create a simple and intuitive interface.

5

Create Commands with our Arm

We use the Arm class as a interface to create commands!

6

Bind buttons to our Arm

We bind buttons to use the Commands from our Arm

7

Simulate our Arm!

We can use our Arm in simulation, with the exact same code that will control the real robot!

Connect an Xbox controller to your system and drag and drop from System Joysticks to Joystick[0]

Open up the Simulated mechanism with NetworkTables -> SmartDashboard -> Arm -> mechanism

Resize Arm/mechanism to your liking

Press Teleoperated in Robot State then you can use your controller like its controlling the real robot!

Congratulations on successfully programming your Arm!! 🎉🎉

Examples can be found in the YAMS repository on GitHub.

https://github.com/Yet-Another-Software-Suite/YAMS/tree/master/examples/simple_arm

Last updated