@@ -26,9 +26,13 @@ export near_zero,
2626 is_so3,
2727 is_se3,
2828 forward_kinematics_body,
29+ forward_kinematics_body!,
2930 forward_kinematics_space,
31+ forward_kinematics_space!,
3032 jacobian_body,
33+ jacobian_body!,
3134 jacobian_space,
35+ jacobian_space!,
3236 inverse_kinematics_body,
3337 inverse_kinematics_space,
3438 ad,
@@ -797,7 +801,7 @@ julia> body_screw_axes = [ 0 0 -1 2 0 0 ;
797801julia> joint_positions = [ π/2, 3, π ];
798802
799803julia> forward_kinematics_body(home_ee_pose, body_screw_axes, joint_positions)
800- 4×4 StaticArraysCore.SMatrix{4, 4, Float64, 16} with indices SOneTo(4)×SOneTo(4) :
804+ 4×4 Matrix{ Float64} :
801805 -1.14424e-17 1.0 0.0 -5.0
802806 1.0 1.14424e-17 0.0 4.0
803807 0.0 0.0 -1.0 1.68584
@@ -809,11 +813,27 @@ function forward_kinematics_body(
809813 body_screw_axes:: AbstractMatrix ,
810814 joint_positions:: AbstractVector ,
811815)
812- T = SMatrix {4,4} (home_ee_pose)
816+ T = similar (home_ee_pose, Float64, 4 , 4 )
817+ forward_kinematics_body! (T, home_ee_pose, body_screw_axes, joint_positions)
818+ end
819+
820+ """
821+ forward_kinematics_body!(T, home_ee_pose, body_screw_axes, joint_positions)
822+
823+ In-place version of [`forward_kinematics_body`](@ref). Writes the result into `T`.
824+ """
825+ function forward_kinematics_body! (
826+ T:: AbstractMatrix ,
827+ home_ee_pose:: AbstractMatrix ,
828+ body_screw_axes:: AbstractMatrix ,
829+ joint_positions:: AbstractVector ,
830+ )
831+ Ts = SMatrix {4,4} (home_ee_pose)
813832 for i in eachindex (joint_positions)
814833 Bi = SVector {6} (@view body_screw_axes[:, i])
815- T = T * matrix_exp6 (vec_to_se3 (Bi * joint_positions[i]))
834+ Ts = Ts * matrix_exp6 (vec_to_se3 (Bi * joint_positions[i]))
816835 end
836+ T .= Ts
817837 T
818838end
819839
@@ -859,7 +879,7 @@ julia> screw_axes = [ 0 0 1 4 0 0 ;
859879julia> joint_positions = [ π/2, 3, π ];
860880
861881julia> forward_kinematics_space(home_ee_pose, screw_axes, joint_positions)
862- 4×4 StaticArraysCore.SMatrix{4, 4, Float64, 16} with indices SOneTo(4)×SOneTo(4) :
882+ 4×4 Matrix{ Float64} :
863883 -1.14424e-17 1.0 0.0 -5.0
864884 1.0 1.14424e-17 0.0 4.0
865885 0.0 0.0 -1.0 1.68584
@@ -871,11 +891,27 @@ function forward_kinematics_space(
871891 screw_axes:: AbstractMatrix ,
872892 joint_positions:: AbstractVector ,
873893)
874- T = SMatrix {4,4} (home_ee_pose)
894+ T = similar (home_ee_pose, Float64, 4 , 4 )
895+ forward_kinematics_space! (T, home_ee_pose, screw_axes, joint_positions)
896+ end
897+
898+ """
899+ forward_kinematics_space!(T, home_ee_pose, screw_axes, joint_positions)
900+
901+ In-place version of [`forward_kinematics_space`](@ref). Writes the result into `T`.
902+ """
903+ function forward_kinematics_space! (
904+ T:: AbstractMatrix ,
905+ home_ee_pose:: AbstractMatrix ,
906+ screw_axes:: AbstractMatrix ,
907+ joint_positions:: AbstractVector ,
908+ )
909+ Ts = SMatrix {4,4} (home_ee_pose)
875910 for i in reverse (eachindex (joint_positions))
876911 Si = SVector {6} (@view screw_axes[:, i])
877- T = matrix_exp6 (vec_to_se3 (Si * joint_positions[i])) * T
912+ Ts = matrix_exp6 (vec_to_se3 (Si * joint_positions[i])) * Ts
878913 end
914+ T .= Ts
879915 T
880916end
881917
@@ -921,8 +957,22 @@ julia> jacobian_body(body_screw_axes, joint_positions)
921957```
922958"""
923959function jacobian_body (body_screw_axes:: AbstractMatrix , joint_positions:: AbstractVector )
960+ Jb = similar (body_screw_axes, Float64)
961+ jacobian_body! (Jb, body_screw_axes, joint_positions)
962+ end
963+
964+ """
965+ jacobian_body!(Jb, body_screw_axes, joint_positions)
966+
967+ In-place version of [`jacobian_body`](@ref). Writes the result into `Jb`.
968+ """
969+ function jacobian_body! (
970+ Jb:: AbstractMatrix ,
971+ body_screw_axes:: AbstractMatrix ,
972+ joint_positions:: AbstractVector ,
973+ )
974+ Jb .= body_screw_axes
924975 T = SMatrix {4,4,Float64} (LA. I)
925- Jb = copy (body_screw_axes)
926976 for i in Iterators. reverse (firstindex (joint_positions): (lastindex (joint_positions)- 1 ))
927977 Bi1 = SVector {6} (@view body_screw_axes[:, i+ 1 ])
928978 T = T * matrix_exp6 (vec_to_se3 (Bi1 * - joint_positions[i+ 1 ]))
@@ -970,8 +1020,22 @@ julia> jacobian_space(screw_axes, joint_positions)
9701020```
9711021"""
9721022function jacobian_space (screw_axes:: AbstractMatrix , joint_positions:: AbstractVector )
1023+ Js = similar (screw_axes, Float64)
1024+ jacobian_space! (Js, screw_axes, joint_positions)
1025+ end
1026+
1027+ """
1028+ jacobian_space!(Js, screw_axes, joint_positions)
1029+
1030+ In-place version of [`jacobian_space`](@ref). Writes the result into `Js`.
1031+ """
1032+ function jacobian_space! (
1033+ Js:: AbstractMatrix ,
1034+ screw_axes:: AbstractMatrix ,
1035+ joint_positions:: AbstractVector ,
1036+ )
1037+ Js .= screw_axes
9731038 T = SMatrix {4,4,Float64} (LA. I)
974- Js = copy (screw_axes)
9751039 for i = (firstindex (joint_positions)+ 1 ): lastindex (joint_positions)
9761040 Si1 = SVector {6} (@view screw_axes[:, i- 1 ])
9771041 T = T * matrix_exp6 (vec_to_se3 (Si1 * joint_positions[i- 1 ]))
0 commit comments