robotpy / examples

Repository of RobotPy example projects
43 stars 52 forks source link

Added example SwerveControllerCommand #108

Open chaoticthegreat opened 8 months ago

chaoticthegreat commented 8 months ago

Added docstrings manually, for some reason whenever I run the code I get an error saying "No module named commands2" even though I have installed the library but the code looks good.

virtuald commented 8 months ago

If you're getting an error regarding commands2 not being found, then it's not installed for the current python interpreter (python -m pip list will tell you if robotpy-commands-v2 is installed). If it shows in the pip list for the current interpreter, that would be interesting.

Suave101 commented 8 months ago

Could you please place the example within the "tests" folder in the repository? This helps maintain our standard project structure. To help move things along, I've already created a pull request to add the example to the tests folder. You can check it out here. ✨ Would you also be able to format the code using Black, as outlined in our contribution guide? This helps keep our codebase consistent and readable for everyone. You can format your code with black with this took I like to use called Black Playground

chaoticthegreat commented 8 months ago

Thank you for the pull request, I have finally got commands2 to work, and have fixed the issues outlined. Just to recap, I have lowercased the folders and files, formatted all the code with black using Black Playground, adjusted robot.py for TimedCommandRobot instead of TimedRobot, added a few docstrings and changed a few into comments.

auscompgeek commented 8 months ago

This PR is still not formatted with black. I would highly recommend setting up black in your IDE.

The file paths still need to be fixed to lowercase.

chaoticthegreat commented 8 months ago

@auscompgeek Sorry about the files being renamed, git was being weird. I did paste all my files into the black playground, but I have now ran it in my IDE.

virtuald commented 8 months ago

I wouldn't recommend copy/pasting into the black playground... that's way too much effort.

Just configure vscode to use black, and it will install it for you. Or, pip install black, then run it from the command line. Either of those will be much less error prone.

chaoticthegreat commented 8 months ago

Ye did that.

chaoticthegreat commented 8 months ago

Within drivesubsystems.py and swervemodule.py I can't import constants. How would I fix this? Most solution just say to modify sys.path but the robotpy porting guidelines says not to.

auscompgeek commented 8 months ago

Within drivesubsystems.py and swervemodule.py I can't import constants.

Why not? It should work fine.

chaoticthegreat commented 8 months ago

No idea, it just gives me a Module Not Found error. For reference I'm using miniconda as my python interpreter. The way I'm testing my code for errors as for now is just having a separate repo where I can run the workflow from this one, but its not great.

chaoticthegreat commented 8 months ago

@auscompgeek I fixed most of the errors, but I get an error saying that commands2 has no attribute named Swerve4ControllerCommand, when the docs clearly says it does. I get this error from running the workflow file from this repo.