@@ -36,15 +36,15 @@ export near_zero,
3636 inverse_kinematics_body,
3737 inverse_kinematics_space,
3838 ad,
39- inverse_dynamics ,
40- inverse_dynamics !,
41- mass_matrix ,
42- mass_matrix !,
39+ inverse_dynamics_rnea ,
40+ inverse_dynamics_rnea !,
41+ mass_matrix_crba ,
42+ mass_matrix_crba !,
4343 mass_matrix_rnea,
4444 velocity_quadratic_forces,
4545 gravity_forces,
4646 end_effector_forces,
47- forward_dynamics ,
47+ forward_dynamics_crba ,
4848 forward_dynamics_rnea,
4949 euler_step,
5050 inverse_dynamics_trajectory,
@@ -1255,7 +1255,7 @@ function ad(V::AbstractVector)
12551255end
12561256
12571257"""
1258- inverse_dynamics (joint_positions, joint_velocities, joint_accelerations, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes)
1258+ inverse_dynamics_rnea (joint_positions, joint_velocities, joint_accelerations, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes)
12591259
12601260Computes inverse dynamics in the space frame for an open chain robot using
12611261forward-backward Newton-Euler iterations.
@@ -1273,7 +1273,7 @@ forward-backward Newton-Euler iterations.
12731273
12741274 This is ``O(n)`` in the number of joints — much faster than forming and inverting
12751275 the full dynamics equation. It is also the workhorse behind most dynamics
1276- computations: [`mass_matrix `](@ref), [`velocity_quadratic_forces`](@ref),
1276+ computations: [`mass_matrix_crba `](@ref), [`velocity_quadratic_forces`](@ref),
12771277 [`gravity_forces`](@ref), and [`end_effector_forces`](@ref) are all computed by
12781278 calling this function with specific inputs zeroed out.
12791279
@@ -1292,14 +1292,14 @@ The ``n``-vector of required joint forces/torques.
12921292
12931293# Examples
12941294```jldoctest; setup = :(using ModernRoboticsBook)
1295- julia> inverse_dynamics ([0.1, 0.1, 0.1], [0.1, 0.2, 0.3], [2, 1.5, 1], [0, 0, -9.8], [1, 1, 1, 1, 1, 1], link_frames, spatial_inertias, screw_axes)
1295+ julia> inverse_dynamics_rnea ([0.1, 0.1, 0.1], [0.1, 0.2, 0.3], [2, 1.5, 1], [0, 0, -9.8], [1, 1, 1, 1, 1, 1], link_frames, spatial_inertias, screw_axes)
129612963-element Vector{Float64}:
12971297 74.6961615528745
12981298 -33.067660158514585
12991299 -3.2305731379014246
13001300```
13011301"""
1302- function inverse_dynamics (
1302+ function inverse_dynamics_rnea (
13031303 joint_positions:: AbstractVector ,
13041304 joint_velocities:: AbstractVector ,
13051305 joint_accelerations:: AbstractVector ,
@@ -1315,7 +1315,7 @@ function inverse_dynamics(
13151315 AdTi = Vector {SMatrix{6,6,Float64,36}} (undef, n + 1 )
13161316 Vi = Vector {SVector{6,Float64}} (undef, n + 1 )
13171317 Vdi = Vector {SVector{6,Float64}} (undef, n + 1 )
1318- inverse_dynamics ! (
1318+ inverse_dynamics_rnea ! (
13191319 joint_torques,
13201320 joint_positions,
13211321 joint_velocities,
@@ -1333,13 +1333,13 @@ function inverse_dynamics(
13331333end
13341334
13351335"""
1336- inverse_dynamics !(joint_torques, joint_positions, joint_velocities, joint_accelerations, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes, Ai, AdTi, Vi, Vdi)
1336+ inverse_dynamics_rnea !(joint_torques, joint_positions, joint_velocities, joint_accelerations, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes, Ai, AdTi, Vi, Vdi)
13371337
1338- In-place version of [`inverse_dynamics `](@ref). Writes the result into `joint_torques`.
1338+ In-place version of [`inverse_dynamics_rnea `](@ref). Writes the result into `joint_torques`.
13391339The workspace vectors `Ai` (length n), `AdTi` (length n+1), `Vi` (length n+1),
13401340and `Vdi` (length n+1) must be pre-allocated.
13411341"""
1342- function inverse_dynamics ! (
1342+ function inverse_dynamics_rnea ! (
13431343 joint_torques:: AbstractVector ,
13441344 joint_positions:: AbstractVector ,
13451345 joint_velocities:: AbstractVector ,
@@ -1386,7 +1386,7 @@ function inverse_dynamics!(
13861386end
13871387
13881388"""
1389- mass_matrix (joint_positions, link_frames, spatial_inertias, screw_axes)
1389+ mass_matrix_crba (joint_positions, link_frames, spatial_inertias, screw_axes)
13901390
13911391Computes the mass matrix ``M(\\ theta)`` of an open chain robot using the
13921392**Composite Rigid Body Algorithm (CRBA)**.
@@ -1401,7 +1401,7 @@ Computes the mass matrix ``M(\\theta)`` of an open chain robot using the
14011401
14021402!!! details "Educational note"
14031403 The textbook (Chapter 8.2) teaches a simpler approach that calls
1404- [`inverse_dynamics `](@ref) ``n`` times with unit accelerations: "what torques
1404+ [`inverse_dynamics_rnea `](@ref) ``n`` times with unit accelerations: "what torques
14051405 are needed for unit acceleration of joint ``i``?" Each call produces one column
14061406 of ``M(\\ theta)``. This builds intuition but requires ``n`` full Newton-Euler
14071407 passes. CRBA computes the same result with one forward pass and one backward
@@ -1419,14 +1419,14 @@ The ``n×n`` mass matrix ``M(\\theta)``.
14191419
14201420# Examples
14211421```jldoctest; setup = :(using ModernRoboticsBook)
1422- julia> mass_matrix ([0.1, 0.1, 0.1], link_frames, spatial_inertias, screw_axes)
1422+ julia> mass_matrix_crba ([0.1, 0.1, 0.1], link_frames, spatial_inertias, screw_axes)
142314233×3 Matrix{Float64}:
14241424 22.5433 -0.307147 -0.00718426
14251425 -0.307147 1.96851 0.432157
14261426 -0.00718426 0.432157 0.191631
14271427```
14281428"""
1429- function mass_matrix (
1429+ function mass_matrix_crba (
14301430 joint_positions:: AbstractVector ,
14311431 link_frames:: AbstractVector ,
14321432 spatial_inertias:: AbstractVector ,
@@ -1437,7 +1437,7 @@ function mass_matrix(
14371437 Ai = Vector {SVector{6,Float64}} (undef, n)
14381438 AdTi = Vector {SMatrix{6,6,Float64,36}} (undef, n + 1 )
14391439 Gc = Vector {SMatrix{6,6,Float64,36}} (undef, n)
1440- mass_matrix ! (
1440+ mass_matrix_crba ! (
14411441 M,
14421442 joint_positions,
14431443 link_frames,
@@ -1450,13 +1450,13 @@ function mass_matrix(
14501450end
14511451
14521452"""
1453- mass_matrix !(M, joint_positions, link_frames, spatial_inertias, screw_axes, Ai, AdTi, Gc)
1453+ mass_matrix_crba !(M, joint_positions, link_frames, spatial_inertias, screw_axes, Ai, AdTi, Gc)
14541454
1455- In-place version of [`mass_matrix `](@ref) using the Composite Rigid Body Algorithm (CRBA).
1455+ In-place version of [`mass_matrix_crba `](@ref) using the Composite Rigid Body Algorithm (CRBA).
14561456Writes the result into `M`. The workspace vectors `Ai` (length n), `AdTi` (length n+1),
14571457and `Gc` (length n) must be pre-allocated.
14581458"""
1459- function mass_matrix ! (
1459+ function mass_matrix_crba ! (
14601460 M:: AbstractMatrix ,
14611461 joint_positions:: AbstractVector ,
14621462 link_frames:: AbstractVector ,
@@ -1507,8 +1507,8 @@ end
15071507 mass_matrix_rnea(joint_positions, link_frames, spatial_inertias, screw_axes)
15081508
15091509Computes the mass matrix using the textbook algorithm (Chapter 8.2): calls
1510- [`inverse_dynamics `](@ref) ``n`` times, each with a unit acceleration vector.
1511- This is slower than [`mass_matrix `](@ref) (which uses CRBA) but directly
1510+ [`inverse_dynamics_rnea `](@ref) ``n`` times, each with a unit acceleration vector.
1511+ This is slower than [`mass_matrix_crba `](@ref) (which uses CRBA) but directly
15121512illustrates that column ``i`` of ``M(\\ theta)`` is the torque needed for unit
15131513acceleration of joint ``i``.
15141514"""
@@ -1526,7 +1526,7 @@ function mass_matrix_rnea(
15261526 zero_F = zeros (6 )
15271527 for i = 1 : n
15281528 ddq[i] = 1
1529- M[:, i] = inverse_dynamics (
1529+ M[:, i] = inverse_dynamics_rnea (
15301530 joint_positions,
15311531 zero_dq,
15321532 ddq,
@@ -1545,7 +1545,7 @@ end
15451545 velocity_quadratic_forces(joint_positions, joint_velocities, link_frames, spatial_inertias, screw_axes)
15461546
15471547Computes the Coriolis and centripetal terms ``c(\\ theta, \\ dot{\\ theta})`` in the inverse
1548- dynamics of an open chain robot. Calls [`inverse_dynamics `](@ref) with `gravity = 0`,
1548+ dynamics of an open chain robot. Calls [`inverse_dynamics_rnea `](@ref) with `gravity = 0`,
15491549`tip_wrench = 0`, and `joint_accelerations = 0`.
15501550
15511551# Arguments
@@ -1574,7 +1574,7 @@ function velocity_quadratic_forces(
15741574 spatial_inertias:: AbstractVector ,
15751575 screw_axes:: AbstractMatrix ,
15761576)
1577- inverse_dynamics (
1577+ inverse_dynamics_rnea (
15781578 joint_positions,
15791579 joint_velocities,
15801580 zeros (length (joint_positions)),
@@ -1590,7 +1590,7 @@ end
15901590 gravity_forces(joint_positions, gravity, link_frames, spatial_inertias, screw_axes)
15911591
15921592Computes the joint forces/torques an open chain robot requires to overcome gravity at
1593- its configuration. Calls [`inverse_dynamics `](@ref) with `joint_velocities = 0`,
1593+ its configuration. Calls [`inverse_dynamics_rnea `](@ref) with `joint_velocities = 0`,
15941594`joint_accelerations = 0`, and `tip_wrench = 0`.
15951595
15961596# Arguments
@@ -1620,7 +1620,7 @@ function gravity_forces(
16201620 screw_axes:: AbstractMatrix ,
16211621)
16221622 n = length (joint_positions)
1623- inverse_dynamics (
1623+ inverse_dynamics_rnea (
16241624 joint_positions,
16251625 zeros (n),
16261626 zeros (n),
@@ -1645,7 +1645,7 @@ Computes the joint forces/torques an open chain robot requires only to create th
16451645- `screw_axes`: the screw axes `Si` of the joints in a space frame, in the format of a matrix with axes as the columns.
16461646
16471647Returns the joint forces and torques required only to create the end-effector force `tip_wrench`.
1648- This function calls inverse_dynamics with `gravity = 0`, `joint_velocities = 0`, and `joint_accelerations = 0`.
1648+ This function calls inverse_dynamics_rnea with `gravity = 0`, `joint_velocities = 0`, and `joint_accelerations = 0`.
16491649
16501650# Examples
16511651```jldoctest; setup = :(using ModernRoboticsBook)
@@ -1772,7 +1772,7 @@ function end_effector_forces(
17721772 screw_axes:: AbstractMatrix ,
17731773)
17741774 n = length (joint_positions)
1775- inverse_dynamics (
1775+ inverse_dynamics_rnea (
17761776 joint_positions,
17771777 zeros (n),
17781778 zeros (n),
@@ -1785,7 +1785,7 @@ function end_effector_forces(
17851785end
17861786
17871787"""
1788- forward_dynamics (joint_positions, joint_velocities, joint_torques, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes)
1788+ forward_dynamics_crba (joint_positions, joint_velocities, joint_torques, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes)
17891789
17901790Computes forward dynamics in the space frame for an open chain robot.
17911791
@@ -1797,13 +1797,13 @@ Computes forward dynamics in the space frame for an open chain robot.
17971797 \\ ddot{\\ theta} = M(\\ theta)^{-1} \\ left[ \\ tau - c(\\ theta,\\ dot{\\ theta}) - g(\\ theta) - J^T(\\ theta) \\ mathcal{F}_{\\ text{tip}} \\ right]
17981798 ```
17991799
1800- where ``M`` is the [mass matrix](@ref mass_matrix ) (computed via CRBA), and the
1801- right-hand side is computed via a single [`inverse_dynamics `](@ref) call with zero
1800+ where ``M`` is the [mass matrix](@ref mass_matrix_crba ) (computed via CRBA), and the
1801+ right-hand side is computed via a single [`inverse_dynamics_rnea `](@ref) call with zero
18021802 accelerations that captures velocity-dependent, gravitational, and tip wrench forces.
18031803
18041804!!! details "Educational note"
18051805 The textbook computes forward dynamics by explicitly forming ``M^{-1}`` and calling
1806- [`inverse_dynamics `](@ref) separately for Coriolis, gravity, and tip wrench terms.
1806+ [`inverse_dynamics_rnea `](@ref) separately for Coriolis, gravity, and tip wrench terms.
18071807 This implementation combines these into a single RNEA call and uses `M \\ b` (LU
18081808 factorization) instead of explicit inversion, which is both faster and more
18091809 numerically stable. See [`forward_dynamics_rnea`](@ref) for the textbook algorithm.
@@ -1823,14 +1823,14 @@ The ``n``-vector of joint accelerations ``\\ddot{\\theta}``.
18231823
18241824# Examples
18251825```jldoctest; setup = :(using ModernRoboticsBook)
1826- julia> forward_dynamics ([0.1, 0.1, 0.1], [0.1, 0.2, 0.3], [0.5, 0.6, 0.7], [0, 0, -9.8], [1, 1, 1, 1, 1, 1], link_frames, spatial_inertias, screw_axes)
1826+ julia> forward_dynamics_crba ([0.1, 0.1, 0.1], [0.1, 0.2, 0.3], [0.5, 0.6, 0.7], [0, 0, -9.8], [1, 1, 1, 1, 1, 1], link_frames, spatial_inertias, screw_axes)
182718273-element Vector{Float64}:
18281828 -0.9739290670855625
18291829 25.584667840340547
18301830 -32.91499212478147
18311831```
18321832"""
1833- function forward_dynamics (
1833+ function forward_dynamics_crba (
18341834 joint_positions:: AbstractVector ,
18351835 joint_velocities:: AbstractVector ,
18361836 joint_torques:: AbstractVector ,
@@ -1841,9 +1841,9 @@ function forward_dynamics(
18411841 screw_axes:: AbstractMatrix ,
18421842)
18431843 # Use the explicit M⁻¹(τ - c - g - J^T F_tip) approach with CRBA for the mass matrix
1844- mass = mass_matrix (joint_positions, link_frames, spatial_inertias, screw_axes)
1844+ mass = mass_matrix_crba (joint_positions, link_frames, spatial_inertias, screw_axes)
18451845 tau_rhs =
1846- joint_torques - inverse_dynamics (
1846+ joint_torques - inverse_dynamics_rnea (
18471847 joint_positions,
18481848 joint_velocities,
18491849 zeros (length (joint_positions)),
@@ -1860,8 +1860,8 @@ end
18601860 forward_dynamics_rnea(joint_positions, joint_velocities, joint_torques, gravity, tip_wrench, link_frames, spatial_inertias, screw_axes)
18611861
18621862Computes forward dynamics using the textbook algorithm (Chapter 8.3): explicitly
1863- forms ``M^{-1}`` and calls [`inverse_dynamics `](@ref) separately for Coriolis,
1864- gravity, and tip wrench terms. This is slower than [`forward_dynamics `](@ref)
1863+ forms ``M^{-1}`` and calls [`inverse_dynamics_rnea `](@ref) separately for Coriolis,
1864+ gravity, and tip wrench terms. This is slower than [`forward_dynamics_crba `](@ref)
18651865(which uses CRBA + single RNEA + backslash) but directly mirrors the textbook
18661866equation ``\\ ddot{\\ theta} = M^{-1}[\\ tau - c - g - J^T F_{\\ text{tip}}]``.
18671867"""
@@ -1875,7 +1875,7 @@ function forward_dynamics_rnea(
18751875 spatial_inertias:: AbstractVector ,
18761876 screw_axes:: AbstractMatrix ,
18771877)
1878- LA. inv (mass_matrix (joint_positions, link_frames, spatial_inertias, screw_axes)) * (
1878+ LA. inv (mass_matrix_crba (joint_positions, link_frames, spatial_inertias, screw_axes)) * (
18791879 joint_torques - velocity_quadratic_forces (
18801880 joint_positions,
18811881 joint_velocities,
@@ -1933,7 +1933,7 @@ end
19331933 inverse_dynamics_trajectory(joint_position_traj, joint_velocity_traj, joint_acceleration_traj, gravity, tip_wrench_traj, link_frames, spatial_inertias, screw_axes)
19341934
19351935Calculates the joint forces/torques required to move the serial chain along the given
1936- trajectory using [`inverse_dynamics `](@ref) at each timestep.
1936+ trajectory using [`inverse_dynamics_rnea `](@ref) at each timestep.
19371937
19381938# Arguments
19391939- `joint_position_traj`: an ``N×n`` matrix of joint variables, where row ``i`` is the joint vector at timestep ``i``.
@@ -1980,7 +1980,7 @@ function inverse_dynamics_trajectory(
19801980 joint_torque_traj = copy (joint_position_traj)
19811981
19821982 for i in axes (joint_position_traj, 2 )
1983- joint_torque_traj[:, i] = inverse_dynamics (
1983+ joint_torque_traj[:, i] = inverse_dynamics_rnea (
19841984 joint_position_traj[:, i],
19851985 joint_velocity_traj[:, i],
19861986 joint_acceleration_traj[:, i],
@@ -1999,7 +1999,7 @@ end
19991999 forward_dynamics_trajectory(joint_positions, joint_velocities, joint_torque_traj, gravity, tip_wrench_traj, link_frames, spatial_inertias, screw_axes, timestep, integration_resolution)
20002000
20012001Simulates the motion of a serial chain given an open-loop history of joint
2002- forces/torques. Uses [`forward_dynamics `](@ref) with [`euler_step`](@ref) integration at
2002+ forces/torques. Uses [`forward_dynamics_crba `](@ref) with [`euler_step`](@ref) integration at
20032003each timestep.
20042004
20052005# Arguments
@@ -2052,7 +2052,7 @@ function forward_dynamics_trajectory(
20522052
20532053 for i = first (axes (joint_torque_traj, 2 )): (last (axes (joint_torque_traj, 2 ))- 1 )
20542054 for j = 1 : integration_resolution
2055- joint_accelerations = forward_dynamics (
2055+ joint_accelerations = forward_dynamics_crba (
20562056 joint_positions,
20572057 joint_velocities,
20582058 joint_torque_traj[:, i],
@@ -2384,11 +2384,11 @@ function computed_torque(
23842384 Kd:: Number ,
23852385)
23862386 e = desired_joint_positions - joint_positions
2387- mass_matrix (joint_positions, link_frames, spatial_inertias, screw_axes) * (
2387+ mass_matrix_crba (joint_positions, link_frames, spatial_inertias, screw_axes) * (
23882388 Kp * e +
23892389 Ki * (error_integral + e) +
23902390 Kd * (desired_joint_velocities - joint_velocities)
2391- ) + inverse_dynamics (
2391+ ) + inverse_dynamics_rnea (
23922392 joint_positions,
23932393 joint_velocities,
23942394 desired_joint_accelerations,
@@ -2404,7 +2404,7 @@ end
24042404 simulate_control(joint_positions, joint_velocities, gravity, tip_wrench_traj, link_frames, spatial_inertias, screw_axes, desired_joint_position_traj, desired_joint_velocity_traj, desired_joint_acceleration_traj, estimated_gravity, estimated_link_frames, estimated_spatial_inertias, Kp, Ki, Kd, timestep, integration_resolution)
24052405
24062406Simulates the [`computed_torque`](@ref) controller over a given desired trajectory using
2407- [`forward_dynamics `](@ref) and numerical integration. The controller may use different
2407+ [`forward_dynamics_crba `](@ref) and numerical integration. The controller may use different
24082408(possibly inaccurate) dynamics parameters
24092409(`estimated_gravity`, `estimated_link_frames`, `estimated_spatial_inertias`) while the
24102410actual forward dynamics simulation uses the true parameters (`gravity`, `link_frames`,
@@ -2509,7 +2509,7 @@ function simulate_control(
25092509 )
25102510
25112511 for j = 1 : integration_resolution
2512- joint_accelerations = forward_dynamics (
2512+ joint_accelerations = forward_dynamics_crba (
25132513 current_positions,
25142514 current_velocities,
25152515 joint_torques,
0 commit comments