Commits

German Larrain committed bdb5325

simulator.Simulation: replaced 'get_time_step' method with 'time_step' property. Also moved 'time_step' call out of the 'for' loop in 'perform_sim_steps_per_frame'.

Comments (0)

Files changed (5)

ars/model/simulator/__init__.py

 
 	def perform_sim_steps_per_frame(self):
 
+		time_step = self.time_step
+
 		for i in range(self._STEPS_PF): #@UnusedVariable
 
 			# before each integration step of the physics engine
 			self._space.collide(coll_args)
 
 			# step world sim
-			time_step = self.get_time_step()
 			self._world.step(time_step)
 			self.sim_time += time_step
 			self.num_iter += 1
 			except (ValueError, AttributeError) as err:
 				print(err)
 
-	def get_time_step(self):
+	@property
+	def time_step(self):
 		return self._DT / self._STEPS_PF
 
 	def get_collision_space(self):

bin/ControlledSimpleArm.py

 	def on_pre_step(self):
 		try:
 			time = self.sim.sim_time
-			time_step = self.sim.get_time_step()
+			time_step = self.sim.time_step
 			cv = self.get_q2()
 			q1p = self.get_q1p()
 			q2p = self.get_q2p()

bin/IROS/example4_sinusoidal_terrain.py

 
 	def get_arm_compensation(self, q1, q2):
 		"""Calculate the control torque with a PD controller"""
-		time_step = self.sim.get_time_step()
+		time_step = self.sim.time_step
 		error_q1 = (self.q1_SP - q1)
 		error_q2 = (self.q2_SP - q2)
 

bin/IROS/example5_vehicle_with_user_input.py

 	def on_pre_step(self):
 		try:
 			time = self.sim.sim_time
-			time_step = self.sim.get_time_step()
+			time_step = self.sim.time_step
 			pos = self.sim.get_object(self.chassis).get_position()
 			q1 = self.sim.get_joint('r1').joint.get_angle()
 			q2 = self.sim.get_joint('r2').joint.get_angle()

bin/VehicleWithControlledArm.py

 	def on_pre_step(self):
 		try:
 			time = self.sim.sim_time
-			time_step = self.sim.get_time_step()
+			time_step = self.sim.time_step
 			cv = self.get_q2()
 
 			mv = self.get_compensation(self.sp, cv, time_step)