Commits

German Larrain  committed 2c0f770

All demos in the /bin folder are now working exactly as before the new feature was introduced, but obviously their code changed accordingly

  • Participants
  • Parent commits 374960e
  • Branches dev-density-mass

Comments (0)

Files changed (6)

File bin/CentrifugalForceTest.py

 class CentrifugalForceTest(Program):
 		
 	OFFSET = (2,0.5,2)
-	BOX_PARAMS = ((5,0.5,5),(0,-0.25,0),1) # (size, center, density)
+	BOX_PARAMS = (((5,0.5,5),(0,-0.25,0)),{'density':1}) # ((size, center), density)
 	
 	WINDOW_SIZE = (900,600)
 	CAMERA_POSITION = (2,5,10) # (0,-4,1) in C++ example #vp_xyz = (0.0,-4.0,1.0) # position [meters]
 		
 	
 	def create_sim_objects(self):
-		box = self.sim.add_box(*self.BOX_PARAMS)
+		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
 		# FIXME: pole should have no mass! => does not really matter, since speed is set
 		pole = self.sim.add_cylinder(self.POLE_HEIGHT, self.POLE_VISUAL_RADIUS, self.POLE_INITIAL_POS, density=1.0)
 		ball_density = self.BALL_MASS / get_sphere_volume(self.BALL_RADIUS)

File bin/ControlledSimpleArm.py

 	
 	OFFSET = (2.5,1,2.5)
 	
-	BOX_PARAMS = ((3,0.5,3),(0,-0.75,0),1) # (size, center, density)
-	LINK1_PARAMS = (0.8, 0.1,(0,0,0),1) # (length, radius, center, density)
-	LINK2_PARAMS = (0.6,0.1,(0,0.7,0.2),1) # (length, radius, center, density)
+	BOX_PARAMS = (((3,0.5,3),(0,-0.75,0)),{'density':1}) # ((size, center), density)
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'density':1}) # ((length, radius, center), density)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'density':1})
 	
 	SP_STEP = 0.1
 	q2_SP = 0.0 # mut.pi/3 # set point
 	
 	def create_sim_objects(self):
 		
-		box = self.sim.add_box(*self.BOX_PARAMS)
-		link1 = self.sim.add_capsule(*self.LINK1_PARAMS)
-		link2 = self.sim.add_capsule(*self.LINK2_PARAMS)
+		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
+		link1 = self.sim.add_capsule(*self.LINK1_PARAMS[0], **self.LINK1_PARAMS[1])
+		link2 = self.sim.add_capsule(*self.LINK2_PARAMS[0], **self.LINK2_PARAMS[1])
 		
 		# bodies are rotated before attaching themselves through joints
 		self.sim.get_object(link1).rotate(cts.X_AXIS, mut.pi/2)
 							self.sim.get_object(link1), 
 							None, cts.Y_AXIS)
 		r2_anchor = mut.sub3(self.sim.get_object(link2).get_position(),
-							(0,self.LINK2_PARAMS[0]/2,0)) # (0, length/2, 0)
+							(0,self.LINK2_PARAMS[0][0]/2,0)) # (0, length/2, 0)
 		self.sim.add_rotary_joint('r2', 
 							self.sim.get_object(link1), 
 							self.sim.get_object(link2), 
 
 	VEHICLE_OFFSET = (-4,0.5,2)
 
-	LINK1_PARAMS = (0.8, 0.1,(0,0,0),1) # (length, radius, center, density)
-	LINK2_PARAMS = (0.6,0.1,(0,0.7,0.2),1)
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'density':1}) # ((length, radius, center), density)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'density':1})
 	
 	kp = 10
 	speeds = ((0,0), (1,0), (5,1), (9,1), (13,0), (14,0)) # (time,speed)

File bin/SimpleArm.py

 	
 	OFFSET = (2.5,1,2.5)
 	
-	BOX_PARAMS = ((3,0.5,3),(0,-0.75,0),1) # (size, center, density)
-	LINK1_PARAMS = (0.8, 0.1,(0,0,0),1) # (length, radius, center, density)
-	LINK2_PARAMS = (0.6,0.1,(0,0.7,0.2),1) # (length, radius, center, density)
+	BOX_PARAMS = (((3,0.5,3),(0,-0.75,0)),{'density':1}) # ((size, center), density)
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'density':1}) # ((length, radius, center), density)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'density':1})
 	
 	def __init__(self):
 		Program.__init__(self)
 		
 		#arm_offset = (0,0.5,0)
 		
-		box = self.sim.add_box(*self.BOX_PARAMS)
-		link1 = self.sim.add_capsule(*self.LINK1_PARAMS)
-		link2 = self.sim.add_capsule(*self.LINK2_PARAMS)
+		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
+		link1 = self.sim.add_capsule(*self.LINK1_PARAMS[0], **self.LINK1_PARAMS[1])
+		link2 = self.sim.add_capsule(*self.LINK2_PARAMS[0], **self.LINK2_PARAMS[1])
 		
 		# bodies are rotated before attaching themselves through joints
 		self.sim.get_object(link1).rotate(cts.X_AXIS, mut.pi/2)
 							self.sim.get_object(link1), 
 							None, cts.Y_AXIS)
 		r2_anchor = mut.sub3(self.sim.get_object(link2).get_position(),
-							(0,self.LINK2_PARAMS[0]/2,0)) # (0, length/2, 0)
+							(0,self.LINK2_PARAMS[0][0]/2,0)) # (0, length/2, 0)
 		self.sim.add_rotary_joint('r2', 
 							self.sim.get_object(link1), 
 							self.sim.get_object(link2), 

File bin/VehicleWithArm.py

 	WHEEL_TORQUE = 400
 	VEHICLE_OFFSET = (2,0.35,2)
 	
-	BALL_PARAMS = (0.3,(1,0,0),1) # (radius, center, density)
-	CHASSIS_PARAMS = ((2,0.2,1.5),(0.5,0.45,0),10) # (size, center, density)
+	BALL_PARAMS = ((0.3,(1,0,0)),{'density':1}) # ((radius, center), density)
+	CHASSIS_PARAMS = (((2,0.2,1.5),(0.5,0.45,0)),{'density':10}) # ((size, center), density)
 		
-	WHEEL_R_PARAMS = (0.4,0.3,(0,0,-0.5),1) # (length, radius, center, density)
-	WHEEL_L_PARAMS = (0.4,0.3,(0,0,0.5),1)
+	WHEEL_R_PARAMS = ((0.4,0.3,(0,0,-0.5)),{'density':1}) # ((length, radius, center), density)
+	WHEEL_L_PARAMS = ((0.4,0.3,(0,0,0.5)),{'density':1})
 	
-	LINK1_PARAMS = (0.8, 0.1,(0,0,0),1) # (length, radius, center, density)
-	LINK2_PARAMS = (0.6,0.1,(0,0.7,0.2),1)
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'density':1}) # ((length, radius, center), density)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'density':1})
 	
 	R1_TORQUE = 3
 	
 		#=======================================================================
 		
 		if self._use_capsule_wheels:
-			wheelR = self.sim.add_capsule(*self.WHEEL_R_PARAMS)
-			wheelL = self.sim.add_capsule(*self.WHEEL_L_PARAMS)
+			wheelR = self.sim.add_capsule(*self.WHEEL_R_PARAMS[0], **self.WHEEL_R_PARAMS[1])
+			wheelL = self.sim.add_capsule(*self.WHEEL_L_PARAMS[0], **self.WHEEL_L_PARAMS[1])
 		else:
-			wheelR = self.sim.add_cylinder(*self.WHEEL_R_PARAMS)
-			wheelL = self.sim.add_cylinder(*self.WHEEL_L_PARAMS)
+			wheelR = self.sim.add_cylinder(*self.WHEEL_R_PARAMS[0], **self.WHEEL_R_PARAMS[1])
+			wheelL = self.sim.add_cylinder(*self.WHEEL_L_PARAMS[0], **self.WHEEL_L_PARAMS[1])
 		
-		ball = self.sim.add_sphere(*self.BALL_PARAMS)
-		chassis = self.sim.add_box(*self.CHASSIS_PARAMS)
+		ball = self.sim.add_sphere(*self.BALL_PARAMS[0], **self.BALL_PARAMS[1])
+		chassis = self.sim.add_box(*self.CHASSIS_PARAMS[0], **self.CHASSIS_PARAMS[1])
 		
 		self.sim.add_rotary_joint('w1', 
 							self.sim.get_object(chassis), 
 		#=======================================================================
 		# ROBOTIC ARM
 		#=======================================================================
-		link1 = self.sim.add_capsule(*self.LINK1_PARAMS)
-		link2 = self.sim.add_capsule(*self.LINK2_PARAMS)
+		link1 = self.sim.add_capsule(*self.LINK1_PARAMS[0], **self.LINK1_PARAMS[1])
+		link2 = self.sim.add_capsule(*self.LINK2_PARAMS[0], **self.LINK2_PARAMS[1])
 		
 		# bodies are rotated before attaching themselves through joints
 		self.sim.get_object(link1).rotate(cts.X_AXIS, mut.pi/2)
 							self.sim.get_object(link1), 
 							None, cts.Y_AXIS)
 		r2_anchor = mut.sub3(self.sim.get_object(link2).get_position(),
-							(0,self.LINK2_PARAMS[0]/2,0)) # (0,length/2,0)
+							(0,self.LINK2_PARAMS[0][0]/2,0)) # (0,length/2,0)
 		self.sim.add_rotary_joint('r2', 
 							self.sim.get_object(link1), 
 							self.sim.get_object(link2), 

File bin/VehicleWithControlledArm.py

 
 class VehicleWithControlledArm(VehicleWithArm):
 		
-	WHEEL_R_PARAMS = (0.4,0.3,(0,0,-0.5),1) # (length, radius, center, density)
-	WHEEL_L_PARAMS = (0.4,0.3,(0,0,0.5),1)
+	WHEEL_R_PARAMS = ((0.4,0.3,(0,0,-0.5)),{'density':1}) # ((length, radius, center), density)
+	WHEEL_L_PARAMS = ((0.4,0.3,(0,0,0.5)),{'density':1})
 	
 	SP_STEP = 0.1
 	q2_SP = 0.0 # mut.pi/3 # set point