コード例 #1
0
ファイル: q_game.py プロジェクト: ShaoTengLiu/diffsim
def run_sim(steps, sim, param_g):
    dx = []
    dx.append(torch.zeros([3], dtype=torch.float64))
    dx.append(param_g)
    dx.append(torch.zeros([1], dtype=torch.float64))
    dx = torch.cat(dx)
    sim.obstacles[0].curr_state_mesh.dummy_node.x += dx
    # sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
    for step in range(100):
        print("step")
        print(step)

        arcsim.sim_step()

    cnt = 0

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
    ans = ans.narrow(0, 3, 2)

    # ans = torch.tensor([0, 0, 0],dtype=torch.float64)
    # for node in sim.cloths[0].mesh.nodes:
    # 	cnt += 1
    # 	ans = ans + node.x
    # ans /= cnt
    loss = get_loss(ans)

    return loss, ans
コード例 #2
0
def run_sim(steps,sim,param_g):
	
	
	for node in sim.obstacles[1].curr_state_mesh.nodes:
		node.m    *= param_g


	# sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
	#print("step")
	for step in range(20):
		#print(step)

		
		arcsim.sim_step()

	cnt = 0
	ans = []
	ans.append(sim.obstacles[0].curr_state_mesh.dummy_node.v[3])
	ans.append(sim.obstacles[1].curr_state_mesh.dummy_node.v[3])

	# ans = torch.tensor([0, 0, 0],dtype=torch.float64)
	# for node in sim.cloths[0].mesh.nodes:
	# 	cnt += 1
	# 	ans = ans + node.x
	# ans /= cnt
	loss = get_loss(ans, param_g)

	return loss, ans
コード例 #3
0
def run_sim(steps, sim):
    losses = []
    for step in range(steps):
        arcsim.sim_step()
        if step % 2 == 1:
            losses.append(get_loss_eval(step + 1, sim))
    return torch.stack(losses).mean()
コード例 #4
0
def run_sim(sim):
	for obstacle in sim.obstacles:
		for node in obstacle.curr_state_mesh.nodes:
			node.m    *= 0.002

	for step in range(200):

		target = np.array([0, 0, 0.5])

		if (step> 50):
			target += np.array([0, 0, 0.3])

		for i in range(len(handles)):
		
			this_x = sim.cloths[0].mesh.nodes[handles[i]].x.data
			this_x = np.array(this_x)
			print(this_x)
			vec = target - this_x
			vec = vec / np.linalg.norm(vec)
			print(vec)
			# sim.cloths[0].mesh.nodes[handles[i]].x +=  torch.tensor([0,0,0.04])
			sim.cloths[0].mesh.nodes[handles[i]].v =  torch.tensor(vec*2, dtype=torch.float64)
			# sim.cloths[0].mesh.nodes[handles[i]].v +=  torch.tensor([0,0,0.04])
		# for i in range(len(sim.cloths[0].mesh.nodes)):
		# 	print(target)
		# 	this_x = sim.cloths[0].mesh.nodes[i].x.data
		# 	this_x = np.array(this_x)
		# 	print(this_x)
		# 	vec = target - this_x
		# 	vec = vec / np.linalg.norm(vec)
		# 	print(vec)
		# 	sim.cloths[0].mesh.nodes[i].v =  torch.tensor(vec*3)
		# 	#sim.cloths[0].mesh.nodes[i].x =  sim.cloths[0].mesh.nodes[i].x+torch.tensor(vec*0.03)

		arcsim.sim_step()
コード例 #5
0
ファイル: exp_inverse.py プロジェクト: ShaoTengLiu/diffsim
def run_sim(steps, sim, param_g):

    for obstacle in sim.obstacles:
        for node in obstacle.curr_state_mesh.nodes:
            node.m *= 0.01

    # sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
    print("step")
    for step in range(20):
        print(step)

        dx = []
        dx.append(param_g[step])
        dx.append(torch.zeros([1], dtype=torch.float64))
        dx = torch.cat(dx)
        sim.obstacles[0].curr_state_mesh.dummy_node.v += dx

        arcsim.sim_step()

    cnt = 0

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
    ans = ans

    # ans = torch.tensor([0, 0, 0],dtype=torch.float64)
    # for node in sim.cloths[0].mesh.nodes:
    # 	cnt += 1
    # 	ans = ans + node.x
    # ans /= cnt
    loss = get_loss(ans, param_g)

    return loss, ans
コード例 #6
0
def run_sim(steps,sim,vext):
	losses=[]
	for step in range(steps):
		sec = int(sim.frame/25)
		if sec < vext.shape[0]:
			for i in range(4):
				sim.cloths[0].mesh.nodes[i].v = sim.cloths[0].mesh.nodes[i].v + vext[sec,i]*scalev/spf
		arcsim.sim_step()
	return get_loss(steps,sim)
コード例 #7
0
def run_sim(steps, sim, net, goal):

    for obstacle in sim.obstacles:
        for node in obstacle.curr_state_mesh.nodes:
            node.m *= 0.1

    #sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
    #np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)
    print(sim.obstacles[0].curr_state_mesh.dummy_node.x)
    for step in range(steps):
        print(step)
        remain_time = torch.tensor([(steps - step) / steps],
                                   dtype=torch.float64)

        net_input = []
        for i in range(len(handles)):
            net_input.append(sim.cloths[0].mesh.nodes[handles[i]].x)
            net_input.append(sim.cloths[0].mesh.nodes[handles[i]].v)

        dis = sim.obstacles[0].curr_state_mesh.dummy_node.x - goal
        net_input.append(dis.narrow(0, 3, 3))
        net_input.append(remain_time)
        net_output = net(torch.cat(net_input))

        # outputs = net_output.view([4, 3])
        print("net_output")
        print(net_output)
        for i in range(len(handles)):
            # sim_input = net_output
            sim_input = torch.cat(
                [torch.tensor([0, 0], dtype=torch.float64), net_output])
            sim.cloths[0].mesh.nodes[handles[i]].v += sim_input + torch.tensor(
                [0, 0, 0.6], dtype=torch.float64)

        # sim.gravity = outputs[1]

        arcsim.sim_step()

    # cnt = 0
    # ans1 = torch.tensor([0, 0, 0],dtype=torch.float64)
    # for node in sim.cloths[0].mesh.nodes:
    # 	cnt += 1
    # 	ans1 = ans1 + node.x
    # ans1 /= cnt

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x

    ans1 = sim.cloths[0].mesh.nodes[62].x

    #print(ans)
    ans = (ans +
           torch.cat([torch.tensor([0, 0, 0], dtype=torch.float64), ans1])) / 2

    # ans  = sim.obstacles[0].curr_state_mesh.dummy_node.x
    loss = get_loss(ans, goal)

    return loss, ans
コード例 #8
0
def run_sim(steps, sim, param_g):
    sim.obstacles[0].curr_state_mesh.dummy_node.v = param_g
    for step in range(50):
        print(step)
        arcsim.sim_step()

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
    loss = get_loss(ans)

    return loss, ans
コード例 #9
0
ファイル: q_drag3.py プロジェクト: ShaoTengLiu/diffsim
def run_sim(steps, sim, param_g, goal):

    for obstacle in sim.obstacles:
        for node in obstacle.curr_state_mesh.nodes:
            node.m *= 0.5

    #sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
    #np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)
    print(sim.obstacles[0].curr_state_mesh.dummy_node.x)
    for step in range(steps):
        print(step)

        # outputs = net_output.view([4, 3])
        # print("net_output")
        # print(net_output)
        print("sim_input")
        for i in range(len(handles)):
            # sim_input = net_output
            sim_input = param_g[step, i * 3:i * 3 + 3]
            print(sim_input)
            sim.cloths[0].mesh.nodes[handles[i]].v += sim_input

        # sim.gravity = outputs[1]

        arcsim.sim_step()

    # cnt = 0
    # ans1 = torch.tensor([0, 0, 0],dtype=torch.float64)
    # # for node in sim.cloths[0].mesh.nodes:
    # for i in range(len(handles)):
    # 	node = sim.cloths[0].mesh.nodes[handles[i]]
    # 	cnt += 1
    # 	ans1 = ans1 + node.x
    # ans1 /= cnt
    cnt = 0
    ans1 = torch.tensor([0, 0, 0], dtype=torch.float64)
    for node in sim.cloths[0].mesh.nodes:
        cnt += 1
        ans1 = ans1 + node.x
    ans1 /= cnt

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
    # ans1 = sim.cloths[0].mesh.nodes[62].x

    #print(ans)
    ans = (ans +
           torch.cat([torch.tensor([0, 0, 0], dtype=torch.float64), ans1])) / 2

    # ans  = sim.obstacles[0].curr_state_mesh.dummy_node.x
    loss = get_loss(ans, goal)

    return loss, ans
コード例 #10
0
def run_sim(steps,sim,param_g):
	
			
	for obstacle in sim.obstacles:
		for node in obstacle.curr_state_mesh.nodes:
			node.m    *= 0.1

	# sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
	print("step")
	

	sim.cloths[0].materials[0].stretching = sim.cloths[0].materials[0].stretching*0.3
	

	dv = []
	dv.append(torch.zeros([3],dtype=torch.float64))
	dv.append(param_g)
	dv.append(torch.zeros([1],dtype=torch.float64))
	dv = torch.cat(dv)

	for step in range(30):
		#if (step%10==0):
		#	sim.obstacles[0].curr_state_mesh.dummy_node.v += dv*np.exp(-step/30)

		if (step==13):

			for obstacle in sim.obstacles:
				for node in obstacle.curr_state_mesh.nodes:
					node.m    *= 0.04

			sim.cloths[0].materials[0].stretching = sim.cloths[0].materials[0].stretching*10
	

		print(step)
		arcsim.sim_step()

	cnt = 0

	ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
	ans = ans

	# ans = torch.tensor([0, 0, 0],dtype=torch.float64)
	# for node in sim.cloths[0].mesh.nodes:
	# 	cnt += 1
	# 	ans = ans + node.x
	# ans /= cnt
	loss = get_loss(ans, param_g)

	return loss, ans
コード例 #11
0
ファイル: exp_learn_cloth.py プロジェクト: mszarski/diffsim
def run_sim(steps, sim, net, goal):

	for obstacle in sim.obstacles:
		for node in obstacle.curr_state_mesh.nodes:
			node.m    *= 0.2

	#sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
	#np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)
	print(sim.obstacles[0].curr_state_mesh.dummy_node.x)
	for step in range(steps):
		print(step)
		remain_time = torch.tensor([(steps - step)/steps],dtype=torch.float64)
		
		net_input = []
		for i in range(len(handles)):
			net_input.append(sim.cloths[0].mesh.nodes[handles[i]].x)
			net_input.append(sim.cloths[0].mesh.nodes[handles[i]].v)

		# dis = sim.obstacles[0].curr_state_mesh.dummy_node.x - goal
		# net_input.append(dis.narrow(0, 3, 3))
		net_input.append(remain_time)
		net_output = net(torch.cat(net_input))
		

		# outputs = net_output.view([4, 3])
		
		for i in range(len(handles)):
			sim_input = torch.cat([torch.tensor([0, 0],dtype=torch.float64), net_output[i].view([1])])
			sim.cloths[0].mesh.nodes[handles[i]].v += sim_input 

		arcsim.sim_step()

	cnt = 0
	ans1 = torch.tensor([0, 0, 0],dtype=torch.float64)
	for node in sim.cloths[0].mesh.nodes:
		cnt += 1
		ans1 = ans1 + node.x
	ans1 /= cnt

	ans1 = torch.cat([torch.tensor([0, 0, 0],dtype=torch.float64),
							ans1])

	# ans  = ans1
	ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
	
	loss = get_loss(ans1, goal)

	return loss, ans
コード例 #12
0
ファイル: ppo_throw.py プロジェクト: ShaoTengLiu/diffsim
 def step(self, action):
     sim = arcsim.get_sim()
     print("step!",sim.step)
     print(action.reshape([4,3]))
     for _ in range(spf*25):
         sec = int(sim.frame/25)
         if sec < 3:
             for i in range(4):
                 for k in range(3):
                     sim.cloths[0].mesh.nodes[i].v[k] = sim.cloths[0].mesh.nodes[i].v[k] + action[i*3+k]*scalev/spf
         arcsim.sim_step()
     sec = int(sim.frame/25)
     if sec == 3:
         for _ in range(spf*25):
             arcsim.sim_step()
     done = sim.step >= 4*25*spf
     return self.get_obs(), -self.get_loss() if done else 0, done, {}
コード例 #13
0
ファイル: q_mod_drag.py プロジェクト: ShaoTengLiu/diffsim
    def step(self, action):
        with torch.no_grad():
            #sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
            #np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)
            action = torch.tensor(action, dtype=torch.float64)

            handles = [0, 1, 2, 3]
            for i in range(len(handles)):
                self.sim.cloths[0].mesh.nodes[handles[i]].v = action

            arcsim.sim_step()

            observation = []
            remain_time = torch.tensor([(self.steps - self.step_) / 50],
                                       dtype=torch.float64)
            for i in range(len(handles)):
                observation.append(self.sim.cloths[0].mesh.nodes[handles[i]].x)
                observation.append(self.sim.cloths[0].mesh.nodes[handles[i]].v)

            dis = self.sim.obstacles[0].curr_state_mesh.dummy_node.x - self.goal
            observation.append(dis.narrow(0, 3, 3))
            observation.append(remain_time)
            observation = torch.cat(observation)

            ans = self.sim.obstacles[0].curr_state_mesh.dummy_node.x
            reward = self.get_loss(ans)

            self.step_ += 1

            done = False
            if self.step_ == self.steps:
                self.f.write(
                    'epoch {}: loss={}\n  ans = {}\n goal = {}\n'.format(
                        self.epoch, (-reward).data, ans.data, self.goal.data))
                done = True
                print("epoch %d-----------------------------  " % self.epoch)
                self.epoch += 1
                if self.epoch > 200:
                    quit()

            info = " "

            # print(observation.numpy())
            # print(reward.numpy())
            return observation.detach().numpy(), reward.detach().numpy(
            ), done, info
コード例 #14
0
ファイル: exp_mujoco.py プロジェクト: ShaoTengLiu/diffsim
def run_sim(steps,sim,param_g):
	
			
	# sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
	#print("step")
	#print(dir(mjsim.data))
	#exit()
	for step in range(steps):
		#print(step)

		for i in range(n_cubes):
			dx = [torch.zeros([5],dtype=torch.float64)]
			dx.append(param_g[step][i].unsqueeze(0))
			dx = torch.cat(dx)
			sim.obstacles[i].curr_state_mesh.dummy_node.v += dx

			mjsim.data.qvel[6-3*i]+=param_g[step][i].data

		sim_state = mjsim.get_state()
		
		qvel = sim_state[2]
		

		#print(qvel)
		mjsim.step()
		viewer.render()
		
		'''
		dx = [torch.zeros([5],dtype=torch.float64)]
		dx.append(param_g[step])
		dx = torch.cat(dx,axis=0)
		sim.obstacles[2].curr_state_mesh.dummy_node.v += dx
		'''
		arcsim.sim_step()

	cnt = 0

	ans = []
	for i in range(n_cubes):
		ans.append(sim.obstacles[i].curr_state_mesh.dummy_node.x)
	
	loss = get_loss(ans, param_g)

	return loss, ans
コード例 #15
0
    def step(self, param_g):

        with torch.no_grad():
            param_g = torch.tensor(param_g, dtype=torch.float64)
            param_g = param_g.view(20, 5)
            # dx = []
            # dx.append(torch.zeros([3],dtype=torch.float64))
            # dx.append(param_g)
            # dx.append(torch.zeros([1],dtype=torch.float64))
            # dx = torch.cat(dx)
            # self.sim.obstacles[0].curr_state_mesh.dummy_node.x += dx
            # sim.obstacles[2].curr_state_mesh.dummy_node.x = param_g[1]
            for step in range(20):

                dx = []
                # dx.append(torch.zeros([3],dtype=torch.float64))
                dx.append(param_g[step])
                dx.append(torch.zeros([1], dtype=torch.float64))
                dx = torch.cat(dx)
                self.sim.obstacles[0].curr_state_mesh.dummy_node.v += dx

                arcsim.sim_step()

            cnt = 0

            ans = self.sim.obstacles[0].curr_state_mesh.dummy_node.x
            ans = ans

            # ans = torch.tensor([0, 0, 0],dtype=torch.float64)
            # for node in sim.cloths[0].mesh.nodes:
            #   cnt += 1
            #   ans = ans + node.x
            # ans /= cnt
            loss = self.get_loss(ans, param_g)

            self.f.write('epoch {}: loss={}\n \n '.format(
                self.epoch, loss.data))

            print("epoch %d-----------------------------  " % self.epoch)

            self.epoch += 1

            return loss.detach().numpy()
コード例 #16
0
def run_sim(steps, sim, model):
    losses = []
    vext = []
    for step in range(steps):
        sec = int(sim.frame / 25)
        if sec < 3:
            if sim.frame % 25 == 0 and step % spf == 0:
                inp = []
                for n in sim.cloths[0].mesh.nodes:
                    inp += [n.x, n.v]
                v = model(torch.stack(inp) / 100).reshape([4, 3]) * 30
                vext.append(v)
                print(v)
            for i in range(4):
                sim.cloths[0].mesh.nodes[
                    i].v = sim.cloths[0].mesh.nodes[i].v + v[i] * scalev / spf
        arcsim.sim_step()
    a, b = get_loss(steps, sim)
    return a, b, torch.stack(vext)
コード例 #17
0
def run_sim(sim):
	with torch.no_grad():
		for step in range(700):
			if step == 0:
				for obstacle in sim.obstacles:
					for node in obstacle.curr_state_mesh.nodes:
						node.m    *=1

			if step < 30:
				for node in sim.cloths[0].mesh.nodes:
					node.v    += torch.tensor([2, 0, 0],dtype=torch.float64)
			else:
				node.v    += np.exp(-(step-30)/50)*np.cos((step-30)/40) *torch.tensor([2, 0, 0],dtype=torch.float64)

			if step == 70:
				for obstacle in sim.obstacles:
					for node in obstacle.curr_state_mesh.nodes:
						node.m    *= 200
			arcsim.sim_step()
			print(step)
コード例 #18
0
def run_sim(sim):
	with torch.no_grad():
		for step in range(400):

			if step == 70:
				for obstacle in sim.obstacles:
					for node in obstacle.curr_state_mesh.nodes:
						node.m    *= 80

			for obstacle in sim.obstacles:
				x = obstacle.curr_state_mesh.dummy_node.x.data
				x = np.abs(x)
				print(x)
				# if  x[0]>threshold or x[1]>threshold:
				if  x[5]<0.4:
					print("--------")
					print(obstacle.curr_state_mesh.dummy_node.v)
					obstacle.curr_state_mesh.dummy_node.v = torch.cat(
						[ obstacle.curr_state_mesh.dummy_node.v.narrow(0, 0, 1),
						obstacle.curr_state_mesh.dummy_node.v.narrow(0, 1, 1)*0.5,
						obstacle.curr_state_mesh.dummy_node.v.narrow(0, 2, 1),
						obstacle.curr_state_mesh.dummy_node.v.narrow(0, 3, 1)*0.5,
						obstacle.curr_state_mesh.dummy_node.v.narrow(0, 4, 1)*0.5,
						obstacle.curr_state_mesh.dummy_node.v.narrow(0, 5, 1)
						]
						)

			if step < 30:
				for node in sim.cloths[0].mesh.nodes:
					node.v    += torch.tensor([2, 0, 0],dtype=torch.float64)
			# else:
			# 	inc         = np.maximum(np.exp(-(step-30.0)/50.0),0.2)
			# 	inc			= inc * np.cos((step-30)/40) *torch.tensor([2, 0, 0],dtype=torch.float64)
			# 	for node in sim.cloths[0].mesh.nodes:
			# 		node.v    += inc
			# 	print(inc)


			arcsim.sim_step()
			print("step:")
			print(step)
コード例 #19
0
def run_sim(steps, sim):
    losses = []
    vext = torch.zeros([4, 3], dtype=torch.float64)
    for step in range(steps):
        sec = int(sim.frame / 25)
        if sec < 3:
            if sim.frame % 25 == 0 and step % spf == 0:
                x, v = get_xv(sim)
                target = torch.tensor([0, 0, -0.7], dtype=torch.float64)
                target -= x + v * (4 - sec)
                target[2] += 0.5 * 9.8 * (4 - sec) * (4 - sec)
                target /= 4 - sec - 0.5
                vext = target
                vext = vext.unsqueeze(0).repeat([4, 1])
                print("vext={}\n".format(vext))
                f.write("vext={}\n".format(vext))
            for i in range(4):
                sim.cloths[0].mesh.nodes[i].v = sim.cloths[0].mesh.nodes[
                    i].v + vext[i] * scalev / spf
        arcsim.sim_step()
    return get_loss(steps, sim)
コード例 #20
0
ファイル: q_mod_man.py プロジェクト: ShaoTengLiu/diffsim
    def step(self, action):
        with torch.no_grad():
            #sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
            #np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)
            action = torch.tensor(action, dtype=torch.float64)
            sim_input = torch.cat(
                [torch.zeros([3], dtype=torch.float64), action])
            self.sim.obstacles[1].curr_state_mesh.dummy_node.v = sim_input
            arcsim.sim_step()

            observation = []
            remain_time = torch.tensor([(self.steps - self.step_) / 50],
                                       dtype=torch.float64)
            observation = torch.cat([
                self.sim.obstacles[0].curr_state_mesh.dummy_node.x - self.goal,
                self.sim.obstacles[0].curr_state_mesh.dummy_node.v, remain_time
            ])

            ans = self.sim.obstacles[0].curr_state_mesh.dummy_node.x
            reward = self.get_loss(ans)

            self.step_ += 1

            done = False
            if self.step_ == self.steps:
                self.f.write(
                    'epoch {}: loss={}\n  ans = {}\n goal = {}\n'.format(
                        self.epoch, (-reward).data, ans.data, self.goal.data))
                done = True
                print("epoch %d-----------------------------  " % self.epoch)
                self.epoch += 1
                if self.epoch == 200:
                    quit()

            info = " "

            # print(observation.numpy())
            # print(reward.numpy())
            return observation.numpy(), reward.numpy(), done, info
コード例 #21
0
ファイル: exp_learn_stick.py プロジェクト: mszarski/diffsim
def run_sim(steps, sim, net, goal):


	#sim.obstacles[0].curr_state_mesh.dummy_node.x = torch.tensor([0.0000, 0.0000, 0.0000,
	#np.random.random(), np.random.random(), -np.random.random()],dtype=torch.float64)

	for step in range(steps):
		remain_time = torch.tensor([(steps - step)/steps],dtype=torch.float64)
		net_output = net(torch.cat([sim.obstacles[0].curr_state_mesh.dummy_node.x - goal,
									sim.obstacles[0].curr_state_mesh.dummy_node.v, 
									remain_time]))
		sim_input = torch.cat([torch.zeros([3], dtype=torch.float64), net_output])
		sim.obstacles[1].curr_state_mesh.dummy_node.v += sim_input 
	
		arcsim.sim_step()


	ans  = sim.obstacles[0].curr_state_mesh.dummy_node.x
	loss = get_loss(ans, goal)


	return loss, ans
コード例 #22
0
def run_sim(steps, sim, param_g):
    for step in range(15):
        print("step")
        print(step)
        for i in range(len(handles)):
            print(param_g)
            sim.cloths[0].mesh.nodes[handles[i]].v = param_g

        arcsim.sim_step()

    cnt = 0

    ans = sim.obstacles[0].curr_state_mesh.dummy_node.x
    ans = ans.narrow(0, 3, 3)

    # ans = torch.tensor([0, 0, 0],dtype=torch.float64)
    # for node in sim.cloths[0].mesh.nodes:
    # 	cnt += 1
    # 	ans = ans + node.x
    # ans /= cnt
    loss = get_loss(ans)

    return loss, ans
コード例 #23
0
def run_sim():
    for step in range(49):
        arcsim.sim_step()
コード例 #24
0
def run_sim(steps, sim):
    losses = []
    for step in range(steps):
        arcsim.sim_step()
    losses.append(get_loss(1, sim))
    return torch.stack(losses).mean()
コード例 #25
0
def run_sim():
    for step in range(20):
        arcsim.sim_step()
        print(step)
コード例 #26
0
ファイル: run_abqr.py プロジェクト: ShaoTengLiu/diffsim
def run_sim(sim):
    for step in range(1):
        arcsim.sim_step()
        print(step)