Galactic Search Trajectory Tracking Code Not Working

We have working trajectory tracking drive code that uses pathweaver and works with are limelight tracking solution (to find the Power Cells), however, we needed to add code to move down the rollers of our intake on our bot (this is the autocross command). When we added this however, it now will just move forward and backwards to move down our intake, but not run the path. Can someone look into this code to figure out what is happening? Thank you! Code: https://drive.google.com/file/d/1ygYtZYp_nztj6_v1QGzeVNwT9wqpV8PL/view?usp=sharing

1 Like

You have TrajDrive, DriveTrain, and DriveSubsystem as three separate subsystems. AutoCross requires the DriveSubsystem while AutoCommand (Your trajectory following command) requires TrajDrive, but that uses the DriveTrain subsystem to drive the motors that are running the trajectory?

For the most part in a Command-Based robot, a coded subsystem normally corresponds to the same physical hardware it is controlling. Having multiple subsystems control the same hardware is usually not advised as it can lead to issues where multiple subsystems are sending separate commands to the same hardware at the same time, which will result in erratic behavior. Or in your case, you have multiple commands using different subsystem, which make sit confusing as to what command is using which subsystem.

The first thing I would do is to merge all your ‘drivetrain’ functionality into a single Subsystem. For TrajDrive, you can have it extend SquentialCommandGroup instead of SubsystemBase to turn it into a command and change DoTrajDrive to be TrajDrive (Turn it into the constructor of the command). Then every time you call return command.andThen(() -> drive.tankDriveVolts(0, 0)); in DoTrajDrive to use addCommand(command.andThen(() -> drive.tankDriveVolts(0, 0))) instead. This way, when you schedule this new command, it will run the constructed trajectory commands that are read from your trajectory *.json files.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.