1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
intake.h
Go to the documentation of this file.
1#pragma once
2#include "command/runCommand.h"
3#include "command/subsystem.h"
4#include "pros/motors.hpp"
5
11class Intake : public Subsystem {
12private:
17 pros::Motor intakeMotor;
18
19public:
25 explicit Intake(pros::Motor intake_motor) : intakeMotor(std::move(intake_motor)) {}
26
32 void periodic() override {
33 // EX: debugging tasks
34 std::cout << "Intake speed: " << intakeMotor.get_actual_velocity() << std::endl;
35 // Also:
36 // Updating PID for something like a flywheel or odometry for a drivetrain subsystem
37 }
38
44 void setPct(const double pct) {
45 // Scale [-1, 1] to [-12000 mV, 12000 mV]
46 this->intakeMotor.move_voltage(static_cast<std::int32_t>(pct * 12000.0));
47 }
48
56 RunCommand *pctCommand(const double pct) {
57 // Create a new RunCommand
58 // The lambda body is called at every update, in this case setting the intake percentage
59 return new RunCommand(
60 [this, pct]() // Capture "this" and the percentage request
61 {
62 this->setPct(pct); // Set the percentage of the intake to the request
63 },
64 {this} // Add "this", the pointer to this subsystem that is currently running.
65 // It is important to ensure that all subsystems that are being utilized in a command are properly
66 // Freed to allow that command to run.
67 );
68 }
69
70 ~Intake() override = default;
71};
void setPct(const double pct)
This command moves the intake at a certain voltage potential requested as a percentage [-1,...
Definition intake.h:44
~Intake() override=default
void periodic() override
Periodic runs every frame (10ms) by the command scheduler after the subsystem is registered.
Definition intake.h:32
Intake(pros::Motor intake_motor)
Definition intake.h:25
RunCommand * pctCommand(const double pct)
Example way to create commands from class This is useful for simple commands or default commands.
Definition intake.h:56
pros::Motor intakeMotor
Definition intake.h:17