JuliaRobotics / RigidBodyDynamics.jl

Julia implementation of various rigid body dynamics and kinematics algorithms
Other
287 stars 48 forks source link

Is modelling flexible links sensible with RigidBodyDynamics.jl? #613

Closed conorbergin closed 3 years ago

conorbergin commented 3 years ago

I am investigating mechanisms with compliant links, so that they can be 3d printed easily. A lot of them of them can be modelled as rigid bodies with torsional springs, a simple example being: Screenshot from 2021-02-19 02-50-13 (from Larry Howell's Handbook of Compliant Mechanisms)

Is there and elegant way to make one of these and be able to string them together into a mechanism. Its quite straight forward with SimScape Multibody, but I'd prefer to not use MATLAB.

Thank you for the library, and I apologise if I'm abusing the issue tracker. -Conor

tkoolen commented 3 years ago

That's OK, sorry I don't have more time to respond to issues promptly. Yeah, the pseudo-rigid body model stuff is definitely possible. I would just start with the double pendulum example code, but write a loop that adds another link in each iteration. You can model the springs by writing a 'controller' as in https://juliarobotics.org/RigidBodyDynamics.jl/stable/generated/2.%20Closed-loop%20simulation%20and%20visualization/2.%20Closed-loop%20simulation%20and%20visualization/#Controller, which would look more like

function set_joint_torques!(torques::AbstractVector, t, state::MechanismState)
    for joint in tree_joints(state.mechanism)
        stiffness = 100 # Nm / rad
        torques[joint] .= -stiffness .* configuration(state, joint)
    end
end

It would probably be wise to add a little bit of damping as well.

The external load can be handled using the externalwrenches argument of dynamics!. Unfortunately simulate doesn't expose that functionality right now; instead you'll have to pattern match the code and call the appropriate dynamics! overload in the modified closed_loop_dynamics! function.