# Unable to make mechanism floating with RigidBodyDynamics

**URL:** https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221
**Category:** General Usage
**Tags:** question
**Created:** [November 29, 2021, 5:13am UTC](https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221 "2021-11-29T05:13:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bbokser](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bbokser/32/31188_2.png) [@bbokser](https://discourse.julialang.org/u/bbokser)
#### Post date: [November 29, 2021, 5:13am UTC](https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221/1 "2021-11-29T05:13:23Z")

</div>

I’m using RigidBodyDynamics and am trying to get my mechanism to be floating rather than fixed-base. However, when I set floating=true in parse\_urdf, I get a “type QuatRotation has no field w” error after running MechanismState.

I’ve seen an example of this work, so it’s odd: [example](https://www.researchgate.net/publication/331983442_Julia_for_robotics_simulation_and_real-time_control_in_a_high-level_programming_language)

I also tried using an earlier version of RigidBodyDynamics (v2.0.0), which didn’t throw any errors, but in this case the model is inexplicably missing from the visualization (And yes, I checked the first timestep).

```julia
curdir = pwd()
urdfpath = joinpath(curdir, "../res/flyhopper_robot/urdf/flyhopper_robot.urdf")
doublependulum = parse_urdf(urdfpath, floating=true)
state = MechanismState(doublependulum)

```

```julia
type QuatRotation has no field w

Stacktrace:
  [1] getproperty(x::Rotations.QuatRotation{Float64}, f::Symbol)
    @ Base ./Base.jl:33
  [2] set_rotation!
    @ ~/.julia/packages/RigidBodyDynamics/8B04X/src/joint_types/quaternion_floating.jl:37 [inlined]
  [3] zero_configuration!
    @ ~/.julia/packages/RigidBodyDynamics/8B04X/src/joint_types/quaternion_floating.jl:169 [inlined]
  [4] zero_configuration!
    @ ~/.julia/packages/RigidBodyDynamics/8B04X/src/joint.jl:353 [inlined]
  [5] (::RigidBodyDynamics.var"#57#58")(joint::Joint{Float64, QuaternionFloating{Float64}}, qjoint::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true})
    @ RigidBodyDynamics ~/.julia/packages/RigidBodyDynamics/8B04X/src/mechanism_state.jl:294
  [6] macro expansion
    @ ~/.julia/packages/TypeSortedCollections/Z4ytl/src/TypeSortedCollections.jl:196 [inlined]
  [7] foreach
    @ ~/.julia/packages/TypeSortedCollections/Z4ytl/src/TypeSortedCollections.jl:187 [inlined]
  [8] zero_configuration!(state::MechanismState{Float64, Float64, Float64, TypeSortedCollections.TypeSortedCollection{Tuple{Vector{Joint{Float64, QuaternionFloating{Float64}}}, Vector{Joint{Float64, Revolute{Float64}}}}, 2}})
    @ RigidBodyDynamics ~/.julia/packages/RigidBodyDynamics/8B04X/src/mechanism_state.jl:293
  [9] zero!(state::MechanismState{Float64, Float64, Float64, TypeSortedCollections.TypeSortedCollection{Tuple{Vector{Joint{Float64, QuaternionFloating{Float64}}}, Vector{Joint{Float64, Revolute{Float64}}}}, 2}})
    @ RigidBodyDynamics ~/.julia/packages/RigidBodyDynamics/8B04X/src/mechanism_state.jl:318
 [10] (MechanismState{Float64, M, C, JointCollection} where {M, C, JointCollection})(mechanism::Mechanism{Float64})
    @ RigidBodyDynamics ~/.julia/packages/RigidBodyDynamics/8B04X/src/mechanism_state.jl:189
 [11] MechanismState(mechanism::Mechanism{Float64})
    @ RigidBodyDynamics ~/.julia/packages/RigidBodyDynamics/8B04X/src/mechanism_state.jl:198
 [12] top-level scope
    @ In[80]:6
 [13] eval
    @ ./boot.jl:360 [inlined]
 [14] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1116

```

Edit: It seems with v2.0.0, the issue is caused when running `set_configuration!(mvis, zeros(11))`. Before this, the visualization appears as normal. I’m not sure how to set the starting position of the body at the origin if using zeros isn’t the answer.

---

<div class="post-metadata">

### Author: ![artkuo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/artkuo/32/28577_2.png) [@artkuo](https://discourse.julialang.org/u/artkuo)
#### Post date: [November 29, 2021, 7:28pm UTC](https://discourse.julialang.org/t/unable-to-make-mechanism-floating-with-rigidbodydynamics/72221/2 "2021-11-29T19:28:51Z")

</div>

That error is probably due to a change in how quaternions are handled in Rotations.jl. I don’t know the history of it, but there’s an [open issue](https://github.com/JuliaGeometry/Rotations.jl/issues/208#issuecomment-976082837) and a pending [PR](https://github.com/JuliaGeometry/Rotations.jl/pull/209). It appears that things got switched from `UnitQuaternion` to `QuatRotation`, and field access to `w`, `x`, `y`, `z` was not retained. The PR should restore this with appropriate `getproperty`, but `RigidBodyDynamics` could also avoid field access altogether, since it is brittle.

You can try out the PR and see if it fixes everything for you. I don’t think this has anything to do floating vs fixed base.
