def main():
    args = parse_args()
    pybullet.connect(pybullet.GUI)
    set_minimal_environment()

    if args.use_kuka:
        robot_path = args.robot_path or DEFAULT_KUKA_ROBOT_PATH
        robot = Kuka(robot_path)
    else:
        robot_path = args.robot_path or DEFAULT_BLUE_ROBOT_PATH
        robot = BlueArm(robot_path)
    robot.startup(is_real_time=False)

    pose_control = PoseControl(*robot.get_pose(), prefix='right')
    if not args.use_kuka:
        clamp_control = ClampControl(prefix='right')
    robot.debug_arm_idx()
    robot.get_mass()

    while 1:
        for _ in tqdm(range(1000), desc='Running simulation'):
            position, orientation = pose_control.get_pose()
            robot.move(position, orientation)
            if args.debug_position:
                debug_position(position, robot.get_pose()[0])

            if not args.use_kuka:
                if clamp_control.close_clamp():
                    robot.close_clamp()
                else:
                    robot.open_clamp()
            pybullet.stepSimulation()
Пример #2
0
def main():
    args = parse_args()
    pybullet.connect(pybullet.SHARED_MEMORY)
    pybullet.resetSimulation()
    set_minimal_environment()

    if args.use_kuka:
        robot_path = args.robot_path or DEFAULT_KUKA_ROBOT_PATH
        robot = Kuka(robot_path)
    else:
        robot_path = args.robot_path or DEFAULT_BLUE_ROBOT_PATH
        robot = BlueArm(robot_path)
    robot.startup(is_real_time=False)

    robot.debug_arm_idx()
    robot.get_mass()

    while 1:
        for _ in tqdm(range(1000), desc='Running simulation'):
            events = pybullet.getVREvents()
            for event in events:
                _, position, orientation = event[:3]
                buttons = event[6]
                trigger_button = buttons[33]

            robot.move(position, orientation)
            if args.debug_position:
                debug_position(position, robot.get_pose()[0])
            if not args.use_kuka:
                if trigger_button:
                    robot.close_clamp()
                else:
                    robot.open_clamp()
            pybullet.stepSimulation()