RigidBodyDynamics.jl attaching a new rigid body to the system


#1

Is it possible to add an extra load to a mechanism created from an urdf? For example, add a sphere to the last joint of a system. Can RigidBodyDynamics.attach! be used for this?


#2

Can RigidBodyDynamics.attach! be used for this?

Yep, that’s what it’s for. You could attach it using the Fixed joint type and then optionally call removed_fixed_tree_joints!(mechanism) to merge the rigid bodies connected by the fixed joint for efficiency.


#3

How can I do this in a mechanism obtained from an urdf file?

robot = getmechanism("acrobot")
axis = SVector(0., 1., 0.) # joint axis
I_1 = 0.333 # moment of inertia about joint axis
c_1 = -0.15 # center of mass location with respect to joint axis
m_1 = 5. # mass
frame1 = CartesianFrame3D("new") # the reference frame in which the spatial inertia will be expressed
inertia1 = SpatialInertia(frame1, I_1 * axis * axis', m_1 * SVector(0, 0, c_1), m_1)
body = RigidBody(inertia1)
attach!(robot, ? , body, Fixed)

#4

? in your code should be a body that’s already part of robot (e.g. last(bodies(robot))). The fourth argument should be a Joint, not the type of a JointType. It’s exactly the same as in cell 9 of the quickstart notebook. It doesn’t matter whether the Mechanism you’re attach!ing a new body to was created directly using API calls or using parse_urdf. See also the documentation for attach! if you hadn’t seen it yet, and feel free to open a documentation PR if anything is unclear there.


#5

Thank you!