Commits

German Larrain committed fcf6391

no code changes: analogous to 3df7464eab42

Comments (0)

Files changed (4)

ars/model/robot/sensors.py

 		return SensorData(**kwargs)
 
 
-class Laser(Sensor): # RangeFinder
+class Laser(Sensor):
 
 	def __init__(self, space, max_distance=10.0):
 		self._ray = coll.Ray(space, max_distance)
 		self._ray.clear_contacts()
 
 	def set_position(self, pos):
-		"""Useful mainly when it is not attached to a body""" #TODO: if mounted, w.r.t what?
+		"""Useful mainly when it is not attached to a body"""
+		# TODO: if mounted, w.r.t what?
 		self._ray.set_position(pos)
 
 	def set_rotation(self, rot):
-		"""Useful mainly when it is not attached to a body""" #TODO: if mounted, w.r.t what?
+		"""Useful mainly when it is not attached to a body"""
+		# TODO: if mounted, w.r.t what?
 		self._ray.set_rotation(rot)
 
 	def get_ray(self):
 		return SensorData(**kwargs)
 
 
-class LaserRangeFinder(BodySensor): # LaserScanner
+class LaserRangeFinder(BodySensor):
 	pass
 
 
 	def __init__(self, body, gravity):
 		super(PotentialEnergy, self).__init__(body)
 		self._gravity = gravity
-	
+
 	def _build_data(self):
 		potential_e = self.body.calc_potential_energy(self._gravity)
 		kwargs = {'potential energy': potential_e, }
 		super(TotalEnergy, self).__init__(body)
 		self._gravity = gravity
 		self._disaggregate = disaggregate
-		
+
 	def _build_data(self):
 		potential_e = self.body.calc_potential_energy(self._gravity)
 		linear_ke = self.body.calc_translation_kinetic_energy()
 class SensorData:
 	def __init__(self, *args, **kwargs):
 		self._time = None
-		self._args = args # as a tuple?
-		self._kwargs = kwargs # as a dictionary?
+		self._args = args		# as a tuple?
+		self._kwargs = kwargs 	# as a dictionary?
 
 	def get_time(self):
 		return self._time
 
 class SensorDataQueue(ars.utils.containers.Queue):
 	pass
-

demos/sensors/base.py

 
 class CentrifugalForce(Program):
 	OFFSET = (2, 0.5, 2)
-	BOX_PARAMS = (((5, 0.5, 5), (0, -0.25, 0)), {'density': 1}) # ((size, center), density)
+
+	# ((size, center), density)
+	BOX_PARAMS = (((5, 0.5, 5), (0, -0.25, 0)), {'density': 1})
 
 	WINDOW_SIZE = (900, 600)
-	CAMERA_POSITION = (2, 5, 10) #  position [meters]
+	CAMERA_POSITION = (2, 5, 10)  # position [meters]
 	FPS = 50
-	STEPS_PER_FRAME = 20 #200 #STEP_SIZE = 1e-5 # 0.01 ms
+	STEPS_PER_FRAME = 20  # 200 # STEP_SIZE = 1e-5 # 0.01 ms
 
 	POLE_SPEED_STEP = 0.01
-	POLE_VISUAL_RADIUS = 0.05 # 5 cm. how it will be displayed
-	POLE_HEIGHT = 2 # 2 m
-	POLE_INITIAL_POS = (0.0, 1.0, 0.0) # (0.0,0.0,1.0) in C++ example
+	POLE_VISUAL_RADIUS = 0.05  # 5 cm. how it will be displayed
+	POLE_HEIGHT = 2  # 2 m
+	POLE_INITIAL_POS = (0.0, 1.0, 0.0)  # (0.0,0.0,1.0) in C++ example
 
-	BALL_MASS = 1.0 # 1kg
-	BALL_RADIUS = 0.01 # 1 cm
-	BALL_VISUAL_RADIUS = 0.1 # 10 cm
+	BALL_MASS = 1.0  # 1kg
+	BALL_RADIUS = 0.01  # 1 cm
+	BALL_VISUAL_RADIUS = 0.1  # 10 cm
 	BALL_INITIAL_POS = (0.0, 1.0, 1.0)
 
 	JOINT1_ANCHOR = (0.0, 0.0, 0.0)
-	JOINT1_AXIS = (0.0, 1.0, 0.0) # (0.0,0.0,1.0) Z-axis in C++ example
+	JOINT1_AXIS = (0.0, 1.0, 0.0)  # (0.0,0.0,1.0) Z-axis in C++ example
 	JOINT1_FMAX = 100
 	JOINT2_ANCHOR = (
-	0.0, 2.0, 1.0) # (0.0,2.0,1.0) # (0.0,1.0,2.0) in C++ example
-	JOINT2_AXIS = (1.0, 0.0, 0.0) # X-axis
+	0.0, 2.0, 1.0)  # (0.0,2.0,1.0) # (0.0,1.0,2.0) in C++ example
+	JOINT2_AXIS = (1.0, 0.0, 0.0)  # X-axis
 
 	CABLE_LENGTH = mut.length3(mut.sub3(BALL_INITIAL_POS, JOINT2_ANCHOR))
 
 
 	def create_sim_objects(self):
 		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
-		# FIXME: pole should have no mass! => does not really matter, since speed is set
+		# Q: Shouldn't pole have mass?
+		# A: Does not really matter because speed is set and fixed.
 		pole = self.sim.add_cylinder(self.POLE_HEIGHT, self.POLE_VISUAL_RADIUS,
 			self.POLE_INITIAL_POS, density=1.0)
 		ball = self.sim.add_sphere(self.BALL_RADIUS, self.BALL_INITIAL_POS,
 		self.sim.get_object(pole).offset_by_position(self.OFFSET)
 		self.sim.get_object(ball).offset_by_position(self.OFFSET)
 
-		self.joint1 = self.sim.add_rotary_joint('r1',	# name
+		self.joint1 = self.sim.add_rotary_joint('r1', 	# name
 			self.sim.get_object(box),					# obj1
 			self.sim.get_object(pole),					# obj2
 			None, self.JOINT1_AXIS)						# anchor, axis
 
 class FallingBalls(Program):
 
-	#===========================================================================
+	#==========================================================================
 	# constants
-	#===========================================================================
+	#==========================================================================
 	BALL_CENTER = (0,3,5)
 	BALL_RADIUS = 1.0
 	BALL_MASS = 1.0

demos/sensors/laser.py

 
 from base import FallingBalls
 
+
 class LaserSensor(FallingBalls):
 
 	RAY_LENGTH = 1000.0

demos/sensors/total_energy1.py

 	def create_sim_objects(self):
 		FallingBalls.create_sim_objects(self)
 		ball_object = self.sim.get_object(self.ball1)
-		self.sensor = sen.TotalEnergy(ball_object, self.sim.gravity)  #, True)
+		self.sensor = sen.TotalEnergy(ball_object, self.sim.gravity)
+		# self.sensor = sen.TotalEnergy(ball_object, self.sim.gravity, True)
 
 	def on_post_step(self):
 		try: