Commits

German Larrain committed 5ed4d4a

-Simulation's add_rotary_joint and add_ball_socket_joint methods now accept anchor = None
-new SimulatedObject.get_position method

Comments (0)

Files changed (1)

ars/model/simulator/__init__.py

 		return self.add_joint(SimulatedJoint(joint=f_joint))
 		
 	def add_rotary_joint(self, name, obj1, obj2, anchor, axis):
+		'''
+		Adds a rotary joint between obj1 and obj2, at the specified anchor and with the given axis.
+		If anchor = None, it will be set equal to the position of obj2.
+		'''
 		body1 = obj1.get_body()
 		body2 = obj2.get_body()
+		if not anchor:
+			anchor = obj2.get_position()
+		
 		r_joint = jo.Rotary(self._world, body1, body2, anchor, axis)
-		#self._joints.add_joint(r_joint)
 		return self.add_joint(SimulatedJoint(name, r_joint))
 	
 	def add_universal_joint(self, obj1, obj2, anchor, axis1, axis2):
 		return self.add_joint(SimulatedJoint(joint=u_joint))
 	
 	def add_ball_socket_joint(self, name, obj1, obj2, anchor):
+		'''
+		Adds a "ball and socket" joint between obj1 and obj2, at the specified anchor.
+		If anchor = None, it will be set equal to the position of obj2.
+		'''
 		body1 = obj1.get_body()
 		body2 = obj2.get_body()
+		if not anchor:
+			anchor = obj2.get_position()
+		
 		bs_joint = jo.BallSocket(self._world, body1, body2, anchor)
-		#self._joints.add_joint(bs_joint)
 		return self.add_joint(SimulatedJoint(name, bs_joint))
 	
 	'''
 	def get_geom(self):
 		return self._geom
 	
+	def get_position(self):
+		return self._body.getPosition()
+	
 class SimulatedJoint:
 	
 	def __init__(self, name=None, joint=None, actor=None):