Calling subsystem methods from another subsystem's periodic() method

You could give the Drive subsystem a reference to the Vision subsystem through its constructor (presumably in RobotContainer).

It’s also possible that the Vision subsystem should not be…a subsystem. Calling it a “Subsystem” can hide the true meaning behind a name/symbol; the Command robot framework uses this term to mean:

If the Vision class isn’t writing changes out to the hardware it interfaces with, it might not need to be a subsystem, just a plain-old-Java-object, and thus not subject to the subsystem/command structure. In that case, it wouldn’t be odd to pass a reference to Vision in through Drive’s constructor.

It sounds like Drive currently owns the pose, and you’d like to update it with additional sensor information from Vision. If so, it may be appropriate to do this from Drive’s periodic() method, assuming the “several conditions” are not dependent on the other subsystems of the robot.

3 Likes