Commits

German Larrain  committed c402700

robots.joints: added class 'Piston', unfinished until ODE's bindings are completed.

  • Participants
  • Parent commits 1c19ab3
  • Branches dev-joints

Comments (0)

Files changed (1)

File ars/model/robot/joints.py

 			raise exc.JointError(self, 'Failed to get the position rate')
 
 
+class Piston(ActuatedJoint):
+
+	"""Slider joint with one additional DOF: rotate about the translation axis.
+
+	It is different from a Slider joint (which has one DOF) in that this does
+	allow rotation about its defined translation axis, while a Slider does not.
+
+	"""
+
+	def __init__(self, world, body1, body2, axis):
+
+		try:
+			inner_joint = None
+#			inner_joint = ode.PistonJoint(world._inner_object)
+			# NOT IMPLEMENTED in ODE's Python bindings
+			# http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions#Piston
+#			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(Piston, self).__init__(world, inner_joint, body1, body2)
+		except:
+			raise exc.PhysicsObjectCreationError(type='Slider joint')
+		raise NotImplementedError("It has not been implemented yet in ODE's"
+									"Python bindings")
+
+	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):