Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mechanism2d example. #52

Merged
merged 5 commits into from
Oct 2, 2022
Merged

Added mechanism2d example. #52

merged 5 commits into from
Oct 2, 2022

Conversation

BerkeSinanYetkin
Copy link
Contributor

@BerkeSinanYetkin BerkeSinanYetkin commented Oct 1, 2022

The title is pretty much self explanatory. I didn't need a physics.py file to test it since the simulation GUI takes care of encoders and analog inputs.

#49

@BerkeSinanYetkin
Copy link
Contributor Author

Why is the macos test absurdly slow?

mechanism2d/robot.py Outdated Show resolved Hide resolved
self.joystick = wpilib.Joystick(0)

self.elevator = wpilib.MechanismLigament2d
self.wrist = wpilib.MechanismLigament2d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to what's happening here. Shouldn't the right hand side be constructing a MechanismLigament2d, rather than a reference to the type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have a init() function, it is referenced rather than constructed in the Java examples too. I'm not sure why they decided to do it this way, maybe it's something to do with how Java -which i have no experience in-, handles variables? I deleted those lines and it seems to be working fine.

Copy link
Member

@auscompgeek auscompgeek Oct 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing the equivalent of this in Java would be a compile-time type error, if my understanding of this code is correct, so I'm not sure I understand what you're saying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 36&37

What does those lines do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

36 and 37 declare variables in the Java example, which are later assigned to on lines 50/51. That isn't needed in python.

mechanism2d/robot.py Outdated Show resolved Hide resolved
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
mechanism2d/robot.py Outdated Show resolved Hide resolved
@BerkeSinanYetkin
Copy link
Contributor Author

Anything else you two want me to add?

@virtuald virtuald merged commit de3a7a8 into robotpy:main Oct 2, 2022
@virtuald
Copy link
Member

virtuald commented Oct 2, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants