Commits

German Larrain committed fb557bb

demos: surrounded with try/except the calls to `sim_object.actor.set_color`.

Comments (0)

Files changed (5)

demos/IROS/example1_bouncing_balls-no_data.py

 		ball2 = self.sim.add_sphere(0.1, (2, 1.5 + 0.1, 2), 1.0)
 		ball3 = self.sim.add_sphere(0.1, (3, 2 + 0.1, 3), 1.0)
 
-		self.sim.get_object(ball1).actor.set_color((1, 1, 1))
-		self.sim.get_object(ball2).actor.set_color((0, 0.8, 0.8))
-		self.sim.get_object(ball3).actor.set_color((0.7, 0.5, 0))
+		try:
+			self.sim.get_object(ball1).actor.set_color((1, 1, 1))
+			self.sim.get_object(ball2).actor.set_color((0, 0.8, 0.8))
+			self.sim.get_object(ball3).actor.set_color((0.7, 0.5, 0))
+		except AttributeError:
+			# if visualization is deactivated, there is no actor
+			pass

demos/IROS/example2_conical_pendulum.py

 			mut.add3(self.OFFSET, self.JOINT2_ANCHOR),
 			self.JOINT2_AXIS)
 
-		#self.sim.get_object(box).actor.set_color(cts.COLOR_RED)
-		self.sim.get_object(pole).actor.set_color(cts.COLOR_YELLOW)
-		self.sim.get_object(arm).actor.set_color(cts.COLOR_NAVY)
+		try:
+			#self.sim.get_object(box).actor.set_color(cts.COLOR_RED)
+			self.sim.get_object(pole).actor.set_color(cts.COLOR_YELLOW)
+			self.sim.get_object(arm).actor.set_color(cts.COLOR_NAVY)
+		except AttributeError:
+			# if visualization is deactivated, there is no actor
+			pass
 
 		self.box = box
 		self.pole = pole

demos/IROS/example3_speed_profile.py

 	def __init__(self):
 		"""Constructor, calls the superclass constructor first."""
 		VehicleWithArm.__init__(self)
-		self.sim.get_object(self.chassis).actor.set_color((0.8, 0, 0))
+		try:
+			self.sim.get_object(self.chassis).actor.set_color((0.8, 0, 0))
+		except AttributeError:
+			# if visualization is deactivated, there is no actor
+			pass
 
 		self.r1_angle_rate_prev = 0.0
 		self.r2_angle_rate_prev = 0.0

demos/Vehicle2.py

 		self.sim.get_object(chassis).offset_by_position(offset)
 
 		# test
-		#print(self.sim.get_object(wheelR).actor.set_color((0.8,0,0)))
+		# try:
+		# 	self.sim.get_object(wheelR).actor.set_color((0.8, 0, 0))
+		# except AttributeError:
+		# 	# if visualization is deactivated, there is no actor
+		# 	pass
 
 	def go_forwards(self):
 		"""Rotate both powered wheels in the same direction, forwards."""

demos/VehicleWithArm.py

 			r2_anchor,
 			cts.Z_AXIS)
 
-		self.sim.get_object(chassis).actor.set_color(cts.COLOR_RED)
-		self.sim.get_object(link1).actor.set_color(cts.COLOR_YELLOW)
-		self.sim.get_object(link2).actor.set_color(cts.COLOR_NAVY)
+		try:
+			self.sim.get_object(chassis).actor.set_color(cts.COLOR_RED)
+			self.sim.get_object(link1).actor.set_color(cts.COLOR_YELLOW)
+			self.sim.get_object(link2).actor.set_color(cts.COLOR_NAVY)
+		except AttributeError:
+			# if visualization is deactivated, there is no actor
+			pass
 
 		self.chassis = chassis
 		self.wheelR = wheelR