TrapezoidProfileSubsystem

class commands2.TrapezoidProfileSubsystem(*arg, **kwargs)[source]

Bases: Subsystem

A subsystem that generates and runs trapezoidal motion profiles automatically. The user specifies how to use the current state of the motion profile by overriding the useState method.

Creates a new TrapezoidProfileSubsystem.

Parameters:
  • constraints – The constraints (maximum velocity and acceleration) for the profiles.

  • initial_position – The initial position of the controlled mechanism when the subsystem is constructed.

  • period – The period of the main robot loop, in seconds.

disable()[source]

Disable the TrapezoidProfileSubsystem’s output.

enable()[source]

Enable the TrapezoidProfileSubsystem’s output.

periodic()[source]

Executes the TrapezoidProfileSubsystem logic during each periodic update.

This method is called synchronously from the subsystem’s periodic() method.

setGoal(goal)[source]

Sets the goal state for the subsystem. Goal velocity assumed to be zero.

Parameters:

goal – The goal position for the subsystem’s motion profile. The goal can either be a TrapezoidProfile.State or float. If float is provided, the assumed velocity for the goal will be 0.

useState(state)[source]

Users should override this to consume the current state of the motion profile.

Parameters:

state – The current state of the motion profile.