Logo Xingxin on Bug

What is a Wrench in Robotics? From Textbook to libfranka

November 27, 2026
12 min read

I have heard the term wrench many times whether in

It kept showing up everywhere, and this time I finally nailed it. In this post, I will explain what a wrench is using both a textbook problem and two real experiments on a Franka Research 3.

📝Definition

Remark

There are several ways to define a wrench (also called a spatial force). Here I follow the convention from Modern Robotics: Mechanics, Planning, and Control because its diagrams and notation make transformation easy to visualize.

Consider a linear force f\mathrm{f} acting on a rigid body at a point r\mathrm{r}. Once we choose a reference frame {a}\{a\}, the point’s coordinates from the origin of {a}\{a\} are ra∈R3r_a \in \mathbb{R}^3, and the force vector is fa∈R3f_a \in \mathbb{R}^3. This force creates a torque(or moment) ma∈R3m_a \in \mathbb{R}^3 about the origin of {a}\{a\}:

ma=ra×fa.m_a = r_a \times f_a .

Just as we combine angular and linear velocity into a 6D twist, we can stack the moment and force into a single 6-dimensional wrench expressed in the {a}\{a\} frame, denoted Fa\mathcal{F}_a:

Fa=[mafa]∈R6.\mathcal{F}_a = \begin{bmatrix} m_a \\ f_a \end{bmatrix} \in \mathbb{R}^6.

modern-robotics-figure-3.21.svg

© Modern Robotics

Tip

I love Russ Tedrake’s analogy: the twists and wrenches both pair a rotational part with a translational part. For a wrench, the rotational part is torque and the translational part is linear force.

To express the same wrench in another frame {b}\{b\}, let Tab=(Rab,pab)∈SE(3)T_{ab} = (R_{ab}, p_{ab}) \in SE(3) be the homogeneous transformation matrix of {b}\{b\} relative to {a}\{a\}. Because mechanical power VTF\mathcal{V}^{\mathsf{T}}\mathcal{F} is coordinate-independent, Proposition 3.27 in Modern Robotics: Mechanics, Planning, and Control shows that wrenches transform between frames using the transpose of the adjoint representation of rigid-body transformation:

Fb=[AdTab]TFa,where [AdTab]=[Rab0[pab]RabRab]∈R6×6,\mathcal{F}_b = [\mathrm{Ad}_{T_{ab}}]^{\mathsf{T}} \mathcal{F}_a, \qquad \text{where } [\mathrm{Ad}_{T_{ab}}] = \begin{bmatrix} R_{ab} & 0 \\ [p_{ab}]R_{ab} & R_{ab} \end{bmatrix} \in \mathbb{R}^{6 \times 6},

and [pab]∈so(3)[p_{ab}] \in \mathfrak{so}(3) is the 3×33 \times 3 skew-symmetric matrix satisfying [p]v=p×v[p]v = p \times v.

🗃Example

Next, let’s walk through 3 examples, one from the textbook and two on real robot hardware, to see how wrenches work in practice.

📁Textbook Example from Modern Robotics

This is the Example 3.28. from Modern Robotics: Mechanics, Planning, and Control.

© Modern Robotics

In the figure above, a robot hand with a mass of 0.5 kg holds an apple with a mass of 0.1 kg. Gravity g=10 m/s2g = 10\ \mathrm{m/s^2} (rounded for simple arithmetic) acts downward on the page. The link lengths are L1=10 cmL_1 = 10\ \mathrm{cm} and L2=15 cmL_2 = 15\ \mathrm{cm}.

We define 3 reference frames: {f}\{f\} at the force-torque sensor, {h}\{h\} at the hand’s center of mass, and {a}\{a\} at the apple’s center of mass.

💬Question What force and torque are measured by the six-axis force-torque sensor between the hand and the robot arm?


🏹Strategy There are 2 ways to find the wrench at frame {f}\{f\}:

  1. Since a wrench is just a 6-vector of 3 moments and 3 forces, we can compute the forces and lever-arm torques separately using basic statics.
  2. Or we can use the adjoint representation of rigid-body transformation (Proposition 3.27) to transform each gravitational wrench into {f}\{f\} and sum them up.

Let’s use the 2nd method. Our goal is to compute the net gravitational wrench acting on the hand-and-apple system in {f}\{f\}:

Ff=[AdThf]TFh+[AdTaf]TFa,\mathcal{F}_f = [\mathrm{Ad}_{T_{hf}}]^{\mathsf{T}} \mathcal{F}_h + [\mathrm{Ad}_{T_{af}}]^{\mathsf{T}} \mathcal{F}_a,

which transforms Fh\mathcal{F}_h from {h}\{h\} to {f}\{f\} and Fa\mathcal{F}_a from {a}\{a\} to {f}\{f\} before adding them together.


1️⃣ Write down Fh\mathcal{F}_h and Fa\mathcal{F}_a

Gravity acts purely at each center of mass, so neither object experiences a gravitational moment about its own center-of-mass frame. Following the axis directions in the figure, the gravitational wrench on the hand (0.5 kg×10 m/s2=5 N0.5\ \mathrm{kg} \times 10\ \mathrm{m/s^2} = 5\ \mathrm{N} along −y^h-\hat{\mathrm{y}}_h) is the column vector:

Fh=[0, 0, 0, 0, −5 N, 0]T.\mathcal{F}_h = [0,\ 0,\ 0,\ 0,\ -5\ \mathrm{N},\ 0]^{\mathsf{T}}.

Similarly, since z^a\hat{\mathrm{z}}_a points downward, the gravitational wrench on the apple (0.1 kg×10 m/s2=1 N0.1\ \mathrm{kg} \times 10\ \mathrm{m/s^2} = 1\ \mathrm{N} along +z^a+\hat{\mathrm{z}}_a) is:

Fa=[0, 0, 0, 0, 0, 1 N]T.\mathcal{F}_a = [0,\ 0,\ 0,\ 0,\ 0,\ 1\ \mathrm{N}]^{\mathsf{T}}.


2️⃣ Find ThfT_{hf} and TafT_{af}

Remember that transforming a wrench from {h}\{h\} to {f}\{f\} via [AdThf]T[\mathrm{Ad}_{T_{hf}}]^{\mathsf{T}} requires ThfT_{hf}—the pose of {f}\{f\} measured in {h}\{h\}. Given L1=0.1 mL_1 = 0.1\ \mathrm{m} and L1+L2=0.25 mL_1 + L_2 = 0.25\ \mathrm{m}:

Thf=[100−0.1 m010000100001],Taf=[100−0.25 m00100−1000001].T_{hf} = \left[\begin{array}{cccc} 1 & 0 & 0 & -0.1\ \mathrm{m} \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right], \qquad T_{af} = \left[\begin{array}{cccc} 1 & 0 & 0 & -0.25\ \mathrm{m} \\ 0 & 0 & 1 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right].

3️⃣ Calculate Ff\mathcal{F}_f in Julia

using LinearAlgebra
 
skew(v) = [ 0    -v[3]   v[2];
            v[3]  0     -v[1];
           -v[2]  v[1]   0  ]
 
function adjoint(T)
    R = T[1:3, 1:3]
    p = T[1:3, 4]
    return [R          zeros(3, 3);
            skew(p)*R  R         ]
end
 
T_hf = [1 0 0 -0.1;
        0 1 0  0;
        0 0 1  0;
        0 0 0  1]
 
T_af = [1  0 0 -0.25;
        0  0 1  0;
        0 -1 0  0;
        0  0 0  1]
 
Ad_T_hf = adjoint(T_hf)
Ad_T_af = adjoint(T_af)
 
F_h = [0, 0, 0, 0, -5, 0]
F_a = [0, 0, 0, 0,  0, 1]
 
# the Ad_T_hf' is the transpose of Ad_T_hf
F_f = Ad_T_hf' * F_h + Ad_T_af' * F_a

Running the script gives:

6-element Vector{Float64}:
  0.0
  0.0
 -0.75
  0.0
 -6.0
  0.0

So the net gravitational wrench acting on the sensor frame {f}\{f\} is:

Ff=[AdThf]TFh+[AdTaf]TFa=[0, 0, −0.5 N⋅m, 0, −5 N, 0]T+[0, 0, −0.25 N⋅m, 0, −1 N, 0]T=[0, 0, −0.75 N⋅m, 0, −6 N, 0]T.\begin{aligned} \mathcal{F}_f &= [\mathrm{Ad}_{T_{hf}}]^{\mathsf{T}} \mathcal{F}_h + [\mathrm{Ad}_{T_{af}}]^{\mathsf{T}} \mathcal{F}_a \\ &= [0,\ 0,\ -0.5\ \mathrm{N\cdot m},\ 0,\ -5\ \mathrm{N},\ 0]^{\mathsf{T}} + [0,\ 0,\ -0.25\ \mathrm{N\cdot m},\ 0,\ -1\ \mathrm{N},\ 0]^{\mathsf{T}} \\ &= [0,\ 0,\ -0.75\ \mathrm{N\cdot m},\ 0,\ -6\ \mathrm{N},\ 0]^{\mathsf{T}}. \end{aligned}
Tip

To hold the hand and apple in static equilibrium, the robot arm exerts the equal and opposite wrench −Ff-\mathcal{F}_f on the hand.

📩Manually Validating Wrench in libfranka

In the apple example, we started with known masses and predicted what a wrist sensor would read. Now let’s work from a real recording. Here, a Franka Research 3 has grasped the 3D-printed block and is holding it above an optical table. Using its joint torque sensors and internal dynamics model, the robot reports an estimated external wrench in 2 different frames:

  1. OFK,ext^O\mathcal{F}_{K,\text{ext}} O_F_ext_hat_K: the external wrench expressed in the base frame {O}\{O\}.
  2. KFK,ext^{K}\mathcal{F}_{K,\text{ext}} K_F_ext_hat_K: the external wrench expressed in the stiffness frame {K}\{K\}.

Because the robot gives us both, we can transform KFK,ext^K\mathcal{F}_{K,\text{ext}} into {O}\{O\} ourselves and verify our math directly against OFK,ext^O\mathcal{F}_{K,\text{ext}}.


💬 Question Given KFK,ext^K\mathcal{F}_{K,\text{ext}} and the robot’s pose from franka_ros2: ROS 2 integration for Franka research robots, can we compute OF^K,ext^O\widehat{\mathcal{F}}_{K,\text{ext}} so that OF^K,ext≈OFK,ext^O\widehat{\mathcal{F}}_{K,\text{ext}} \approx {}^O\mathcal{F}_{K,\text{ext}}?


🏹 Strategy

Using the same adjoint wrench transformation as before (denoting FK≡KFK,ext\mathcal{F}_K \equiv {}^K\mathcal{F}_{K,\text{ext}} and FO≡OFK,ext\mathcal{F}_O \equiv {}^O\mathcal{F}_{K,\text{ext}} for short):

F^O=[AdTKO]TFK.\widehat{\mathcal{F}}_O = [\mathrm{Ad}_{T_{KO}}]^{\mathsf{T}} \mathcal{F}_K.

All we need from the robot state message are TKOT_{KO} and FK\mathcal{F}_K.


1️⃣ Which fields should we inspect?

SymbolMeaning in this exampleField in franka_ros2
FK\mathcal F_K6D wrench about the {K}\{K\} origin, in {K}\{K\} axesk_f_ext_hat_k.wrench
FO\mathcal F_OBase-frame 6D wrench we want to reproduceo_f_ext_hat_k.wrench
TO,EET_{O,EE}End-effector frame {EE}\{EE\} pose in base frame {O}\{O\}o_t_ee.pose
TEE,KT_{EE,K}Stiffness frame {K}\{K\} pose in end-effector frame {EE}\{EE\}ee_t_k.pose
Remark

{O}\{O\} is the robot base frame, {EE}\{EE\} is the end-effector frame, and {K}\{K\} is the stiffness frame attached to the tool.


2️⃣Read the wrench values in franka_ros2

K_F_ext_hat_K:

{
  "wrench": {
    "force": {
      "x": 1.4548066854476929,
      "y": -2.1362175941467285,
      "z": 1.833638072013855
    },
    "torque": {
      "x": -0.9619402885437012,
      "y": 0.5624399781227112,
      "z": 0.14742685854434967
    }
  }
}

In Modern Robotics order ([mKT, fKT]T[m_K^{\mathsf{T}},\ f_K^{\mathsf{T}}]^{\mathsf{T}}), this is:

FK=[−0.961940, 0.562440, 0.147427,1.454807, −2.136218, 1.833638]T.\mathcal F_K = [-0.961940,\ 0.562440,\ 0.147427,\quad 1.454807,\ -2.136218,\ 1.833638]^{\mathsf T}.

O_F_ext_hat_K:

{
  "wrench": {
    "force": {
      "x": 1.757339596748352,
      "y": 1.9453562498092651,
      "z": -1.7802985906600952
    },
    "torque": {
      "x": -1.3314000368118286,
      "y": 0.48174265027046204,
      "z": 0.5212849378585815
    }
  }
}

We write the ground-truth base wrench as:

FO=[−1.331400, 0.481743, 0.521285,1.757340, 1.945356, −1.780299]T.\mathcal F_O = [-1.331400,\ 0.481743,\ 0.521285,\quad 1.757340,\ 1.945356,\ -1.780299]^{\mathsf T}.

3️⃣ Read the frame transformation from franka_ros2

EE_T_K :

{
  "pose": {
    "position": {
      "x": 0,
      "y": 0,
      "z": 0
    },
    "orientation": {
      "x": 0,
      "y": 0,
      "z": 0,
      "w": 1
    }
  }
}

This is the identity transform (TEE,K=I4T_{EE,K} = I_4), meaning the stiffness frame {K}\{K\} coincides with the end-effector frame {EE}\{EE\}.

O_T_EE:

{
  "pose": {
    "position": {
      "x": 0.46695610880851746,
      "y": 0.10892454534769058,
      "z": 0.07038187235593796
    },
    "orientation": {
      "x": 0.9983684596516972,
      "y": -0.04724302407225961,
      "z": 0.03022007656759094,
      "w": 0.010735766483374817
    }
  }
}

Changing the frames gives

TOK=TO,EE⋅TEE,K=TO,EE.T_{OK} = T_{O,EE} \cdot T_{EE,K} = T_{O,EE}.

Converting the position vector and unit quaternion into an SE(3)SE(3) homogeneous transformation matrix and taking its inverse TKO=TOK−1=[ROKT−ROKTpOK0T1]T_{KO} = T_{OK}^{-1} = \begin{bmatrix} R_{OK}^{\mathsf{T}} & -R_{OK}^{\mathsf{T}} p_{OK} \\ 0^{\mathsf{T}} & 1 \end{bmatrix} yields:

TOK=[0.99371−0.09498080.05932720.466956−0.093683−0.995306−0.02429190.1089250.06135590.0185811−0.9979430.07038190.00.00.01.0],TKO=TOK−1=[0.99371−0.0936830.0613559−0.458133−0.0949808−0.9953060.01858110.1514570.0593272−0.0242919−0.9979430.04517990.00.00.01.0].\begin{align} T_{OK} &= & \begin{bmatrix} 0.99371 & -0.0949808 & 0.0593272 & 0.466956 \\ -0.093683 & -0.995306 & -0.0242919 & 0.108925 \\ 0.0613559 & 0.0185811 & -0.997943 & 0.0703819 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{bmatrix}, \\ T_{KO} &= T_{OK}^{-1} = & \begin{bmatrix} 0.99371 & -0.093683 & 0.0613559 & -0.458133 \\ -0.0949808 & -0.995306 & 0.0185811 & 0.151457 \\ 0.0593272 & -0.0242919 & -0.997943 & 0.0451799 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{bmatrix}. \end{align}

4️⃣ Compute the base-frame wrench in Julia

With all inputs ready, we evaluate:

FO=[AdTKO]TFK\mathcal F_O = [\mathrm{Ad}_{T_{KO}}]^{\mathsf T}\mathcal F_K

at full recorded floating-point precision:

using LinearAlgebra
 
function quat_to_T(q; p)
    w, x, y, z = q ./ norm(q)
    R = [1-2(y^2+z^2)  2(x*y-z*w)    2(x*z+y*w);
         2(x*y+z*w)    1-2(x^2+z^2)  2(y*z-x*w);
         2(x*z-y*w)    2(y*z+x*w)    1-2(x^2+y^2)]
    T = Matrix{Float64}(I, 4, 4)
    T[1:3, 1:3] = R
    T[1:3, 4] = p
    return T
end
 
skew(v) = [0 -v[3] v[2]; v[3] 0 -v[1]; -v[2] v[1] 0]
 
function mr_adjoint(T)
    R = T[1:3, 1:3]
    p = T[1:3, 4]
    return [R zeros(3, 3); skew(p)*R R]
end
 
F_k = [-0.9619402885437012,  0.5624399781227112, 0.14742685854434967,
        1.4548066854476929, -2.1362175941467285, 1.833638072013855]
q_wxyz = [0.010735766483374817, 0.9983684596516972,
         -0.04724302407225961,  0.03022007656759094]
p = [0.46695610880851746, 0.10892454534769058, 0.07038187235593796]
 
T_ok = quat_to_T(q_wxyz; p=p)
T_ko = inv(T_ok)
F_o_cal = mr_adjoint(T_ko)' * F_k
 
# Compare with the second representation in the same robot-state message.
F_o_recorded = [-1.3314000368118286, 0.48174265027046204,  0.5212849378585815,
                 1.757339596748352,  1.9453562498092651, -1.7802985906600952]
@assert isapprox(F_o_cal, F_o_recorded; rtol=1e-6)
println(round.(F_o_cal; digits=6))

5️⃣ Compare our calculation with ground truth

Our calculated base-frame wrench is

F^O≈[−1.331400, 0.481743, 0.521285⏟moment (N\cdotpm),1.757340, 1.945356, −1.780299⏟force (N)]T,\widehat{\mathcal F}_O \approx [\underbrace{-1.331400,\ 0.481743,\ 0.521285}_{\text{moment (N·m)}},\quad \underbrace{1.757340,\ 1.945356,\ -1.780299}_{\text{force (N)}}]^{\mathsf T},

which matches the recorded franka_ros2 value to 6 decimal places:

FO=[−1.331400, 0.481743, 0.521285,1.757340, 1.945356, −1.780299]T.\mathcal F_O = [-1.331400,\ 0.481743,\ 0.521285,\quad 1.757340,\ 1.945356,\ -1.780299]^{\mathsf T}.

🗂Using the Wrench to Estimate Object Weight

For one more hands-on test with libfranka, I wanted to see how accurate the Franka’s joint-torque-based wrench estimate really is.

GraspedReleased

💬Question

When the gripper releases the block, can we estimate the block’s mass from the change in the estimate force?


✏Solution

To reduce sensor noise variance, I averaged O_F_ext_hat_K.wrench.force component by component from the MCAP logs in the robot’s base frame {O}\{O\}, where +zO+z_O points upward:

StateSamplesJaw openingMean X (N)(N)Mean Y (N)(N)Mean Z (N)(N)
Holding4,00028.54 mm+0.52179−0.07921+1.52044
Released2,00050.00 mm+0.54184−0.07974+1.20580
Difference−0.02005+0.00053+0.31464
Tip

The documentation on the sign of O_F_ext_hat_K is confusing. Here’s my tl;dr way of thinking about it, with the robot base frame axes shown as follows:

In short, the force in O_F_ext_hat_K is the force vector the robot exerts on the environment, expressed in the base frame {O}\{O\}.

For example, when the weight of the block pulls the gripper downward, the robot must exert an upward force (fz>0f_z > 0) to support it, giving Δfz=+0.31464 N\Delta f_z = +0.31464\text{ N}.

Dividing Δfz\Delta f_z by gravitational acceleration g=9.81 m/s2g = 9.81\ \mathrm{m/s^2} gives the estimated mass:

m=1.52044−1.205809.81=0.03207 kg≈32 g.m = \frac{1.52044 - 1.20580}{9.81} = 0.03207\ \mathrm{kg} \approx \mathbf{32\ \mathrm{g}}.

I brought the block back to my dorm and put it on the kitchen scale I use to weigh my breakfast. It read 36g. Being with 4 g4\ \mathrm{g} (∼0.04 N\sim 0.04\ \mathrm{N}) using only arm joint torque sensors, with no dedicated wrist force–torque sensor, is pretty impressive!😲

See also...