Commits

German Larrain committed 640685d

model.simulator: no code changes, analogous to 3df7464eab42

Comments (0)

Files changed (1)

ars/model/simulator/__init__.py

 	def __init__(self, FPS, STEPS_PF, do_debug = False):
 		self._FPS = FPS
 		self._DT = 1.0 / FPS
-		self._STEPS_PF = STEPS_PF # steps per frame
+		self._STEPS_PF = STEPS_PF  # steps per frame
 		self.paused = False
 		self.sim_time = 0.0
 		self.num_iter = 0
 		#self._joints = jo.JointCollection()
 		self._joints = {}
 
-		# stores functions to be called on each step of a specific frame. e.g. addTorque
+		# stores functions to be called on each step of a specific frame.
+		# 	e.g. addTorque
 		self.all_frame_steps_callbacks = []
 
 		self.coll_engine = coll.OdeEngine()
 
 		time_step = self.time_step
 
-		for i in range(self._STEPS_PF): #@UnusedVariable
+		for i in range(self._STEPS_PF):
 
 			# before each integration step of the physics engine
 			try:
 			except Exception as e:
 				print(e)
 
-
 	def update_actors(self):
 		"""Update the position and rotation of each simulated object's
 		corresponding actor"""
 	def add_floor(self, normal=(0,1,0), dist=0, box_size=(5,0.1,5), box_center=(0,0,0), color=(0.2,0.5,0.5)):
 		"""Create a plane geom to simulate a floor. It won't be used explicitly
 		later (space object has a reference to it)"""
-		# FIXME: the relation between ODE's definition of plane and the center of the box
+		# FIXME: the relation between ODE's definition of plane and the center
+		# 	of the box
 		self._floor_geom = self.phs_engine.create_plane_geom(self._space, normal, dist)
-		gFloor = gp.Box(box_size, box_center) #TODO: use normal parameter for orientation
+		# TODO: use normal parameter for orientation
+		gFloor = gp.Box(box_size, box_center)
 		gFloor.set_color(color)
 		name = "floor"
 		return self.add_object(SimulatedObject(name, actor=gFloor))
 		body.set_position(center)
 
 		g_box = gp.Box(size, center)
-		name = "box" + str(center) #FIXME
+		name = "box" + str(center)  # FIXME
 		return self.add_object(SimulatedBody(name, body, g_box))
 
 	def add_cylinder(self, length, radius, center, mass=None, density=None):
 	def get_joint(self, name):
 		return self._joints[name]
 
-#===============================================================================
-# ADD JOINTS
-#===============================================================================
+	#==========================================================================
+	# Add joints
+	#==========================================================================
 
 	def add_fixed_joint(self, obj1, obj2):
 		body1 = obj1.body
 		bs_joint = jo.BallSocket(self._world, body1, body2, anchor)
 		return self.add_joint(SimulatedJoint(name, bs_joint))
 
+
 class SimulatedObject:
 	__metaclass__ = ABCMeta
 
 			self._name = str(self)
 		self._actor = actor
 
-	#===========================================================================
-	# GETTERS AND SETTERS
-	#===========================================================================
+	#==========================================================================
+	# Getters and setters
+	#==========================================================================
 
 	def get_name(self):
 		return self._name
 	def is_updatable(self):
 		return self.has_actor() and self._updatable
 
+
 class SimulatedPhysicsObject(SimulatedObject):
 	__metaclass__ = ABCMeta
 
 		axis and angle"""
 		rot_now = mu.matrix_as_3x3_tuples(self.get_rotation())
 		rot_to_apply = mu.matrix_as_3x3_tuples(gemut.calc_rotation_matrix(axis, angle))
-		# the rotation matrix to be applied multiplies from the LEFT the actual one
+		# Matrix (of the rotation to apply)
+		# multiplies from the LEFT the actual one
 		rot_final = mu.matrix_as_tuple(mu.matrix3_multiply(rot_to_apply, rot_now))
 		self.set_rotation(rot_final)
 
 	def set_rotation(self, rot_matrix):
 		pass
 
+
 class SimulatedBody(SimulatedPhysicsObject):
 	"""Class encapsulating the physics, collision and graphical objects
 	representing a body.
 	def __init__(self, name, body=None, actor=None, geom=None):
 		super(SimulatedBody, self).__init__(name, actor)
 		self._body = body
-		self._geom = geom # we might need it in the future
+		self._geom = geom  # we might need it in the future
 
 	#def has_body(self):
 	#	return not self._body is None
 
-#===============================================================================
-# GETTERS AND SETTERS
-#===============================================================================
+	#==========================================================================
+	# Getters and setters
+	#==========================================================================
 
 	@property
 	def body(self):
 		super(SimulatedJoint, self).__init__(name, actor)
 		self._joint = joint
 
-	#===========================================================================
-	# DYNAMIC AND KINEMATIC INTERACTION
-	#===========================================================================
+	#==========================================================================
+	# Dynamic and kinematic interaction
+	#==========================================================================
 
 	def add_force(self):
 		raise NotImplementedError()
 	def dec_position(self):
 		raise NotImplementedError()
 
-	#===========================================================================
-	# GETTERS AND SETTERS
-	#===========================================================================
+	#==========================================================================
+	# Getters and setters
+	#==========================================================================
 
 	@property
 	def joint(self):
 	def set_rotation(self, rot_matrix):
 		raise NotImplementedError()
 
+
 class ActiveObject:
 
 	def __init__(self):
 	def update_internal_forces(self):
 		pass
 
+
 class CompositeObject:
 	pass
 
+
 class Environment:
 	pass