@@ -42,11 +42,11 @@ def angle_axis_python(T, Td):
42
42
return e
43
43
44
44
45
- def p_servo (
45
+ def cp_servo (
46
46
wTe , wTep , gain : Union [float , ArrayLike ] = 1.0 , threshold = 0.1 , method = "rpy"
47
47
):
48
48
"""
49
- Position -based servoing.
49
+ Cartesian position -based servoing.
50
50
51
51
Returns the end-effector velocity which will cause the robot to approach
52
52
the desired pose.
@@ -104,6 +104,40 @@ def p_servo(
104
104
105
105
return v , arrived
106
106
107
+ def jp_servo (q , q_dest , gain : Union [float , ArrayLike ] = 1.0 , threshold = 0.1 ):
108
+ """
109
+ joint space position-based servoing.
110
+
111
+ Returns the joint velocities which will cause the robot to approach the desired joint positions.
112
+
113
+ :param q: The current joint positions of the robot.
114
+ :type q: ndarray
115
+ :param qd: The desired joint positions of the robot.
116
+ :type qd: ndarray
117
+ :param gain: The gain for the controller. Can be a scalar or a vector corresponding to each joint.
118
+ :type gain: float, or array-like
119
+ :param threshold: The threshold or tolerance of the final error between the robot's joint positions and desired joint positions.
120
+ :type threshold: float
121
+ :returns qdd: The joint velocities which will cause the robot to approach qd.
122
+ :rtype qdd: ndarray(n)
123
+ :returns arrived: True if the robot is within the threshold of the final joint positions.
124
+ :rtype arrived: bool
125
+ """
126
+ # Joint position error
127
+ e = q_dest - q
128
+
129
+ if base .isscalar (gain ):
130
+ k = gain * np .eye (len (q ))
131
+ else :
132
+ k = np .diag (gain )
133
+
134
+ # Joint velocities
135
+ qdd = k @ e
136
+
137
+ arrived = True if np .sum (np .abs (e )) < threshold else False
138
+
139
+ return qdd , arrived
140
+
107
141
def pid_servo (wTe , wTep , prev_error , integral_error , dt , gains , threshold = 0.1 , method = "rpy" ):
108
142
"""
109
143
Position-based servoing with PID control.
0 commit comments