@@ -72,18 +72,63 @@ Transform chains
7272The :func: `~roboticstoolbox.tools.trchain.trchain ` and
7373:func: `~roboticstoolbox.tools.trchain.trchain2 ` functions provide the compact
7474string notation used by the MATLAB Toolbox for one-off SE(3) and SE(2)
75- transform chains. Joint variables are numbered from one, while named
75+ transform chains.
76+
77+ Three-dimensional chains contain rotations and translations about or along
78+ any Cartesian axis. Joint variables are numbered from one, and named
7679constants are passed explicitly in ``variables ``.
7780
7881.. runblock :: pycon
7982
8083 >>> import roboticstoolbox as rtb
81- >>> rtb.trchain(" Rz(q1) Tx(a)" , [0.3 ], variables = {" a" : 1 })
82- >>> rtb.trchain2(" R(q1) Tx(a)" , [0.3 ], variables = {" a" : 1 })
84+ >>> q = [0.2 , - 0.3 , 0.4 ]
85+ >>> rtb.trchain(" Rx(q1) Ry(q2) Rz(q3) Tx(x) Ty(y) Tz(z)" , q,
86+ ... variables= {" x" : 0.5 , " y" : 0.2 , " z" : 0.1 })
87+
88+ Arguments can use arithmetic, the names ``pi ``, ``sin ``, ``cos ``, ``tan `` and
89+ ``sqrt ``, or functions supplied in ``variables ``. The joint prefix and angle
90+ unit can also be changed.
91+
92+ .. runblock :: pycon
93+
94+ >>> import roboticstoolbox as rtb
95+ >>> rtb.trchain(" Rz(pi / 2) Tx(sqrt(4)) Ty(sin(pi / 2) + cos(0) + tan(0))" )
96+ >>> double = lambda value : 2 * value
97+ >>> rtb.trchain(" Rz(theta1 - 45) Tx(double(a))" , [90 ], unit = " deg" ,
98+ ... qvar= " theta" , variables= {" a" : 0.5 , " double" : double})
99+
100+ For planar motion, :func: `~roboticstoolbox.tools.trchain.trchain2 ` accepts
101+ ``R `` (or ``Rz ``), ``Tx `` and ``Ty `` transforms.
102+
103+ .. runblock :: pycon
104+
105+ >>> import numpy as np
106+ >>> import roboticstoolbox as rtb
107+ >>> rtb.trchain2(" R(q1) Tx(L1) Rz(q2) Tx(L2) Ty(y)" ,
108+ ... [np.pi / 2 , - np.pi / 2 ],
109+ ... variables= {" L1" : 1 , " L2" : 0.5 , " y" : 0.25 })
83110
84111Parsed tokens can also be returned and reused when evaluating the same chain
85112for different joint values.
86113
114+ .. runblock :: pycon
115+
116+ >>> import roboticstoolbox as rtb
117+ >>> _, tokens = rtb.trchain(" Rz(q1) Tx(a)" , [0 ], variables = {" a" : 1 },
118+ ... return_tokens= True )
119+ >>> tokens
120+ >>> rtb.trchain(tokens, [0.5 ], variables = {" a" : 1 })
121+
122+ Joint values and named constants can be symbolic.
123+
124+ .. runblock :: pycon
125+
126+ >>> import roboticstoolbox as rtb
127+ >>> import sympy
128+ >>> q, a = sympy.symbols(" q a" , real = True )
129+ >>> T = rtb.trchain(" Rz(q1) Tx(a)" , [q], variables = {" a" : a})
130+ >>> T[0 , 0 ], T[0 , 3 ], T[1 , 3 ]
131+
87132.. autofunction :: roboticstoolbox.tools.trchain.trchain
88133
89134.. autofunction :: roboticstoolbox.tools.trchain.trchain2
0 commit comments