Commits

German Larrain committed 387ca1a

demos.sensors: added missing docstrings to module 'base'.

Comments (0)

Files changed (1)

demos/sensors/base.py

 
 
 class CentrifugalForce(Program):
+
+	"""Demo of a system where inertia and centrifugal force intervene."""
+
 	OFFSET = (2, 0.5, 2)
 
 	# ((size, center), density)
 		self.large_speed_steps = True
 
 	def create_sim_objects(self):
+		"""Implementation of the required method.
+
+		Creates and sets up all the objects of the simulation.
+
+		"""
 		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
 		# Q: Shouldn't pole have mass?
 		# A: Does not really matter because speed is set and fixed.
 		self.ball = ball
 
 	def on_pre_frame(self):
+		"""Handle simulation's pre-frame signal."""
 		try:
 			self.set_joint1_speed()
 			self.apply_friction()
 			print('Exception when executing on_pre_frame: %s' % str(e))
 
 	def inc_joint1_vel(self):
+		"""Increase joint1's speed set point."""
 		self.joint1_vel_user += self.POLE_SPEED_STEP
 
 	def dec_joint1_vel(self):
+		"""Decrease joint1's speed set point."""
 		self.joint1_vel_user -= self.POLE_SPEED_STEP
 
 	def set_joint1_speed(self):
+		"""Set joint1's speed."""
 		self.sim.get_joint('r1').joint.set_speed(self.joint1_vel_user,
 			self.JOINT1_FMAX)
 
 	def apply_friction(self):
+		"""Calculate friction torque and apply it to joint 'r2'."""
 		torque = -self.JOINT2_ANGLE_RATE_CONTROLLER_KP *\
 			self.sim.get_joint('r2').joint.angle_rate
 		self.sim.get_joint('r2').joint.add_torque(torque)
 
 class CentrifugalForce2(CentrifugalForce):
 
+	"""Small modification of :class:`CentrifugalForce`.
+
+	Adds :meth:`on_post_step` handler to simulation's post-step signal.
+
+	"""
+
 	def __init__(self):
 		CentrifugalForce.__init__(self)
 		dispatcher.connect(self.on_post_step, signals.SIM_POST_STEP)
 
 	def on_post_step(self):
+		"""Handle simulation's post-step signal."""
 		pass
 
 
 class FallingBalls(Program):
 
+	"""A very simple simulation: three falling balls impact the floor."""
+
 	#==========================================================================
 	# constants
 	#==========================================================================
 	STEPS_PER_FRAME = 100
 
 	def create_sim_objects(self):
+		"""Implementation of the required method.
+
+		Creates and sets up all the objects of the simulation.
+
+		"""
 		self.ball1 = self.sim.add_sphere(self.BALL_RADIUS, self.BALL_CENTER,
 			mass=self.BALL_MASS)
 		self.ball2 = self.sim.add_sphere(self.BALL_RADIUS,
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.