11#!/usr/bin/env python3
2-
2+ from pybullet_tree_sim .camera import Camera
3+ from pybullet_tree_sim .time_of_flight import TimeOfFlight
34from pybullet_tree_sim .pruning_environment import PruningEnv
45from pybullet_tree_sim .tree import Tree
56from pybullet_tree_sim .utils .pyb_utils import PyBUtils
1112from zenlog import log
1213
1314
14- def main ():
15- # TODO: CLI args?
16- cam_dfov = 65
17- cam_height = 8
18- cam_width = 8
15+ def main ():
16+ pbutils = PyBUtils (renders = False )
17+
18+ # Init sensors
19+ sensor_config = {
20+ "camera0" : {
21+ 'sensor' : Camera (pbutils , sensor_name = "realsense_d435i" ),
22+ 'tf_frame' : "mock_pruner__camera0" ,
23+ }
24+ }
25+
1926
20- pbutils = PyBUtils ( renders = True , cam_width = cam_width , cam_height = cam_height , dfov = cam_dfov )
27+
2128 penv = PruningEnv (
22- pbutils = pbutils , load_robot = True , robot_pos = [0 , 1 , 0 ], verbose = True , cam_width = cam_width , cam_height = cam_height
29+ pbutils = pbutils , load_robot = True , sensor_config = sensor_config , robot_pos = [0 , 2 , 0 ], verbose = True ,
2330 )
31+
2432
2533 penv .activate_shape (shape = "cylinder" , radius = 2 * 0.0254 , height = 2.0 , orientation = [0 , np .pi / 2 , 0 ])
2634 # penv.load_tree(
@@ -43,14 +51,14 @@ def main():
4351 # Simulation loop
4452 while True :
4553 try :
46- view_matrix = penv .ur5 .get_view_mat_at_curr_pose (0 , 0 , [ 0 , 0 , 0 ])
54+ tof0_view_matrix = penv .robot .get_view_mat_at_curr_pose (camera = penv . robot . sensors [ 'mock_pruner__camera0' ])
4755 rgbd = penv .pbutils .get_rgbd_at_cur_pose (type = "robot" , view_matrix = view_matrix )
4856 keys_pressed = penv .get_key_pressed ()
4957 action = penv .get_key_action (keys_pressed = keys_pressed )
5058 action = action .reshape ((6 , 1 ))
51- jv , jacobian = penv .ur5 .calculate_joint_velocities_from_ee_velocity_dls (end_effector_velocity = action )
52- penv .ur5 .action = jv
53- singularity = penv .ur5 .set_joint_velocities (penv .ur5 .action )
59+ jv , jacobian = penv .robot .calculate_joint_velocities_from_ee_velocity_dls (end_effector_velocity = action )
60+ penv .robot .action = jv
61+ singularity = penv .robot .set_joint_velocities (penv .robot .action )
5462 penv .pbutils .pbclient .stepSimulation ()
5563 time .sleep (0.01 )
5664 except KeyboardInterrupt :
0 commit comments