German Larrain avatar 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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.