Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: joint drives #87

Closed
emilk opened this issue Jan 14, 2021 · 2 comments · Fixed by #119
Closed

Feature request: joint drives #87

emilk opened this issue Jan 14, 2021 · 2 comments · Fixed by #119
Labels
C-Enhancement New feature or request

Comments

@emilk
Copy link
Contributor

emilk commented Jan 14, 2021

Joint drives (or joint motors) allows one to simulate e.g. a motor turning a wheel, a muscle bending an arm, or a pushing piston.

In particular, I'd like to be able to set up angular forces for ball joints and revolute joints in an "angular spring" fashion, i.e.:

torque = stiffness * (target_angle - relative_angle)
       + damping * (target_angular_velocity - relative_angular_velocity)

(the word damping really only makes sense for when target_angular_velocity=0 - some more clever nomenclature may be warranted).

In addition, it would be desireable to clamp this to a given maximum absolute torque.

For a revolve joint this would then be five parameters (target_angle, target_angular_velocity, stiffness, damping, max_torque). One could then use target_angle and stiffness to move the hands of a clock, and target_velocity + damping to turn the wheels of a car.

For ball joints we have three DOFs, so target_angle would need to be a quaternion and target_angular_velocity a vector. For the siffness, damping and max_torque I think one dimension is enough for most use cases (i.e. use the same strength for all three DOFs).

Related to this is a generalization of all joints as one 6DOF joint. If one can set a target angle and velocity as well as stiffness and damping for all the six degrees of freedom independently, then one actually has a general joint constraint. Basically one would lock a degree of freedom by setting a very high stiffness and damping to one dimension (and zero target velocity). This may simplify the inner workings of rapier in the long run, but probably be more work in the short run.


Of course, all this can be approximated using RigidBody::apply_torque and friends, but it really ought to be part of the constraint solver, as forces and torques tend to "lose" against real constraints (after all, one can approximate all the constraints using forces and torques).

@sebcrozet
Copy link
Member

Joint motors/limits/pose-control is something that will be added within the next few months.

A generic 6-DOF joint could be added too, however it will probably not end up simplifying the inner workings of Rapier in the long run because each joint has its specific formulation in order to solve all its constraints (for all the DOFs it affects) at once in a linearly-implicit way. So a generic 6-DOF joint will probably end up being a different formulation (somewhat more generic), perhaps slightly less efficient and less stable than the existing specific joints. Though I may be wrong since I have not thought about this in details yet.

@emilk
Copy link
Contributor Author

emilk commented Jan 21, 2021

Joint motors/limits/pose-control is something that will be added within the next few months.

I just discovered the roadmap at https://www.dimforge.com/blog/2021/01/01/physics-simulation-with-rapier-2021-roadmap/ 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants