Setting gravity in RigidBodyDynamics.jl

I have just started to use RigidBodyDynamics. According to the tutorial, the proper way to set gravity seems m = Mechanism(world; gravity = SVector(0, 0, g). But when constructing a mechanism using parse_urdf, what is the proper way to set gravity? My trial was like

m = parse_urdf(myurdf.urdf)
m.gravitational_acceleration = FreeVector3D(default_frame(m.tree.root), SVector(0, 0, -9.8))

but I guess mine is wrong and there is a better way.

Yeah, that’s a bit of an oversight. An additional keyword argument for that should be added to parse_urdf. For now, I’d do

urdf = "bla.urdf"
m = parse_urdf(urdf)
m.gravitational_acceleration = FreeVector3D(root_frame(m), 0, 0, -9.81)
1 Like

I understand. Thanks for your answer and great software!

1 Like