QuirkyCort / gears

Generic Educational Robotics Simulator
Other
65 stars 41 forks source link

Feature/Pull Request: More Wheels #90

Open sgmurray opened 2 years ago

sgmurray commented 2 years ago

I recently submitted a pull request for a feature that allows users to add more wheels to robots in GEARS. Here is a video demonstrating what is possible with this new feature. https://youtu.be/Mq4urBJPNng

QuirkyCort commented 2 years ago

Looks great, but it's gonna take me a while before I can find the time to look through the code. As well, there is a competition going on using Gears, so better to avoid any big changes til it's over.

sgmurray commented 2 years ago

The stair climber robot in my video is based on the real life EV3 stair climber. https://www.youtube.com/watch?v=f8xkVyMFrog

I have added 2 new features to my fork of gears, wheel blocks and passive wheels, which allow the simulated climber to use only 3 motors (just like the physical robot).

Here's how you can try out the stair climber for yourself.

  1. Go to https://sgmurray.github.io/gears/public/
  2. Download and extract stairClimber.zip
  3. Robot > Load from file>stairClimber.json
  4. Worlds > Load from file>stairWorld.json
  5. File > Load Python from your computer > stairClimberCode.py
QuirkyCort commented 2 years ago

Sorry for taking a long time. Finally gotten some free time to look through the PR. It's great. Thanks!

sgmurray commented 2 years ago

@QuirkyCort Would you also be willing to add wheel blocks (dumb blocks that look like wheels)? I used them to make linked left and right pairs of wheels on the stair climber.

https://github.com/sgmurray/gears/commit/a5633079b956af24fe439e1fac7b170119f33141

QuirkyCort commented 2 years ago

I've already done that. I've named it "WheelPassive" and it's under the "Others" category in the configurator.

There are also a few fixes related to the "more wheels" PR, so you might want to pull that into your own version.

sgmurray commented 2 years ago

Maybe I'm missing something. WheelPassive creates a hinge joint between the parent and the wheel. What I am asking for an additional component that acts like a dumb block (no hinge joint). On the real stair climber left and right pairs of wheels are attached to the same axle and rotate in lockstep. The way I replicated this in gears is to create a WheelActuator and add a WheelBlock as a child.

The commit that I linked to does the above. I will make a pull request so it is clearer.

image

QuirkyCort commented 2 years ago

Ok. I think I understand. The WheelBlock is basically just a cylinder, but with the default wheel skin and the magical tire downward force. Anything other differences from a cylinder?

sgmurray commented 2 years ago

Correct. The wheelBlock is just a cylinder with the wheel skin. Maybe make magical tire downward force a checkbox option that users can choose to turn on/off. I can't think of any other differences from a cylinder.

QuirkyCort commented 2 years ago

I added in the option on my local copy, then realized that this won't work (...ammo throws an error). The cylinder doesn't have it's own physics body as it is merged with the physics body of the wheel.

The closest I can do is to apply the downward force on the parent (wheel), but at the location of the cylinder. Is that how you did it? That will work, but the center of mass will remain at the wheel, so I don't think that's a great solution. There may also be some minor physics issue due to the position of the joint between the wheel and the body being off to one side.

A better solution may be to place the wheel in the middle and set it to a small diameter, then attach two cylinders to act as the wheels. The total downward force will be only half that of using two separate wheels, but that's easily resolved by making the tire down force a configurable option.

sgmurray commented 2 years ago

I naively applied the downward force to the cylinder. Ammo doesn't seem to throw an error for me.
You can see the changes I made here: https://github.com/sgmurray/gears/commit/80eb15c6405836a1a689fb6314239c700438a655 You can watch run it in the browser here https://sgmurray.github.io/gears/public/

I also tried the small wheel in the middle with 2 larger wheels on the outside. That seems to work better.