Commits

German Larrain  committed 8f49def

Simulation class: all add_X methods modified to the density-mass changes

  • Participants
  • Parent commits b867838
  • Branches dev-density-mass

Comments (0)

Files changed (1)

File ars/model/simulator/__init__.py

 	def add_obstacle(self, length=0.25, radius=0.15):
 		# create an obstacle
 		# TODO: create this using "add_capsule"
-		obstacle = phs.Capsule(self._world, self._space, density=1000, length=length, radius=radius)
+		obstacle = phs.Capsule(self._world, self._space, length=length, radius=radius, density=1000)
 		pos = (random.uniform(-0.3, 0.3), 0.2, random.uniform(-0.15, 0.2))
 		#pos = (-0.27752817947085257, 0.20000000000000001, -0.071494489985067272)
 		
 		name = "obstacle"
 		return self.add_object(SimulatedObject(name, obstacle, g_capsule))
 
-	def add_ragdoll(self, density, offset):
-		self._ragdoll = cb.RagDoll(self._world, self._space, density, offset)
+	def add_ragdoll(self, offset, mass=None, density=None):
+		self._ragdoll = cb.RagDoll(self._world, self._space, offset, mass, density)
 		self._ragdoll.printMass()
 		
 		for rBody in self._ragdoll.bodies:
 			name = str(rBody)
 			self.add_object(SimulatedObject(name, rBody, actor))
 
-	def add_sphere(self, density, radius, center):
-		body = phs.Sphere(self._world, self._space, density, radius)
+	def add_sphere(self, radius, center, mass=None, density=None):
+		body = phs.Sphere(self._world, self._space, radius, mass, density)
 		body.set_position(center)
 		
 		g_sphere = gp.Sphere(radius, center)
 		name = "sphere"
 		return self.add_object(SimulatedObject(name, body, g_sphere))
 
-	def add_box(self, density, size, center):
-		body = phs.Box(self._world, self._space, density, size)
+	def add_box(self, size, center, mass=None, density=None):
+		body = phs.Box(self._world, self._space, size, mass, density)
 		body.set_position(center)
 		
 		g_box = gp.Box(size, center)
 		name = "box" + str(center) #FIXME
 		return self.add_object(SimulatedObject(name, body, g_box))
 
-	def add_cone(self, density, height, radius, center):
+	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)
 		#=======================================================================
 		raise Exception("Not available in ODE")
 
-	def add_cylinder(self, density, length, radius, center):		
-		body = phs.Cylinder(self._world, self._space, density, length, radius)
+	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)
 
 		g_cylinder = gp.Cylinder(length, radius, center)
 		name = "cylinder"
 		return self.add_object(SimulatedObject(name, body, g_cylinder))
 
-	def add_capsule(self, density, length, radius, center):
-		body = phs.Capsule(self._world, self._space, density, length, radius)
+	def add_capsule(self, length, radius, center, mass=None, density=None):
+		body = phs.Capsule(self._world, self._space, length, radius, mass. density)
 		body.set_position(center)
 
 		g_capsule = gp.Capsule(length, radius, center)