Skip to content

DoubleFeederSubsystem

Kujaku223 edited this page Sep 2, 2024 · 2 revisions

DoubleFeederAutoFeedCommand

The DoubleFeederAutoFeedCommand class inherits from tap::control::Command and is used to control the automatic feeding operation for a double feeder system. It utilizes a double feeder subsystem (DoubleFeederSubsystem) and drivers (drivers) to manage the feeding behavior of the system.

Class Declaration

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

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

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

Analysis

Inheritance: DoubleAutoFeedCommand inherits from tap::control::Command, which means it is a generic command that can be executed within the control system.

Constructor: The constructor takes two parameters:

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

initialize(): Initializes the state of the system before executing the command. execute(): Contains the main logic for the command, executed every time the command is active. isFinished(): Returns a boolean indicating whether the command has finished. Private Attributes:

feeder: Stores a pointer to the double feeder subsystem. / drivers: Stores a pointer to the drivers used.

Class Implementation

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

Copier le code
DoubleAutoFeedCommand::DoubleAutoFeedCommand(
    feeder::DoubleFeederSubsystem *const feeder,
    src::Drivers *drivers)
    : feeder(feeder),
      drivers(drivers)
{
    if (feeder == nullptr)
    {
        reportError("Feeder subsystem cannot be nullptr.");
    }
}

void DoubleAutoFeedCommand::initialize()
{
    // Initialization logic here
}

void DoubleAutoFeedCommand::execute()
{
    // Execution logic to control the feeder motors based on drivers input
}

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

Analysis

Constructor: Verifies that the feeder pointer is not nullptr and initializes the members feeder and drivers. If there is an issue, it reports an error.

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

execute(): Contains the main logic to control the double feeder 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 DoubleFeederAutoFeedCommand class is designed to manage the automatic feeding process of a double feeder system. It inherits from tap::control::Command and uses the double feeder subsystem and drivers to perform the auto-feed operation based on the system's state and input conditions.