Commits

German Larrain committed 5581277

model: replaced prints to console with logging

Comments (0)

Files changed (4)

ars/model/collision/base.py

 
 		if cls.is_ray(geom1):
 			if cls.is_ray(geom2):
-				print('Weird, ODE says two rays may collide. '
-				      'That case is not handled.')
+				logger.error("Weird, ODE says two rays may collide. "
+				             "That case is not handled.")  # TODO: better msg
 				return
 			ray_geom = geom1
 			other_geom = geom2

ars/model/collision/ode_adapter.py

 			try:
 				ray.outer_object.set_last_contact(ray_contact)
 			except AttributeError:
-				print("`ray` has no attribute `outer_object` ")
+				logger.error("`ray` has no attribute `outer_object` ")
 			except Exception:
-				print("Ray's encapsulating object's last_contact"
-				      "attribute could not be set")
+				logger.exception("Ray's encapsulating object's last_contact"
+				                 "attribute could not be set")
 
 
 class Space(base.Space):

ars/model/robot/sensors.py

 				power += torque * sender.angle_rate
 			if force is not None:
 				power += force * sender.position_rate
-		except Exception as e:
-			print('Error when calculating power. Exception:\n%s' % e)
+		except Exception:
+			logger.exception("Error when calculating power")
 
 		return SensorData(**{'power': power})
 

ars/model/simulator/__init__.py

 		# before each visualization frame
 		try:
 			dispatcher.send(signals.SIM_PRE_FRAME, sender=self)
-		except Exception as e:
-			print(e)
+		except Exception:
+			logger.exception("")
 
 		self.perform_sim_steps_per_frame()
 
 		# after each visualization frame
 		try:
 			dispatcher.send(signals.SIM_POST_FRAME, sender=self)
-		except Exception as e:
-			print(e)
+		except Exception:
+			logger.exception("")
 
 		# clear functions registered to be called in the steps of this past frame
 		self.all_frame_steps_callbacks = []
 				# call all registered functions before each step in next frame
 				for callback_ in self.all_frame_steps_callbacks:
 					callback_()
-			except Exception as e:
-				print(e)
+			except Exception:
+				logger.exception("")
 
 			# detect collisions and create contact joints
 			args = coll.NearCallbackArgs(self._world, self._contact_group)
 			# after each integration step of the physics engine
 			try:
 				dispatcher.send(signals.SIM_POST_STEP, sender=self)
-			except Exception as e:
-				print(e)
+			except Exception:
+				logger.exception("")
 
 	def update_actors(self):
 		"""Update pose of each simulated object's corresponding actor."""
 			try:
 				if self._objects[key_].is_updatable():
 					self._objects[key_].update_actor()
-			except (ValueError, AttributeError) as err:
-				print(err)
+			except (ValueError, AttributeError):
+				logger.exception("")
 
 	@property
 	def time_step(self):
 	def add_torque(self, torque):
 		try:
 			self._joint.add_torque(torque)
-		except Exception as ex:
-			print(ex)
+		except Exception:
+			logger.exception("")
 
 	#==========================================================================
 	# Getters and setters
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.