LEGO Swerve drive #1729
thomasbrus
started this conversation in
Show and tell
Replies: 1 comment 4 replies
-
This looks amazing! Thanks so much for sharing. Do you think it might also work in this kind of configuration where the communication is That's a really nice interface as well. On a somewhat related note, we're working on a dashboard-like interface here too #1708 if you're interested in that sort of thing :) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Four wheel swerve drive
Source code: https://github.com/thomasbrus/lego-swerve-drive
Well this was quite a long project 😮💨. I was set on building a swerve drive after reading this article, and as far as I could tell there weren't many fully working ones on YouTube. At least none of them had simultaneous sidewards and rotational movement.
So my first attempt was building a four wheeled swerve drive. At some point I had all the code working, but in practice it turned out to be pretty difficult to make sure that all four wheels never ever drive in opposing directions turned. It was still working alright but you had to be very careful not to make sudden changes in direction.
The code is in the four-wheel-swerve-drive branch. I built a dashboard in next js and using web bluetooth connected with the two hubs (since I had eight motors I needed two hubs). Then via the Gamepad API connected with the XBOX controller and send the joystick positions to the hubs, which then independently calculated the angle and speed for each two connected swerve drive wheels.
gamepad.mov
4wheel.mov
Two wheel swerve drive
So then I switched to a two wheeled swerve drive with wheels that have less grip, and that worked quite well. The main program is fairly simple, I could reuse a lot of code from the four wheel swerve drive of course. There is also some code that simulates the Pybricks XBOXController class, which made debugging a lot easier.
Cool thing about this one is that it can rotate and move in any direction simultaneously, so mission accomplished 👌
2wheel.mov
Beta Was this translation helpful? Give feedback.
All reactions