German Larrain avatar German Larrain committed 4388cd7

simulator.SimulatedJoint: replaced 'get_joint' method with 'joint' property.

Comments (0)

Files changed (9)

ars/model/simulator/__init__.py

 	def add_joint(self, sim_joint):
 		name = sim_joint.get_name()
 		if (name in self._joints.keys()) and name:
-			name = name + '/' + str(sim_joint.get_joint())
+			name = name + '/' + str(sim_joint.joint)
 			sim_joint.set_name(name)
 		self._joints[name] = sim_joint
 		return name
 	# GETTERS AND SETTERS
 	#===========================================================================
 
-	def get_joint(self):
+	@property
+	def joint(self):
 		return self._joint
 
 	def get_position(self):

bin/CentrifugalForceTest.py

 		self.joint1_vel_user -= self.POLE_SPEED_STEP
 	
 	def set_joint1_speed(self):
-		self.sim.get_joint('r1').get_joint().set_speed(self.joint1_vel_user, self.JOINT1_FMAX)
+		self.sim.get_joint('r1').joint.set_speed(self.joint1_vel_user, self.JOINT1_FMAX)
 	
 	def apply_friction(self):
-		torque = -self.JOINT2_ANGLE_RATE_CONTROLLER_KP * self.sim.get_joint('r2').get_joint().get_angle_rate()
-		self.sim.get_joint('r2').get_joint().add_torque(torque)
+		torque = -self.JOINT2_ANGLE_RATE_CONTROLLER_KP * self.sim.get_joint('r2').joint.get_angle_rate()
+		self.sim.get_joint('r2').joint.add_torque(torque)
 
 if __name__ == '__main__':
 	sim_program = CentrifugalForceTest()

bin/ControlledSimpleArm.py

 		self.sp -= self.SP_STEP
 
 	def get_q2(self):
-		return self.sim.get_joint('r2').get_joint().get_angle()
+		return self.sim.get_joint('r2').joint.get_angle()
 
 	def get_q1p(self):
-		return self.sim.get_joint('r1').get_joint().get_angle_rate()
+		return self.sim.get_joint('r1').joint.get_angle_rate()
 
 	def get_q2p(self):
-		return self.sim.get_joint('r2').get_joint().get_angle_rate()
+		return self.sim.get_joint('r2').joint.get_angle_rate()
 
 	def get_compensation(self, sp, q, time_step):
 		"""PD controller"""

bin/IROS/example2_conical_pendulum.py

 		return torque
 	
 	def get_q1(self):
-		return self.sim.get_joint('r1').get_joint().get_angle()
+		return self.sim.get_joint('r1').joint.get_angle()
 	
 	def get_q2(self):
-		return self.sim.get_joint('r2').get_joint().get_angle()
+		return self.sim.get_joint('r2').joint.get_angle()
 	
 	def get_q1p(self):
-		return self.sim.get_joint('r1').get_joint().get_angle_rate()
+		return self.sim.get_joint('r1').joint.get_angle_rate()
 	
 	def get_q2p(self):
-		return self.sim.get_joint('r2').get_joint().get_angle_rate()
+		return self.sim.get_joint('r2').joint.get_angle_rate()
 	
 	def apply_torque_to_joints(self, torque1, torque2):
 		if torque1 is not None:

bin/IROS/example3_speed_profile.py

 				pass
 
 			pos = self.sim.get_object(self.chassis).get_position()
-			q1 = self.sim.get_joint('r1').get_joint().get_angle()
-			q1p = self.sim.get_joint('r1').get_joint().get_angle_rate()
-			q2 = self.sim.get_joint('r2').get_joint().get_angle()
-			q2p = self.sim.get_joint('r2').get_joint().get_angle_rate()
+			q1 = self.sim.get_joint('r1').joint.get_angle()
+			q1p = self.sim.get_joint('r1').joint.get_angle_rate()
+			q2 = self.sim.get_joint('r2').joint.get_angle()
+			q2p = self.sim.get_joint('r2').joint.get_angle_rate()
 
 			linear_vel = self.sim.get_object(self.chassis).get_linear_velocity()
 			linear_vel_XZ = (linear_vel[0], linear_vel[2])

bin/IROS/example4_sinusoidal_terrain.py

 
 			pos = self.sim.get_object(self.chassis).get_position()
 			vel = self.sim.get_object(self.chassis).get_linear_velocity()
-			q1 = self.sim.get_joint('r1').get_joint().get_angle()
-			q1p = self.sim.get_joint('r1').get_joint().get_angle_rate()
-			q2 = self.sim.get_joint('r2').get_joint().get_angle()
-			q2p = self.sim.get_joint('r2').get_joint().get_angle_rate()
+			q1 = self.sim.get_joint('r1').joint.get_angle()
+			q1p = self.sim.get_joint('r1').joint.get_angle_rate()
+			q2 = self.sim.get_joint('r2').joint.get_angle()
+			q2p = self.sim.get_joint('r2').joint.get_angle_rate()
 
 			if mut.length3(vel) < self.MAX_SPEED:
 				wheels_torque = self.WHEELS_TORQUE

bin/IROS/example5_vehicle_with_user_input.py

 			time = self.sim.sim_time
 			time_step = self.sim.get_time_step()
 			pos = self.sim.get_object(self.chassis).get_position()
-			q1 = self.sim.get_joint('r1').get_joint().get_angle()
-			q2 = self.sim.get_joint('r2').get_joint().get_angle()
+			q1 = self.sim.get_joint('r1').joint.get_angle()
+			q2 = self.sim.get_joint('r2').joint.get_angle()
 
 			mv = self.get_compensation(self.sp, q2, time_step)
 			self.apply_torque_to_joints(0, mv) # torque1, torque2

bin/VehicleWithArm.py

 			self.sim.get_joint('r2').add_torque(torque2)
 
 	def get_q1p(self):
-		return self.sim.get_joint('r1').get_joint().get_angle_rate()
+		return self.sim.get_joint('r1').joint.get_angle_rate()
 
 	def get_q2p(self):
-		return self.sim.get_joint('r2').get_joint().get_angle_rate()
+		return self.sim.get_joint('r2').joint.get_angle_rate()
 
 	def apply_friction(self, q1p, q2p):
 		self.apply_torque_to_joints(-q1p * self.Q1_FRICTION_COEFF, -q2p * self.Q2_FRICTION_COEFF)

bin/VehicleWithControlledArm.py

 
 	def get_q2(self):
 		"""Get the current angle of the second rotary joint"""
-		return self.sim.get_joint('r2').get_joint().get_angle()
+		return self.sim.get_joint('r2').joint.get_angle()
 
 	def get_compensation(self, sp, q, time_step):
 		"""Calculate the control torque with a PD controller"""
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.