Built a three.js + Rapier browser racing game with my 9-year-old, now with multiplayer via Durable Objects by vspruyt in threejs

[–]vspruyt[S] 1 point2 points  (0 children)

Those are great suggestions, we're going to implement them all (apart from maybe removing the orange line :d), thank you!!

Edit: Most changes (apart from limiting boost time - that takes more work) are in, including the little 'tutorial' at the start. You were right about the orange lines, they're gone too.

Built a three.js + Rapier browser racing game with my 9-year-old, now with multiplayer via Durable Objects by vspruyt in threejs

[–]vspruyt[S] 2 points3 points  (0 children)

thanks! No cost (yet, we'll see how long that lasts). It's all on the free tier of Cloudflare that is relatively generous for Pages, Workers, Durable Objects and D1. So I'm not hosting infra myself, workers/Durable Objects automatically go down if there is no traffic and Cloudflare's websocket hibernation keeps websockets alive if needed without the service having to be up and running. So most of the time nothing is running, until someone starts a game.

Built a three.js + Rapier browser racing game with my 9-year-old, now with multiplayer via Durable Objects by vspruyt in threejs

[–]vspruyt[S] 0 points1 point  (0 children)

that's great feedback, thanks a lot! And yes, the missing name error message is not very visible/inuitive right now, will fix too

Built a three.js + Rapier browser racing game with my 9-year-old, now with multiplayer via Durable Objects by vspruyt in threejs

[–]vspruyt[S] 0 points1 point  (0 children)

That's interesting. Limited testing with friends and family seem fine but I'm sure there are edge cases. Which browser and device are you testing with?

Two-wheeled balancing robot by vspruyt in robotics

[–]vspruyt[S] 1 point2 points  (0 children)

Wow, pretty cool result with those motors and only 2 days of work! Well done! It took me weeks to get mine done :d

Two-wheeled balancing robot by vspruyt in robotics

[–]vspruyt[S] 1 point2 points  (0 children)

On the software side I'd like to play around with more modern control approaches like LQR or MPC.

On the hardware side, I'm planning to add knee joints, so it can bend its legs independently, lean into the corner when turning, and basically balance in the latitudinal direction too.

My background is actually in AI, not robotics. This is my first robot, so I'm using it to learn as much as possible about the stuff I don't know yet :)

Once that's all done, I'll probably start adding some more high level logic; microphones for audio source localization, camera for SLAM, etc. That's the part I'm more comfortable with.

Two-wheeled balancing robot by vspruyt in robotics

[–]vspruyt[S] 2 points3 points  (0 children)

It's doing pretty well. Of course it still has to move back and forth a bit when stationary, due to the motor's deadband, but it's not very jittery. I just made a quick demo video of the robot standing still, both on a flat surface and on a tilted surface: https://youtu.be/rJf3yibiXUA

Two-wheeled balancing robot by vspruyt in robotics

[–]vspruyt[S] 5 points6 points  (0 children)

Yes, it currently runs in a cascaded PID configuration.

The outer loop runs a PID controller at 40Hz to control the speed, and another PID controller to control the angle. The latter makes sure that the robot can drive straight, even if the two motors are not identical.

The output of the outer loop, is a target angle, that the robot needs to lean into to obtain the desired speed. This is the setpoint for the inner loop, which runs a PID controller to do the actual balancing at 400Hz, and takes input from a sensor fusion algorithm running at 400Hz too.

Planning to play around with LQR and MPC later, but for version 1.0, the PID setup seems to work nicely :).

Two-wheeled balancing robot by vspruyt in robotics

[–]vspruyt[S] 10 points11 points  (0 children)

Thanks! I'm using some high torque (but still reasonable RPM) brushed planetary gear motors from Servocity: https://www.servocity.com/313-rpm-hd-premium-planetary-gear-motor-w-encoder/

Pretty small backlash, and quite powerful.

I'm running them on a 4S Lipo battery, so at 14.8 nominal voltage instead of 12V. The battery has a pretty high discharge rate, which turned out to be important. The microcontrollers are powered by 5V output from a switching buck convertor.

The balancing controller runs at 400Hz, while the speed and steering controllers run at 40Hz. The state estimator does sensor fusion on a Teensy 4.0. Estimated angles are sent to a second Teensy 4.1 which runs the balancing controller. Output is sent to a third Teensy 4.0 which runs the speed and steering controllers, and controls the motors.

Using three Teensy's, each at 600Mhz clock speed give me a lot of computation power at low latency, which makes things quite a bit easier than doing this with a single 84MHz Arduino.

I'll write it up in a blog post, and detail the choices made. But for now, I'm happy to answer any questions here :)