Example #1
0
    robot.ik.add_task(DOFTask(robot, robot.CHEST_Y, 0., gain=0.9, weight=0.05))
    robot.ik.add_task(DOFTask(robot, robot.ROT_P, 0., gain=0.9, weight=0.05))
    robot.solve_ik()


def record_video():
    window_recorder.record_video = True
    camera_travel.on_tick(sim)
    time.sleep(2)
    sim.start()


if __name__ == "__main__":
    seed(24)
    pylab.ion()
    pymanoid.init(set_viewer=False)
    robot = RobotModel(download_if_needed=True)
    robot.set_transparency(0.3)

    env = pymanoid.get_env()
    env.SetViewer('qtcoin')
    pymanoid.env.set_default_background_color()
    viewer = pymanoid.get_viewer()
    viewer.SetCamera(
        [[5.39066316e-01, 3.61154816e-01, -7.60903874e-01, 6.57677031e+00],
         [8.42254221e-01, -2.26944015e-01, 4.88982864e-01, -2.9774201e+00],
         [3.91593606e-03, -9.04468691e-01, -4.26522042e-01, 2.25269456e+00],
         [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])

    contacts = generate_contacts()
    com = PointMass([0, 0, 0], robot.mass, visible=False)
Example #2
0

def draw_cdd_only_thread():
    while True:
        try:
            # you can vary ``custom_mass`` to check that it has no effect
            vertices = compute_static_polygon_cdd_only(contacts, custom_mass)
            gui_handles['cdd_only'] = draw_com_polygon(vertices, black)
        except Exception as e:
            print "draw_cdd_only_thread:", e
            continue
        time.sleep(1e-2)


if __name__ == "__main__":
    pymanoid.init()
    robot = RobotModel(download_if_needed=True)
    robot.set_transparency(0.2)
    robot_mass = robot.mass
    viewer = pymanoid.get_env().GetViewer()
    viewer.SetCamera(
        numpy.array([[0.60587192, -0.36596244, 0.70639274, -2.4904027],
                     [-0.79126787, -0.36933163, 0.48732874, -1.6965636],
                     [0.08254916, -0.85420468, -0.51334199, 2.79584694],
                     [0., 0., 0., 1.]]))
    viewer.SetBkgndColor([1, 1, 1])

    fname = sys.argv[1] if len(sys.argv) > 1 else '../stances/triple.json'
    contacts = pymanoid.ContactSet.from_json(fname)

    com_target = pymanoid.Cube(0.01, visible=True)
            print "Did you move the target COM (blue box) out of the polygon?\n"
        env_lock.release()
        time.sleep(dt)
    return handles


def recompute_polygon():
    global polygon_handle
    vertices = contacts.compute_static_equilibrium_polygon()
    polygon_handle = pymanoid.draw_polygon(
        [(x[0], x[1], z_polygon) for x in vertices],
        normal=[0, 0, 1], color=(0.5, 0., 0.5, 0.5))


if __name__ == "__main__":
    pymanoid.init()
    robot = pymanoid.robots.JVRC1('JVRC-1.dae', download_if_needed=True)
    pymanoid.get_viewer().SetCamera([
        [0.60587192, -0.36596244,  0.70639274, -2.4904027],
        [-0.79126787, -0.36933163,  0.48732874, -1.6965636],
        [0.08254916, -0.85420468, -0.51334199,  2.79584694],
        [0.,  0.,  0.,  1.]])
    robot.set_transparency(0.25)

    contacts = pymanoid.ContactSet({
        'left_foot': pymanoid.Contact(
            X=0.2,
            Y=0.1,
            pos=[0.20, 0.15, 0.1],
            rpy=[0, 0, 0],
            friction=0.5,
        [[0.79144370, 0.24411156, -0.56038061, 3.21349812],
         [0.61108966, -0.29552771, 0.73432472, -2.30738068],
         [0.01364915, -0.92361947, -0.38306759, 2.12724948], [0., 0., 0., 1.]])
    cam_id = 1


def set_camera_2():
    global cam_id
    pymanoid.get_viewer().SetCamera([[0., -1., 0., 0.7], [-1., 0., 0., 0.3],
                                     [0., 0., -1., 4.65], [0., 0., 0., 1.]])
    cam_id = 2


if __name__ == '__main__':
    init_ros()
    pymanoid.init('editor/jvrc1_env.xml')
    env = pymanoid.get_env()
    collision_handle = env.RegisterCollisionCallback(collision_callback)
    viewer = env.GetViewer()
    motion_plan = MotionPlan(show_targets=gui_defaults['show_targets'])
    robot = JVRC1()
    robot.set_transparency(0.)
    customize_joint_limits(robot)

    pendulum = Pendulum(robot)
    com_ghost = pymanoid.Cube(0.01,
                              robot.com,
                              color='g',
                              visible=motion_plan.show_targets)
    com_real = pymanoid.Cube(0.01, robot.com, color='r', visible=True)
    zmp_real = pymanoid.Cube(0.005, pendulum.zmp.pos, color='r', visible=True)