def main(args): """Test GUI application.""" client = BulletClient(pb.GUI) client.setGravity(0, 0, -10) client.resetDebugVisualizerCamera(cameraDistance=0.5, cameraYaw=-40.0, cameraPitch=-40.0, cameraTargetPosition=[0.0, 0.0, 0.0]) if args.dofs == 20: hand_model = HandModel20(left_hand=args.left_hand) elif args.dofs == 45: hand_model = HandModel45(left_hand=args.left_hand) else: raise ValueError('Only 20 and 45 DoF models are supported.') flags = sum([ HandBody.FLAG_ENABLE_COLLISION_SHAPES, HandBody.FLAG_ENABLE_VISUAL_SHAPES * args.visual, HandBody.FLAG_JOINT_LIMITS, HandBody.FLAG_DYNAMICS, HandBody.FLAG_USE_SELF_COLLISION * args.self_collisions ]) client.configureDebugVisualizer(pb.COV_ENABLE_RENDERING, 0) hand = HandBody(client, hand_model, flags=flags) client.configureDebugVisualizer(pb.COV_ENABLE_RENDERING, 1) slider_ids = [] for coord in ('X', 'Y', 'Z'): uid = client.addUserDebugParameter(f'base_{coord}', -0.5, 0.5, 0) slider_ids.append(uid) for coord in ('R', 'P', 'Y'): uid = client.addUserDebugParameter(f'base_{coord}', -3.14, 3.14, 0) slider_ids.append(uid) for i, joint in enumerate(hand_model.joints): name = hand_model.link_names[i] for axis, (lower, upper) in zip(joint.axes, joint.limits): uid = client.addUserDebugParameter(f'{name}[{axis}]', lower, upper, 0) slider_ids.append(uid) client.setRealTimeSimulation(True) try: while client.isConnected(): values = [client.readUserDebugParameter(uid) for uid in slider_ids] position = values[0:3] rotation = client.getQuaternionFromEuler(values[3:6]) angles = values[6:] hand.set_target(position, rotation, angles) except pb.error as err: if str(err) not in [ 'Not connected to physics server.', 'Failed to read parameter.' ]: raise
import pybullet_data import pybullet import time import random bc = BulletClient(connection_mode=pybullet.GUI) bc.setAdditionalSearchPath(pybullet_data.getDataPath()) bc.configureDebugVisualizer(bc.COV_ENABLE_Y_AXIS_UP, 1) bc.setGravity(0, -9.8, 0) motion = MotionCaptureData() motionPath = pybullet_data.getDataPath( ) + "/motions/humanoid3d_walk.txt" #humanoid3d_spinkick.txt"#/motions/humanoid3d_backflip.txt" motion.Load(motionPath) #print("numFrames = ", motion.NumFrames()) simTimeId = bc.addUserDebugParameter("simTime", 0, motion.NumFrames() - 1.1, 0) y2zOrn = bc.getQuaternionFromEuler([-1.57, 0, 0]) bc.loadURDF("plane.urdf", [0, -0.04, 0], y2zOrn) humanoid = Humanoid(bc, motion, [0, 0, 0]) #4000,0,5000]) simTime = 0 keyFrameDuration = motion.KeyFrameDuraction() #print("keyFrameDuration=",keyFrameDuration) #for i in range (50): # bc.stepSimulation() stage = 0
from pybullet_envs.deep_mimic.motion_capture_data import MotionCaptureData import pybullet_data import pybullet import time import random bc = BulletClient(connection_mode=pybullet.GUI) bc.setAdditionalSearchPath(pybullet_data.getDataPath()) bc.configureDebugVisualizer(bc.COV_ENABLE_Y_AXIS_UP,1) bc.setGravity(0,-9.8,0) motion=MotionCaptureData() motionPath = pybullet_data.getDataPath()+"/motions/humanoid3d_walk.txt"#humanoid3d_spinkick.txt"#/motions/humanoid3d_backflip.txt" motion.Load(motionPath) #print("numFrames = ", motion.NumFrames()) simTimeId= bc.addUserDebugParameter("simTime",0,motion.NumFrames()-1.1,0) y2zOrn = bc.getQuaternionFromEuler([-1.57,0,0]) bc.loadURDF("plane.urdf",[0,-0.04,0], y2zOrn) humanoid = Humanoid(bc, motion,[0,0,0])#4000,0,5000]) simTime = 0 keyFrameDuration = motion.KeyFrameDuraction() #print("keyFrameDuration=",keyFrameDuration) #for i in range (50): # bc.stepSimulation() stage = 0