|
5 | 5 | import math |
6 | 6 |
|
7 | 7 |
|
8 | | -# def p_servo(wTe, wTep, gain=2, threshold=0.1): |
9 | | -# """ |
10 | | -# Position-based servoing. |
| 8 | +def p_servo_old(wTe, wTep, gain=2, threshold=0.1): |
| 9 | + """ |
| 10 | + Position-based servoing. |
| 11 | +
|
| 12 | + Returns the end-effector velocity which will cause the robot to approach |
| 13 | + the desired pose. |
| 14 | +
|
| 15 | + :param wTe: The current pose of the end-effecor in the base frame. |
| 16 | + :type wTe: SE3 |
| 17 | + :param wTep: The desired pose of the end-effecor in the base frame. |
| 18 | + :type wTep: SE3 |
| 19 | + :param gain: The gain for the controller |
| 20 | + :type gain: float |
| 21 | + :param threshold: The threshold or tolerance of the final error between |
| 22 | + the robot's pose and desired pose |
| 23 | + :type threshold: float |
| 24 | +
|
| 25 | + :returns v: The velocity of the end-effecotr which will casue the robot |
| 26 | + to approach wTep |
| 27 | + :rtype v: ndarray(6) |
| 28 | + :returns arrived: True if the robot is within the threshold of the final |
| 29 | + pose |
| 30 | + :rtype arrived: bool |
| 31 | +
|
| 32 | + """ |
11 | 33 |
|
12 | | -# Returns the end-effector velocity which will cause the robot to approach |
13 | | -# the desired pose. |
14 | | - |
15 | | -# :param wTe: The current pose of the end-effecor in the base frame. |
16 | | -# :type wTe: SE3 |
17 | | -# :param wTep: The desired pose of the end-effecor in the base frame. |
18 | | -# :type wTep: SE3 |
19 | | -# :param gain: The gain for the controller |
20 | | -# :type gain: float |
21 | | -# :param threshold: The threshold or tolerance of the final error between |
22 | | -# the robot's pose and desired pose |
23 | | -# :type threshold: float |
24 | | - |
25 | | -# :returns v: The velocity of the end-effecotr which will casue the robot |
26 | | -# to approach wTep |
27 | | -# :rtype v: ndarray(6) |
28 | | -# :returns arrived: True if the robot is within the threshold of the final |
29 | | -# pose |
30 | | -# :rtype arrived: bool |
31 | | - |
32 | | -# """ |
33 | | - |
34 | | -# if not isinstance(wTe, SE3): |
35 | | -# wTe = SE3(wTe) |
| 34 | + if not isinstance(wTe, SE3): |
| 35 | + wTe = SE3(wTe) |
36 | 36 |
|
37 | | -# if not isinstance(wTep, SE3): |
38 | | -# wTep = SE3(wTep) |
| 37 | + if not isinstance(wTep, SE3): |
| 38 | + wTep = SE3(wTep) |
39 | 39 |
|
40 | | -# # Pose difference |
41 | | -# eTep = wTe.inv() * wTep |
| 40 | + # Pose difference |
| 41 | + eTep = wTe.inv() * wTep |
42 | 42 |
|
43 | | -# # Translational error |
44 | | -# ev = eTep.t |
| 43 | + # Translational error |
| 44 | + ev = eTep.t |
45 | 45 |
|
46 | | -# # Angular error |
47 | | -# ew = eTep.rpy("rad") |
| 46 | + # Angular error |
| 47 | + ew = eTep.rpy("rad") |
48 | 48 |
|
49 | | -# # Form error vector |
50 | | -# e = np.r_[ev, ew] |
| 49 | + # Form error vector |
| 50 | + e = np.r_[ev, ew] |
51 | 51 |
|
52 | | -# # Desired end-effector velocity |
53 | | -# v = gain * e |
| 52 | + # Desired end-effector velocity |
| 53 | + v = gain * e |
54 | 54 |
|
55 | | -# if np.sum(np.abs(e)) < threshold: |
56 | | -# arrived = True |
57 | | -# else: |
58 | | -# arrived = False |
| 55 | + if np.sum(np.abs(e)) < threshold: |
| 56 | + arrived = True |
| 57 | + else: |
| 58 | + arrived = False |
59 | 59 |
|
60 | | -# return v, arrived |
| 60 | + return v, arrived |
61 | 61 |
|
62 | 62 |
|
63 | 63 | def _angle_axis(T, Td): |
|
0 commit comments