box3 = MujocoPrimitiveObject(obj_pos=[.4, -0.1, 0.35], obj_name="box3", geom_rgba=[1, 0, 0, 1]) box4 = MujocoPrimitiveObject(obj_pos=[.6, -0.0, 0.35], obj_name="box4", geom_rgba=[1, 0, 0, 1]) box5 = MujocoPrimitiveObject(obj_pos=[.6, 0.1, 0.35], obj_name="box5", geom_rgba=[1, 1, 1, 1]) box6 = MujocoPrimitiveObject(obj_pos=[.6, 0.2, 0.35], obj_name="box6", geom_rgba=[1, 0, 0, 1]) table = MujocoPrimitiveObject(obj_pos=[0.5, 0.0, 0.2], obj_name="table0", geom_size=[0.25, 0.35, 0.2], mass=2000) object_list = [box1, box2, box3, box4, box5, box6, table] scene = Scene(object_list=object_list, control=mj_ctrl.MocapControl()) # if we want to do mocap control # scene = Scene(object_list=object_list) # ik control is default mj_Robot = MujocoRobot(scene, gravity_comp=True, num_DoF=7) duration = 2 # you can specify how long a trajectory can be executed witht the duration mj_Robot.startLogging() # this will start logging robots internal state mj_Robot.set_gripper_width = 0.0 # we set the gripper to clos at the beginning home_position = mj_Robot.current_c_pos.copy() # store home position home_orientation = mj_Robot.current_c_quat.copy() # store initial orientation # execute the pick and place movements mj_Robot.gotoCartPositionAndQuat([0.5, -0.2, 0.6 - 0.1], [0, 1, 0, 0], duration=duration) mj_Robot.set_gripper_width = 0.04 mj_Robot.gotoCartPositionAndQuat([0.5, -0.2, 0.52 - 0.1], [0, 1, 0, 0], duration=duration) mj_Robot.set_gripper_width = 0.00 mj_Robot.gotoCartPositionAndQuat(home_position, home_orientation, duration=duration)
from classic_framework.mujoco.MujocoScene import MujocoScene as Scene from classic_framework.mujoco.mujoco_utils.mujoco_scene_object import MujocoPrimitiveObject if __name__ == '__main__': box = MujocoPrimitiveObject(obj_pos=[.6, -0.2, 0.15], obj_name="box", diaginertia=[0.01, 0.01, 0.01], geom_rgba=[1, 0, 0, 1]) object_list = [box] duration = 4 # Setup the scene # ctrl = mj_ctrl.IKControl()# torque control ctrl = mj_ctrl.MocapControl() # mocap control scene = Scene(object_list=object_list, control=ctrl) # mocap control mj_Robot = MujocoRobot(scene, gravity_comp=True, num_DoF=7) mj_Robot.ctrl_duration = duration home_position = mj_Robot.current_c_pos mj_Robot.startLogging() # log the data for plotting mj_Robot.set_gripper_width = 0.04 mj_Robot.gotoCartPositionAndQuat(desiredPos=[0.6, -0.20, 0.02], desiredQuat=[0.009, 0.72, -0.67, -0.014], duration=duration) """Close the fingers.""" duration = 1 mj_Robot.ctrl_duration = duration mj_Robot.set_gripper_width = 0.0 mj_Robot.gotoCartPositionAndQuat(desiredPos=[0.6, -0.20, 0.02], desiredQuat=[0.009, 0.72, -0.67, -0.014],
box2 = MujocoPrimitiveObject(obj_pos=[.6, -0.1, 0.35], obj_name="box2", geom_rgba=[0.2, 0.3, 0.7, 1]) box3 = MujocoPrimitiveObject(obj_pos=[.4, -0.1, 0.35], obj_name="box3", geom_rgba=[1, 0, 0, 1]) box4 = MujocoPrimitiveObject(obj_pos=[.6, -0.0, 0.35], obj_name="box4", geom_rgba=[1, 0, 0, 1]) box5 = MujocoPrimitiveObject(obj_pos=[.6, 0.1, 0.35], obj_name="box5", geom_rgba=[1, 1, 1, 1]) box6 = MujocoPrimitiveObject(obj_pos=[.6, 0.2, 0.35], obj_name="box6", geom_rgba=[1, 0, 0, 1]) table = MujocoPrimitiveObject(obj_pos=[0.5, 0.0, 0.2], obj_name="table0", geom_size=[0.25, 0.35, 0.2], mass=2000) object_list = [box1, box2, box3, box4, box5, box6, table] scene = Scene(object_list) mj_Robot = MujocoRobot(scene, gravity_comp=True, num_DoF=7) duration = 2 mj_Robot.ctrl_duration = duration mj_Robot.set_gripper_width = 0.0 home_position = mj_Robot.current_c_pos.copy() home_orientation = mj_Robot.current_c_quat.copy() mj_Robot.gotoCartPositionAndQuat([0.5, -0.2, 0.6 - 0.1], [0, 1, 0, 0], duration=duration) mj_Robot.set_gripper_width = 0.04 cam_name = 'rgbd_cage' plt.subplot(141) plt.imshow(scene.get_segmentation_from_cam(cam_name=cam_name))
from classic_framework.mujoco.MujocoRobot import MujocoRobot from classic_framework.mujoco.MujocoScene import MujocoScene as Scene from classic_framework.interface.Logger import RobotPlotFlags from classic_framework.utils.sim_path import sim_framework_path import numpy as np if __name__ == '__main__': object_list = [] duration = 4 # Setup the scene scene = Scene(object_list=object_list) mj_Robot = MujocoRobot(scene, gravity_comp=True, num_DoF=7) mj_Robot.startLogging() # load the trajectory you want to follow path2file = sim_framework_path( 'demos/mujoco/robot_control_scene_creation/des_joint_traj.npy') des_joint_trajectory = np.load(path2file) mj_Robot.follow_JointTraj(des_joint_trajectory) mj_Robot.stopLogging() mj_Robot.logger.plot(plotSelection=RobotPlotFlags.JOINTS)
from classic_framework.mujoco.MujocoRobot import MujocoRobot from classic_framework.mujoco.MujocoScene import MujocoScene import classic_framework.mujoco.mujoco_utils.mujoco_controllers as mj_ctrl from demos.mujoco.kitbash.procedural_objects import KitBashContainer if __name__ == "__main__": # Generate KitBash Objects obj_list = [] for i in range(20): obj_list.append(KitBashContainer()) scene = MujocoScene( object_list=obj_list, # panda_xml_path=sim_framework_path('envs', 'mujoco', 'panda', 'panda_gym.xml'), control=mj_ctrl.MocapControl(), # gripper_control='none', ) robot = MujocoRobot(scene) for i in range(10000): robot.gotoCartPositionAndQuat([0.5, 0.0, 0.5], [0, 1, 0, 0])
from classic_framework.interface.Logger import RobotPlotFlags from classic_framework.mujoco.MujocoRobot import MujocoRobot from classic_framework.mujoco.MujocoScene import MujocoScene as Scene from classic_framework.mujoco.mujoco_utils.mujoco_scene_object import MujocoPrimitiveObject if __name__ == '__main__': box = MujocoPrimitiveObject(obj_pos=[.6, -0.2, 0.15], obj_name="box", diaginertia=[0.01, 0.01, 0.01], geom_rgba=[1, 0, 0, 1]) object_list = [box] duration = 4 # Setup the scene scene = Scene(object_list=object_list) mj_Robot = MujocoRobot(scene, gravity_comp=True, num_DoF=7) mj_Robot.ctrl_duration = duration robot_init_q = mj_Robot.current_j_pos mj_Robot.startLogging() # log the data for plotting des_q = np.array([ -0.17372284, 0.74377287, -0.15055875, -1.8271288, 0.17003154, 2.52458572, 1.85687575 ]) mj_Robot.set_gripper_width = 0.04 mj_Robot.gotoJointPosition(des_q, duration=duration) """Close the fingers.""" duration = 3 mj_Robot.ctrl_duration = duration mj_Robot.set_gripper_width = 0.0