Commits

German Larrain committed 1330e66

-In SimulatedObject, new methods: update_actor and has_body.
-Simulation.update_actors method was simplified and now has doc.

  • Participants
  • Parent commits 9779f67
  • Branches default

Comments (0)

Files changed (1)

File ars/model/simulator/__init__.py

 			self._contact_group.empty()
 		
 	def update_actors(self):
-
+		'''
+		Update the position and rotation of each simulated object's corresponding actor.
+		'''
 		for key_ in self._objects:
 			try:
-				sim_body = self._objects[key_].get_body()
-				sim_actor = self._objects[key_].get_actor()
-				
-				if sim_body != None and sim_actor != None:
-					pos = sim_body.getPosition()
-					rot = sim_body.getRotation()
-					sim_actor.update_position_rotation(pos, rot)
+				if self._objects[key_].has_body():
+					self._objects[key_].update_actor()
 				
 			except (ValueError, AttributeError) as err:
 				print(err)
 		pos = (random.uniform(-0.3, 0.3), 0.2, random.uniform(-0.15, 0.2))
 		#pos = (-0.27752817947085257, 0.20000000000000001, -0.071494489985067272)
 		
+		# TODO: apply transformation using SimulatedObject methods
 		obstacle.setPosition(pos) #TODO: necessary?
 		obstacle.setRotation(mu.rightRot) #TODO: necessary?
-		print "obstacle created at %s" % (str(pos))
+		#print "obstacle created at %s" % (str(pos))
 
 		#g_capsule = gp.Box((2*radius, length + 2*radius, 2*radius), pos)
 		g_capsule = gp.Capsule(length, radius, pos)
 	def offset_by_position(self, offset_pos):
 		pos = self._body.getPosition()
 		new_pos = mu.add3(offset_pos, pos)
-		self._body.setPosition(new_pos)
-		
+		self.set_position(new_pos)
+	
+	def has_body(self):
+		return not self._body is None
+	
+	def update_actor(self):
+		pos = self.get_position()
+		rot = self.get_rotation()
+		self._actor.update_position_rotation(pos, rot)
 
 #===============================================================================
 # GETTERS AND SETTERS