Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lfd/environment/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ def set_state(self, sim_state):
self.update()

def update(self):
self.bt_robot.UpdateBullet()
if self.robot:
self.bt_robot.UpdateBullet()
self._update_rave()

def step(self):
self.bt_robot.UpdateBullet()
if self.robot:
self.bt_robot.UpdateBullet()
self.bt_env.Step(.01, 200, .005)
self._update_rave()

Expand Down
17 changes: 9 additions & 8 deletions test/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ def setUp(self):
cyl_pos1 = np.r_[.6, -helix_radius, table_height + .35]

sim_objs = []
sim_objs.append(XmlSimulationObject("robots/pr2-beta-static.zae", dynamic=False))
sim_objs.append(BoxSimulationObject("table", [1, 0, table_height-.1], [.85, .85, .1], dynamic=False))
sim_objs.append(RopeSimulationObject("rope", init_rope_nodes, rope_params))
sim_objs.append(CylinderSimulationObject("cyl0", cyl_pos0, cyl_radius, cyl_height, dynamic=True))
sim_objs.append(CylinderSimulationObject("cyl1", cyl_pos1, cyl_radius, cyl_height, dynamic=True))

self.sim = DynamicSimulation()
self.sim.add_objects(sim_objs)
self.sim.robot.SetDOFValues([0.25], [self.sim.robot.GetJoint('torso_lift_joint').GetJointIndex()])
sim_util.reset_arms_to_side(self.sim)


# rotate cylinders by 90 deg
for i in range(2):
bt_cyl = self.sim.bt_env.GetObjectByName('cyl%d'%i)
T = openravepy.matrixFromAxisAngle(np.array([np.pi/2,0,0]))
T[:3,3] = bt_cyl.GetTransform()[:3,3]
bt_cyl.SetTransform(T) # SetTransform needs to be used in the Bullet object, not the openrave body
bt_cyl = self.sim.bt_env.GetObjectByName('cyl%d' % i)
T = openravepy.matrixFromAxisAngle(np.array([np.pi/2, 0, 0]))
T[:3,3] = bt_cyl.GetTransform()[:3, 3]
bt_cyl.SetTransform(T) # SetTransform needs to be used in the Bullet object, not the openrave body
self.sim.update()

self.sim.add_objects([XmlSimulationObject("robots/pr2-beta-static.zae", dynamic=False)])
self.sim.robot.SetDOFValues([0.25], [self.sim.robot.GetJoint('torso_lift_joint').GetJointIndex()])
sim_util.reset_arms_to_side(self.sim)

def test_reproducibility(self):
sim_state0 = self.sim.get_state()
Expand Down