Skip to content

Curriculum challenge ~ Auto stopping Collector

Alex Schokking edited this page Nov 9, 2024 · 4 revisions

The 2023 robot had a collector to suck in inflatable cubes. But once the collector had a cube it needed to stop intaking so hard or it would pop the cube.

You're going to implement this feature from scratch yourself in this challenge.

The collector is a motor that you can set the power of just like you've been doing for the drive motors this whole time.

Your first step is to implement a basic Subsystem and Commands for this collector mechanism that can run the motors forwards and backwards.

From there, you'll add in the ability to detect that a cube has been intaked and the motor should stop trying so hard.

Creating a new robot project from our template

First create a new git repository using our template as a base: https://github.com/new?template_name=FRCRobotTemplate&template_owner=Team488

Give the repository a name like "My2023Robot"

Then clone this repository locally

Create a new Subsystem for the Collector

Create a new java class CollectorSubsystem that inherits from BaseSubsystem.

It should have a XCANSparkMax motor inside of it that you can make go forward, backwards or stop with functions.

Create intake, outake and stop Commands

Map intake/outtake to reasonable buttons on the gamepad.

Make stop the default command for your new subsystem so the motor will stop when no buttons are pressed.

Test what you've done so far on the 2023 robot

Update intake logic so it doesn't pop cubes

You can read the velocity that the motor is turning. Using this, we can try to detect if we're trying to intake but the motor isn't actually turning very fast anymore (because a cube is stuck in it). Once we've detected that, we can send a weaker power to the motors to keep the cube in the intake but not pop it!

When this is working, you should be able to run your intake command on the real robot and try feeding it a cube and verify the motor stops once the cube is acquired.

Clone this wiki locally