|
6 | 6 |
|
7 | 7 | from crisp_py.robot import make_robot |
8 | 8 |
|
9 | | -left_arm = make_robot("fr3") |
10 | | -left_arm.wait_until_ready() |
| 9 | +robot = make_robot("fr3") |
| 10 | +robot.wait_until_ready() |
11 | 11 |
|
12 | 12 | # %% |
13 | | -print(left_arm.end_effector_pose) |
14 | | -print(left_arm.joint_values) |
| 13 | +print(robot.end_effector_pose) |
| 14 | +print(robot.joint_values) |
15 | 15 |
|
16 | 16 | # %% |
17 | 17 | print("Going to home position...") |
18 | | -left_arm.home() |
19 | | -homing_pose = left_arm.end_effector_pose.copy() |
| 18 | +robot.home() |
| 19 | +homing_pose = robot.end_effector_pose.copy() |
20 | 20 |
|
21 | 21 |
|
22 | 22 | # %% |
|
29 | 29 | max_time = 8.0 |
30 | 30 |
|
31 | 31 | # %% |
32 | | -left_arm.controller_switcher_client.switch_controller("cartesian_impedance_controller") |
33 | | -left_arm.cartesian_controller_parameters_client.load_param_config( |
| 32 | +robot.controller_switcher_client.switch_controller("cartesian_impedance_controller") |
| 33 | +robot.cartesian_controller_parameters_client.load_param_config( |
34 | 34 | # file_path="config/control/gravity_compensation.yaml" |
35 | 35 | # file_path="config/control/default_operational_space_controller.yaml" |
36 | 36 | # file_path="config/control/clipped_cartesian_impedance.yaml" |
|
39 | 39 |
|
40 | 40 | # %% |
41 | 41 | # The move_to function will publish a pose to /target_pose while interpolation linearly |
42 | | -left_arm.move_to(position=center, speed=0.15) |
| 42 | +robot.move_to(position=center, speed=0.15) |
43 | 43 |
|
44 | 44 | # %% |
45 | 45 | # The set_target will directly publish the pose to /target_pose |
|
49 | 49 |
|
50 | 50 | print("Starting to draw a circle...") |
51 | 51 | t = 0.0 |
52 | | -target_pose = left_arm.end_effector_pose.copy() |
53 | | -rate = left_arm.node.create_rate(ctrl_freq) |
| 52 | +target_pose = robot.end_effector_pose.copy() |
| 53 | +rate = robot.node.create_rate(ctrl_freq) |
54 | 54 |
|
55 | 55 | while t < max_time: |
56 | 56 | x = center[0] |
57 | 57 | y = radius * np.sin(2 * np.pi * sin_freq_y * t) + center[1] |
58 | 58 | z = radius * np.sin(2 * np.pi * sin_freq_z * t) + center[2] |
59 | 59 | target_pose.position = np.array([x, y, z]) |
60 | 60 |
|
61 | | - left_arm.set_target(pose=target_pose) |
| 61 | + robot.set_target(pose=target_pose) |
62 | 62 |
|
63 | 63 | rate.sleep() |
64 | 64 |
|
65 | | - ee_poses.append(left_arm.end_effector_pose.copy()) |
66 | | - target_poses.append(left_arm._target_pose.copy()) |
| 65 | + ee_poses.append(robot.end_effector_pose.copy()) |
| 66 | + target_poses.append(robot._target_pose.copy()) |
67 | 67 | ts.append(t) |
68 | 68 |
|
69 | 69 | t += 1.0 / ctrl_freq |
|
73 | 73 |
|
74 | 74 | rate.sleep() |
75 | 75 |
|
76 | | - ee_poses.append(left_arm.end_effector_pose.copy()) |
77 | | - target_poses.append(left_arm._target_pose.copy()) |
| 76 | + ee_poses.append(robot.end_effector_pose.copy()) |
| 77 | + target_poses.append(robot._target_pose.copy()) |
78 | 78 | ts.append(t) |
79 | 79 |
|
80 | 80 | t += 1.0 / ctrl_freq |
|
114 | 114 | # %% |
115 | 115 |
|
116 | 116 | print("Going back home.") |
117 | | -left_arm.home() |
| 117 | +robot.home() |
118 | 118 |
|
119 | 119 | # %% |
120 | | -left_arm.shutdown() |
| 120 | +robot.shutdown() |
0 commit comments