robotpy / examples

Repository of RobotPy example projects
45 stars 53 forks source link

Add SwerveBot example #98

Closed megarubber closed 10 months ago

megarubber commented 10 months ago

Issue #49

Add the SwerveBot example. I added a constants.py file to remove redundant imports, since the original Java example doesn't have a Constants.java.

auscompgeek commented 10 months ago

I added a constants.py file to remove redundant imports

I'm not sure I understand, what would be redundant?

megarubber commented 10 months ago

I added a constants.py file to remove redundant imports

I'm not sure I understand, what would be redundant?

They are mutual top-level imports, because drivetrain.py imports swervemodule.py, and vice versa. I created this file to avoid errors like this: AttributeError: module 'drivetrain' has no attribute 'kModuleMaxAngularVelocity'

But now, I guess that can be fixed with: from drivetrain import kModuleMaxAngularVelocity

auscompgeek commented 10 months ago

Oh, you're trying to break an import cycle. Hmm. It seems odd to me that those constants would depend on each other in the example, since that doesn't seem like a physical constraint of real robots.

It looks like in the C++ example they're simply separate constants. Let's do that instead of introducing a constants module.