1. German Larrain
  2. ars

Commits

German Larrain  committed c648b37 Merge

Merge with dev

  • Participants
  • Parent commits 9b57008, 223a590
  • Branches dev-sensors

Comments (0)

Files changed (3)

File ars/model/robot/joints.py

View file
  • Ignore whitespace
 import ode
 
 import ars.exceptions as exc
+from ars.lib.pydispatch import dispatcher
+
+from ars.model.robot import signals
 
 
 class Joint:
 		"""Applies the torque about the rotation axis
 		torque: float
 		"""
+		dispatcher.send(signals.JOINT_PRE_ADD_TORQUE, sender=self,
+			torque=torque)
 		try:
 			self._inner_joint.addTorque(torque)
 		except:
 			raise exc.JointError(self, 'Failed to add torque to this joint')
+		dispatcher.send(signals.JOINT_POST_ADD_TORQUE, sender=self,
+			torque=torque)
 
 	@property
 	def angle(self):
 			raise exc.JointError(self, 'Failed to get the angle rate of this joint')
 
 	def set_speed(self, speed, max_force=None):
+		dispatcher.send(signals.JOINT_PRE_SET_SPEED, sender=self,
+			speed=speed)
 		if max_force:
 			self._inner_joint.setParam(ode.ParamFMax, max_force)
 		self._inner_joint.setParam(ode.ParamVel, speed)
+		dispatcher.send(signals.JOINT_POST_SET_SPEED, sender=self,
+			speed=speed)
 
 
 class Universal(Joint):

File ars/model/robot/signals.py

View file
  • Ignore whitespace
+"""This module contains string values defining different signals related to
+the :mod:`ars.model.robot` package.
+
+"""
+
+JOINT_PRE_ADD_TORQUE = 'robot joint pre add torque'
+JOINT_POST_ADD_TORQUE = 'robot joint post add torque'
+JOINT_PRE_SET_SPEED = 'robot joint pre set speed'
+JOINT_POST_SET_SPEED = 'robot joint post set speed'

File ars/model/simulator/__init__.py

View file
  • Ignore whitespace
 		self._DT = 1.0 / FPS
 		self._STEPS_PF = STEPS_PF  # steps per frame
 		self.paused = False
-		self.sim_time = 0.0
+		self._sim_time = 0.0
 		self.num_iter = 0
 		self.num_frame = 0
 
 		self.all_frame_steps_callbacks = []
 
 		if self._debug:
-			print(self.sim_time)
+			print(self._sim_time)
 		self.update_actors()
 
 	def perform_sim_steps_per_frame(self):
 
 			# step world sim
 			self._world.step(time_step)
-			self.sim_time += time_step
+			self._sim_time += time_step
 			self.num_iter += 1
 
 			# Remove all contact joints
 		return self._DT / self._STEPS_PF
 
 	@property
+	def sim_time(self):
+		return self._sim_time
+
+	@property
 	def gravity(self):
 		return self._world.gravity