Commits

German Larrain  committed 2109715

model.simulator.Simulation: replaced 'get_body' method with 'body' property.

  • Participants
  • Parent commits ab8537c

Comments (0)

Files changed (4)

File ars/model/simulator/__init__.py

 		"""Adds an object to the internal dictionary of simulated ones"""
 		name = sim_object.get_name()
 		if (name in self._objects.keys()) and name:
-			name = name + '/' + str(sim_object.get_body())
+			name = name + '/' + str(sim_object.body)
 			sim_object.set_name(name)
 		self._objects[name] = sim_object
 		return name
 #===============================================================================
 
 	def add_fixed_joint(self, obj1, obj2):
-		body1 = obj1.get_body()
-		body2 = obj2.get_body()
+		body1 = obj1.body
+		body2 = obj2.body
 		f_joint = jo.Fixed(self._world, body1, body2)
 		return self.add_joint(SimulatedJoint(joint=f_joint))
 
 		"""Adds a rotary joint between obj1 and obj2, at the specified anchor
 		and with the given axis. If anchor = None, it will be set equal to the
 		position of obj2"""
-		body1 = obj1.get_body()
-		body2 = obj2.get_body()
+		body1 = obj1.body
+		body2 = obj2.body
 		if not anchor:
 			anchor = obj2.get_position()
 
 		return self.add_joint(SimulatedJoint(name, r_joint))
 
 	def add_universal_joint(self, obj1, obj2, anchor, axis1, axis2):
-		body1 = obj1.get_body()
-		body2 = obj2.get_body()
+		body1 = obj1.body
+		body2 = obj2.body
 		u_joint = jo.Universal(self._world, body1, body2, anchor, axis1, axis2)
 		return self.add_joint(SimulatedJoint(joint=u_joint))
 
 		"""Adds a "ball and socket" joint between obj1 and obj2, at the
 		specified anchor. If anchor = None, it will be set equal to the
 		position of obj2."""
-		body1 = obj1.get_body()
-		body2 = obj2.get_body()
+		body1 = obj1.body
+		body2 = obj2.body
 		if not anchor:
 			anchor = obj2.get_position()
 
 # GETTERS AND SETTERS
 #===============================================================================
 
-	def get_body(self):
+	@property
+	def body(self):
 		return self._body
 
 	def get_position(self):

File bin/IROS/example2_conical_pendulum.py

 	sim_program.start()
 	
 	# print arm links' inertia matrices
-	pole_body = sim_program.sim.get_object(sim_program.pole).get_body()
-	arm_body = sim_program.sim.get_object(sim_program.arm).get_body()
+	pole_body = sim_program.sim.get_object(sim_program.pole).body
+	arm_body = sim_program.sim.get_object(sim_program.arm).body
 	print(pole_body.get_inertia_tensor())
 	print(arm_body.get_inertia_tensor())

File bin/IROS/example3_speed_profile.py

 	sim_program.start()
 
 	# print mass of bodies defined with a density value
-	ball_body = sim_program.sim.get_object(sim_program.ball).get_body()
-	chassis_body = sim_program.sim.get_object(sim_program.chassis).get_body()
-	wheelR_body = sim_program.sim.get_object(sim_program.wheelR).get_body()
-	wheelL_body = sim_program.sim.get_object(sim_program.wheelL).get_body()
+	ball_body = sim_program.sim.get_object(sim_program.ball).body
+	chassis_body = sim_program.sim.get_object(sim_program.chassis).body
+	wheelR_body = sim_program.sim.get_object(sim_program.wheelR).body
+	wheelL_body = sim_program.sim.get_object(sim_program.wheelL).body
 	print(ball_body.get_mass())
 	print(chassis_body.get_mass())
 	print(wheelR_body.get_mass())

File tests/physics.py

 def run_body_test():
 	sim_program = BodyTest1()
 	sim_program.start()
-	body = sim_program.sim.get_object("sphere").get_body()
+	body = sim_program.sim.get_object("sphere").body
 	print(body.get_mass())
 	print(body.get_position())
 	print(body.get_center_of_gravity())
 	
 	sim_program = BodyTest2()
 	sim_program.start()
-	body = sim_program.sim.get_object("cylinder").get_body()
+	body = sim_program.sim.get_object("cylinder").body
 	print(body.get_mass())
 	print(body.get_position())
 	print(body.get_center_of_gravity())
 	
 	sim_program = BodyTest3()
 	sim_program.start()
-	body = sim_program.sim.get_object("sphere").get_body()
+	body = sim_program.sim.get_object("sphere").body
 	print(body.get_mass())
 	print(body.get_position())
 	print(body.get_center_of_gravity())