Commits

German Larrain  committed d640db5 Merge

Merge with dev

  • Participants
  • Parent commits e7069be, 842f6e6
  • Branches dev-contrib

Comments (0)

Files changed (3)

File ars/model/collision/adapters.py

 			space.inner_object, normal, dist)
 
 
-class Cone(OdeBasicShape, base.Cone):
-	"""Cone"""
-
-	def __init__(self):
-		super(Cone, self).__init__()
-		raise exc.ArsError("Not available in ODE")
-
-
 class NearCallbackArgs(base.NearCallbackArgs):
 	pass

File ars/model/physics/adapters.py

 		self._inner_object = body
 		self.attach_geom(geom)
 
-
-class Cone(OdeBody, base.Cone):
-	def __init__(self, world, space, height, radius, mass=None, density=None):
-		OdeBody.__init__(self, world, space, mass, density)
-		base.Cone.__init__(self, height, radius, mass, density)
-		raise exc.ArsError("Not available in ODE")
-
 #==============================================================================
 # Private functions
 #==============================================================================

File ars/model/simulator/__init__.py

-
-# Created on 2011.10.17
-#
-# @author: german
 from abc import ABCMeta, abstractmethod
 
 import random
 
 class Simulation:
 
-	def __init__(self, FPS, STEPS_PF, do_debug = False):
+	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()
 		self.phs_engine = phs.OdeEngine()
 
-	def add_basic_simulation_objects(self, gravity=(0.0,-9.81,0.0)):
+	def add_basic_simulation_objects(self, gravity=(0.0, -9.81, 0.0)):
 		"""Create the basic simulation objects needed for physics and collision
 		such as a contact group (holds temporary contact joints generated during
 		collisions), a simulation 'world' (where physics objects are processed)
 
 		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"""
 		name = 'axes'
 		return self.add_object(SimulatedObject(name, actor=gAxes))
 
-	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)):
+	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
-		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
+		# 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)
+		# 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))
 
-	def add_trimesh_floor(self, vertices, faces, center=(0,0,0), color=(0.2,0.5,0.5)):
+	def add_trimesh_floor(self, vertices, faces, center=(0, 0, 0),
+			color=(0.2, 0.5, 0.5)):
 		self._floor_geom = coll.Trimesh(self._space, vertices, faces, center)
 		gFloor = gp.Trimesh(vertices, faces, center)
 		gFloor.set_color(color)
 		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_cone(self, height, radius, center, mass=None, density=None):
-	#	 body, geom = phs.createConeBodyAndGeom(self._world, self._space, density, height, radius)
-	#	 body.setPosition(center)
-	#	
-	#	 g_object = gp.Cone(height, radius, center)
-	#	 self.graphicBodies.append((body, g_object))
-	#	 return graphicObject
-	#	raise exc.ArsError("Not available in ODE")
-	#===========================================================================
-
 	def add_cylinder(self, length, radius, center, mass=None, density=None):
 		body = phs.Cylinder(self._world, self._space, length, radius, mass, density)
 		body.set_position(center)
 	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
 
 		"""Rotate the object by applying a rotation matrix defined by the given
 		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
+		rot_to_apply = mu.matrix_as_3x3_tuples(gemut.calc_rotation_matrix(axis,
+			angle))
+		# 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