1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
Intake Class Reference

#include <intake.h>

+ Inheritance diagram for Intake:

Public Member Functions

 Intake (pros::Motor intake_motor)
 
void periodic () override
 Periodic runs every frame (10ms) by the command scheduler after the subsystem is registered.
 
void setPct (const double pct)
 This command moves the intake at a certain voltage potential requested as a percentage [-1, 1].
 
RunCommand * pctCommand (const double pct)
 Example way to create commands from class This is useful for simple commands or default commands.
 
 ~Intake () override=default
 

Private Attributes

pros::Motor intakeMotor
 

Detailed Description

Intake subsystem

Allows controlling the percentage power of the intake subsystem

Definition at line 11 of file intake.h.

Constructor & Destructor Documentation

◆ Intake()

Intake::Intake ( pros::Motor intake_motor)
inlineexplicit

Construct a new Intake subsystem with pro::Motor object

Parameters
intake_motor

Definition at line 25 of file intake.h.

25: intakeMotor(std::move(intake_motor)) {}
pros::Motor intakeMotor
Definition intake.h:17

References intakeMotor.

◆ ~Intake()

Intake::~Intake ( )
overridedefault

Member Function Documentation

◆ pctCommand()

RunCommand * Intake::pctCommand ( const double pct)
inline

Example way to create commands from class This is useful for simple commands or default commands.

Parameters
pctPercentage Desired for this command
Returns
Command pointer to a RunCommand that moves the intake

Definition at line 56 of file intake.h.

56 {
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 }
void setPct(const double pct)
This command moves the intake at a certain voltage potential requested as a percentage [-1,...
Definition intake.h:44

References setPct().

◆ periodic()

void Intake::periodic ( )
inlineoverride

Periodic runs every frame (10ms) by the command scheduler after the subsystem is registered.

Note
Periodic represents useful tasks such as PID that need to run every frame, but the target is only set once.

Definition at line 32 of file intake.h.

32 {
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 }

References intakeMotor.

◆ setPct()

void Intake::setPct ( const double pct)
inline

This command moves the intake at a certain voltage potential requested as a percentage [-1, 1].

Parameters
pctPercent voltage for the intake in the range [-1, 1]

Definition at line 44 of file intake.h.

44 {
45 // Scale [-1, 1] to [-12000 mV, 12000 mV]
46 this->intakeMotor.move_voltage(static_cast<std::int32_t>(pct * 12000.0));
47 }

Referenced by pctCommand().

Member Data Documentation

◆ intakeMotor

pros::Motor Intake::intakeMotor
private

Store the necessary resources for this subsystem in the private section. Member methods control these resources.

Definition at line 17 of file intake.h.

Referenced by Intake(), and periodic().


The documentation for this class was generated from the following file: