sirkut / InfernalRobotics

Update to r4m0n Dammed Robotics that works on Kerbal Space Program 0.20.2
Other
17 stars 16 forks source link

Adjustable servo acceleration/deceleration #6

Open tox1m opened 10 years ago

tox1m commented 10 years ago

Would be nice if we could adjust how long it takes for a part to start moving at the set speed, so that they would slowly accelerate (and/or decelerate to a stop).

Right now when applying movement to the parts, they immediately move at the specified speed.

For example; we could set the servo acceleration to take 2 seconds and deceleration to take 1.5s and have servo speed at 1.

This might decrease the wobble with robotic arms and cranes when moving around large objects.

ZodiusInfuser commented 10 years ago

I too would like this feature. I'd say that the end stops of each joint would need to be taken into account, so if you accelerate a joint and it reaches the end of its 90 degree range it cannot be allowed to overshoot, and should abruptly stop.

omgnull commented 10 years ago

I understand the acceleration but not the deceleration. Movement action could be stopped at any time, so the action must stop immediately or continue and decrease speed to achieve smooth stop?

ZodiusInfuser commented 10 years ago

It should be the latter IMO, since you've released control of the joint, but it needs to apply the brakes to reach a stop. The exception to this is when the distance/angle reaches the limits of the joint, in which case the value should just be clamped, and not allowed to overshoot. This should apply in both cases, as its possible to hit the limit whilst accelerating.

pellinor0 commented 9 years ago

I have a simple interpolator in mind, which accelerates smoothly both on keypress and towards the ends of the travelling range. Say we are travelling in positive direction.

// Variables cmdVel: target speed oldVel: speed from last frame newVel: speed for this frame maxPos: End of travelling range

// Limit cmdVel to constant acceleration braking profile towards maxPos cmdVel = min(maxVel, sqrt(2 * acc * (maxPos-pos) )) // speed tries to follow cmdVel newVel = min(oldVel + acc * deltaT, cmdVel) newVel = max(oldVel - acc * deltaT, newVel) // position is updated pos = min(pos + curVel * deltaT, maxPos)