Skip to content

FeederFeedCommand

Kujaku223 edited this page Sep 5, 2024 · 2 revisions

FeederFeedCommand

The FeederFeedCommand class inherits from tap::control::Command and is used to control the feeding process of a feeder velocity subsystem (FeederVelocitySubsystem). It uses drivers (drivers) to execute the feed command, ensuring the necessary conditions are met.

Class Declaration

Below is an excerpt from the header file (feeder_feed_command.hpp) showing the class declaration:

Copier le code
namespace control
{
namespace feeder
{
class FeederFeedCommand : public tap::control::Command
{
public:
    /**
     * Initializes the command with the passed-in FeederVelocitySubsystem. Must not be nullptr.
     *
     * @param[in] feeder a pointer to the feeder velocity subsystem that this command will control.
     * @param[in] drivers a pointer to the drivers needed for the command.
     */
    FeederFeedCommand(FeederVelocitySubsystem *const feeder, src::Drivers *drivers);
    
    void initialize() override;
    void execute() override;
    bool isFinished() override;

private:
    FeederVelocitySubsystem *const feeder;
    src::Drivers *drivers;
};
} // namespace feeder
} // namespace control

Analysis

Inheritance: FeederFeedCommand inherits from tap::control::Command, indicating that it is a generic command that can be used within the control system.

Constructor: The constructor takes two parameters:

FeederVelocitySubsystem *const feeder: A constant pointer to the feeder velocity subsystem. src::Drivers *drivers: A pointer to the drivers required for the command. Public Methods:

initialize(): Prepares the initial state necessary to execute the feeding command. execute(): Contains the main logic to execute the feeding command. isFinished(): Returns a boolean indicating if the command is finished.

Private Attributes:

feeder: Stores a pointer to the feeder velocity subsystem.
drivers: Stores a pointer to the drivers used.

Class Implementation

Below is an excerpt from the source file (feeder_feed_command.cpp) showing the implementation of the methods:

Copier le code
FeederFeedCommand::FeederFeedCommand(
    FeederVelocitySubsystem *const feeder,
    src::Drivers *drivers)
    : feeder(feeder),
      drivers(drivers)
{
    if (feeder == nullptr)
    {
        return;
    }
    this->addSubsystemRequirement(dynamic_cast<tap::control::Subsystem *>(feeder));
}

void FeederFeedCommand::initialize() {
    // Initialize feeder velocity subsystem state for feeding operation
}

void FeederFeedCommand::execute() {
    // Execute the feed logic to control the feeder motors based on drivers input
}

bool FeederFeedCommand::isFinished() {
    // Determine if the feeding process is complete
    return false;
}

Analysis

Constructor: Initializes the feeder and drivers members. If the pointer to the feeder subsystem is nullptr, the constructor exits immediately. Otherwise, it adds a subsystem requirement using addSubsystemRequirement.

initialize(): Sets up the initial conditions necessary for the feeding operation, such as initializing motors or sensors.

execute(): Contains the main logic to control the feeder velocity subsystem, based on input from the drivers (drivers).

isFinished(): Checks if the feeding process is complete. In this excerpt, the method always returns false, indicating that the command continues to execute.

Conclusion

The FeederFeedCommand class is designed to manage the feeding process of a feeder velocity subsystem. It inherits from tap::control::Command and uses the subsystem and drivers to perform the feeding operation within a control system.

Clone this wiki locally