QuirkyCort / gears

Generic Educational Robotics Simulator
Other
65 stars 41 forks source link

Reduce Electromagnet Wobble #70

Closed sgmurray closed 3 years ago

QuirkyCort commented 3 years ago

Haven't tested it, but the logic looks ok. I'm gonna go ahead and merge this.

QuirkyCort commented 3 years ago

Tested it out. The dampening works to reduce wobbling, but it has a few negative effects...

1) The ball's acceleration towards the magnet is reduced. At a dGain of 1, you can see the ball move slowly towards the magnet (...compared to dGain 0, where the acceleration increases until it hits). Looks a little unrealistic.

2) When the robot rotates, the ball should follow the magnet, but the dampening slows it down. This makes it more likely to detach from the magnet.

Perhaps a solution would be to apply the dampening only in the perpendicular direction, and only when the ball is moving away from the centerline. In the following image, the dampening should only be applied in case 4.

g4456-6

sgmurray commented 3 years ago

For reference, I use maxRange = 20, maxPower = 10000, and d Gain = 0.1

  1. Good idea! I can work on making the damping only act in the perpendicular direction.

  2. With regards to holding onto the ball while rotating, I have found 0.1 dGain is better than 0 dGain which is better than 1 dGain.