Commits

German Larrain committed eafe76d Merge

Merge with dev

Comments (0)

Files changed (5)

ars/model/robot/joints.py

 			raise exc.PhysicsObjectCreationError(type='Ball and Socket joint')
 
 
+class Slider(ActuatedJoint):
+
+	"""Joint with one DOF that constrains two objects to line up along an axis.
+
+	It is different from a Piston joint (which has two DOF) in that the Slider
+	does not allow rotation.
+
+	"""
+
+	def __init__(self, world, body1, body2, axis):
+
+		try:
+			inner_joint = ode.SliderJoint(world._inner_object)
+			inner_joint.attach(body1.inner_object, body2.inner_object)
+			inner_joint.setAxis(axis)
+
+			# TODO: necessary?
+			# see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions#Parameter_Functions
+			lo_stop = -ode.Infinity
+			hi_stop = ode.Infinity
+			inner_joint.setParam(ode.ParamLoStop, lo_stop)
+			inner_joint.setParam(ode.ParamHiStop, hi_stop)
+
+			super(Slider, self).__init__(world, inner_joint, body1, body2)
+		except:
+			raise exc.PhysicsObjectCreationError(type='Slider joint')
+
+	def add_force(self, force):
+		"""Apply a force of magnitude ``force`` along the joint's axis.
+
+		:type force: :class:`float`
+
+		"""
+		dispatcher.send(signals.JOINT_PRE_ADD_FORCE, sender=self,
+			force=force)
+		try:
+			self._inner_joint.addForce(force)
+		except:
+			raise exc.JointError(self, 'Failed to add force to this joint')
+		dispatcher.send(signals.JOINT_POST_ADD_FORCE, sender=self,
+			force=force)
+
+	@property
+	def position(self):
+		"""Return position of the joint with respect to its initial position.
+
+		The zero position is established when the joint's axis is set.
+
+		:rtype: :class:`float`
+
+		"""
+		try:
+			return self._inner_joint.getPosition()
+		except:
+			raise exc.JointError(self, 'Failed to get the position')
+
+	@property
+	def position_rate(self):
+		"""Return position's time derivative, i.e. "speed".
+
+		:rtype: :class:`float`
+
+		"""
+		try:
+			return self._inner_joint.getPositionRate()
+		except:
+			raise exc.JointError(self, 'Failed to get the position rate')
+
+
 class JointFeedback:
 	def __init__(self, body1, body2, force1=None, force2=None, torque1=None,
 			torque2=None):

ars/model/robot/signals.py

 
 JOINT_PRE_ADD_TORQUE = 'robot joint pre add torque'
 JOINT_POST_ADD_TORQUE = 'robot joint post add torque'
+JOINT_PRE_ADD_FORCE = 'robot joint pre add force'
+JOINT_POST_ADD_FORCE = 'robot joint post add force'
 JOINT_PRE_SET_SPEED = 'robot joint pre set speed'
 JOINT_POST_SET_SPEED = 'robot joint post set speed'

ars/model/simulator/__init__.py

 		bs_joint = jo.BallSocket(self._world, body1, body2, anchor)
 		return self.add_joint(SimulatedJoint(name, bs_joint))
 
+	def add_slider_joint(self, name, obj1, obj2, axis):
+		"""Add a :class:`jo.Slider` joint between obj1 and obj2.
+
+		The only movement allowed is translation along ``axis``.
+
+		:return: the name under which the slider was stored, which could be
+		different from the given ``name``
+
+		"""
+		body1 = obj1.body
+		body2 = obj2.body
+
+		s_joint = jo.Slider(self._world, body1, body2, axis)
+		return self.add_joint(SimulatedJoint(name, s_joint))
+
 
 class SimulatedObject:
 	__metaclass__ = ABCMeta

docs/maintainers/Procedure to create and upload a release .txt

 	python setup.py sdist --formats=gztar,zip
 
 2) update version/release number and commit. Change it in
-	docs/sphinx/source/conf.py
-	setup.py
+	ars/__init__.py
 
 3) tag previous changeset with 'version XYZ'
 
 	#package_dir={}, 
 	packages=[
 		'ars',
-		'ars.app', 'ars.graphics', 'ars.gui', 'ars.lib', 'ars.model',
+		'ars.app', 'ars.graphics', 'ars.lib', 'ars.model',
 		'ars.utils',
 		'ars.lib.pydispatch',
 		'ars.model.collision', 'ars.model.contrib', 'ars.model.geometry',