torch.zeros(
                1, faces_gt.shape[1], 2, 1, dtype=torch.float32,
                device=device),
            torch.zeros(
                1, faces_gt.shape[1], 2, 1, dtype=torch.float32,
                device=device),
        ),
        dim=-1,
    )

    # Initialize the renderer.
    renderer = SoftRenderer(camera_mode="look_at", device=device)
    camera_distance = 8.0
    elevation = 0.0
    azimuth = 0.0
    renderer.set_eye_from_angles(camera_distance, elevation, azimuth)

    pendulum_gt = SimplePendulum(args.mass, args.radius, args.gravity,
                                 args.length, args.damping).to(device)
    theta_init = torch.tensor([0.0, 3.0], device=device)
    times = torch.arange(
        args.starttime,
        args.starttime + args.simsteps * args.dtime,
        args.dtime,
        device=device,
    )
    numsteps = times.numel()
    ret = odeint(pendulum_gt, theta_init, times)

    theta1_gt = ret[:, 0]
    theta2_gt = ret[:, 1]
Beispiel #2
0
        #         os.path.join(os.path.dirname(os.path.abspath(__file__)), "../gradsim")
        #     ),
        #     os.path.join(args.out_dir, "gradsim"),
        # )
        shutil.copy(os.path.abspath(__file__), args.out_dir)
        os.makedirs(os.path.join(args.out_dir, "obj"), exist_ok=True)
        for obj in glob.glob(os.path.join(args.data_dir, "*.obj")):
            shutil.copy(obj, os.path.join(args.out_dir, "obj"))
        with open(os.path.join(args.out_dir, "args.yaml"), "w") as f:
            yaml.dump(vars(args), f, default_flow_style=False)

    # Initialize the renderer.
    renderer = SoftRenderer(image_size=args.image_size,
                            camera_mode=args.camera_mode,
                            device=device)
    renderer.set_eye_from_angles(args.camera_distance, args.elevation,
                                 args.azimuth)

    # Initialize sampler
    prim_gen = PrimitiveGenerator(mass_scaling=args.mass_scaling,
                                  mass_offset=args.mass_offset,
                                  data_type=args.data_type,
                                  data_dir=args.data_dir)

    objects = sorted(glob.glob(os.path.join(args.data_dir, "*.obj")))

    pos, ornt, linvel, angvel = None, None, None, None

    try:
        for i in trange(args.n):

            volume = 0.0