|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -from pybullet_tree_sim.camera import Camera |
3 |
| -from pybullet_tree_sim.time_of_flight import TimeOfFlight |
4 | 2 | from pybullet_tree_sim.pruning_environment import PruningEnv
|
5 | 3 | from pybullet_tree_sim.robot import Robot
|
6 | 4 | from pybullet_tree_sim.tree import Tree
|
@@ -50,24 +48,29 @@ def main():
|
50 | 48 | try:
|
51 | 49 | # log.debug(f"{robot.sensors['tof0']}")
|
52 | 50 | tof0_view_matrix = robot.get_view_mat_at_curr_pose(camera=robot.sensors["tof0"])
|
53 |
| - tof0_rgbd = penv.pbutils.get_rgbd_at_cur_pose( |
54 |
| - camera=robot.sensors["tof0"], type="robot", view_matrix=tof0_view_matrix |
| 51 | + tof0_rgbd = robot.get_rgbd_at_cur_pose( |
| 52 | + camera=robot.sensors["tof0"], type="sensor", view_matrix=tof0_view_matrix |
55 | 53 | )
|
56 | 54 | tof1_view_matrix = robot.get_view_mat_at_curr_pose(camera=robot.sensors["tof1"])
|
57 |
| - tof1_rgbd = penv.pbutils.get_rgbd_at_cur_pose( |
58 |
| - camera=robot.sensors["tof1"], type="robot", view_matrix=tof1_view_matrix |
| 55 | + tof1_rgbd = robot.get_rgbd_at_cur_pose( |
| 56 | + camera=robot.sensors["tof1"], type="sensor", view_matrix=tof1_view_matrix |
59 | 57 | )
|
60 | 58 | # tof0_view_matrix = np.asarray(tof0_view_matrix).reshape((4, 4), order="F")
|
61 | 59 | # log.debug(f"{tof0_view_matrix[:3, 3]}")
|
62 | 60 |
|
| 61 | + # Get user keyboard input, map to robot movement, camera capture, controller action |
63 | 62 | keys_pressed = penv.get_key_pressed()
|
64 |
| - action = penv.get_key_action(robot=robot, keys_pressed=keys_pressed) |
65 |
| - action = action.reshape((6, 1)) |
66 |
| - joint_vel, jacobian = robot.calculate_joint_velocities_from_ee_velocity_dls(end_effector_velocity=action) |
67 |
| - robot.action = joint_vel |
68 |
| - singularity = robot.set_joint_velocities(robot.action) |
69 |
| - penv.pbutils.pbclient.stepSimulation() |
70 |
| - time.sleep(0.01) |
| 63 | + move_action = robot.get_key_move_action(keys_pressed=keys_pressed) |
| 64 | + sensor_data = robot.get_key_sensor_action(keys_pressed=keys_pressed) |
| 65 | + |
| 66 | + joint_vels, jacobian = robot.calculate_joint_velocities_from_ee_velocity_dls( |
| 67 | + end_effector_velocity=move_action |
| 68 | + ) |
| 69 | + singularity = robot.set_joint_velocities(joint_velocities=joint_vels) |
| 70 | + |
| 71 | + # Step simulation |
| 72 | + pbutils.pbclient.stepSimulation() |
| 73 | + time.sleep(0.001) |
71 | 74 | except KeyboardInterrupt:
|
72 | 75 | break
|
73 | 76 |
|
|
0 commit comments