# RigidBodyDynamics.jl - Fixed joint creation not working?

**URL:** <https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [November 16, 2024, 5:01pm UTC](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719 "2024-11-16T17:01:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobbesU](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robbesu/32/212459_2.png) [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Post date:** [November 16, 2024, 5:01pm UTC](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719/1 "2024-11-16T17:01:04Z")

</div>

What is the correct syntax for creating a `Fixed` Joint, so it can be added to a Mechanism?

A Revolute Joint is created by

```julia
revolute_joint = Joint("revolute_joint", Revolute(axis) )

```

but a Fixed Joint I can’t get to accept anything.

```julia
# these all fail
fixed_joint1 = Joint("fixed_joint", Fixed() )
fixed_joint2 = Joint("fixed_joint", Fixed )
fixed_joint3 = Joint("fixed_joint", Fixed(axis) )

```

all result in a form of

```julia
MethodError: no method matching RigidBodyDynamics.Fixed( ....)
The type `RigidBodyDynamics.Fixed` exists, but no method is defined for this combination of argument types when trying to construct it.

```

Looking at the docs and source it shows the `struct` for `Revolute()` takes an axis, but `Fixed` takes nothing

```julia
struct Fixed{T} <: JointType{T} end

struct Revolute{T} <: JointType{T}
    axis::SVector{3, T}
    rotation_from_z_aligned::RotMatrix3{T}

    function Revolute{T}(axis::AbstractVector) where {T}
        a = normalize(axis)
        new{T}(a, rotation_between(SVector(zero(T), zero(T), one(T)), SVector{3, T}(a)))
    end
end

```

Example use in the [quick start Double Pendulum](https://juliarobotics.org/RigidBodyDynamics.jl/stable/generated/1.%20Quickstart%20-%20double%20pendulum/1.%20Quickstart%20-%20double%20pendulum/) :  
Application in Mechanism replacing the elbow joint by a fixed joint:

```julia
l_1 = -1. # length of the upper link
I_2 = 0.333 # moment of inertia about joint axis
c_2 = -0.5 # center of mass location with respect to joint axis
m_2 = 1. # mass
inertia2 = SpatialInertia(CartesianFrame3D("lower_link"),
    moment=I_2 * axis * axis',
    com=SVector(0, 0, c_2),
    mass=m_2)
lowerlink = RigidBody(inertia2)

elbow = Joint("elbow", Revolute(axis)) # <<<< Change this to Fixed
# elbox_fixed = Joint("elbow", Fixed???? ) 

before_elbow_to_after_shoulder = Transform3D(
    frame_before(elbow), frame_after(shoulder), SVector(0, 0, l_1))
attach!(doublependulum, upperlink, lowerlink, elbow,
    joint_pose = before_elbow_to_after_shoulder)

```

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [November 22, 2024, 5:56pm UTC](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719/2 "2024-11-22T17:56:03Z")

</div>

Hi,

You just need to explicitly specify the data type `T` in `Fixed{T}` as there are no arguments to infer it from.

```julia-repl
julia> elbow = Joint("elbow", Fixed{Float64}())
Joint "elbow": Fixed joint

```

---

<div class="post-metadata">

**Author:** ![RobbesU](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robbesu/32/212459_2.png) [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Post date:** [November 23, 2024, 11:25am UTC](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719/3 "2024-11-23T11:25:16Z")

</div>

Thank you @eldee. I figured it was something simple, but not _this_ simple.
