Commits

German Larrain  committed 445036f

model.robot.joints.Rotary: replaced 'get_angle'/'get_angle_rate' methods with 'angle'/'angle_rate' properties.

  • Participants
  • Parent commits 8364d68

Comments (0)

Files changed (9)

File ars/model/robot/joints.py

 		except:
 			raise exc.JointError(self, 'Failed to add torque to this joint')
 
-	def get_angle(self):
+	@property
+	def angle(self):
 		"""Returns the angle (float) between the two bodies. Its value is
 		between -pi and +pi. The zero angle is determined by the position of
 		the bodies when joint anchor is set."""
 		except:
 			raise exc.JointError(self, 'Failed to get the angle of this joint')
 
-	def get_angle_rate(self):
+	@property
+	def angle_rate(self):
 		"""Returns the angle rate (float)"""
 		try:
 			return self._inner_joint.getAngleRate()

File bin/CentrifugalForceTest.py

 		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').joint.get_angle_rate()
+		torque = -self.JOINT2_ANGLE_RATE_CONTROLLER_KP * self.sim.get_joint('r2').joint.angle_rate
 		self.sim.get_joint('r2').joint.add_torque(torque)
 
 if __name__ == '__main__':

File bin/ControlledSimpleArm.py

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

File bin/IROS/example2_conical_pendulum.py

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

File bin/IROS/example3_speed_profile.py

 				pass
 
 			pos = self.sim.get_object(self.chassis).get_position()
-			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()
+			q1 = self.sim.get_joint('r1').joint.angle
+			q1p = self.sim.get_joint('r1').joint.angle_rate
+			q2 = self.sim.get_joint('r2').joint.angle
+			q2p = self.sim.get_joint('r2').joint.angle_rate
 
 			linear_vel = self.sim.get_object(self.chassis).get_linear_velocity()
 			linear_vel_XZ = (linear_vel[0], linear_vel[2])

File 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').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()
+			q1 = self.sim.get_joint('r1').joint.angle
+			q1p = self.sim.get_joint('r1').joint.angle_rate
+			q2 = self.sim.get_joint('r2').joint.angle
+			q2p = self.sim.get_joint('r2').joint.angle_rate
 
 			if mut.length3(vel) < self.MAX_SPEED:
 				wheels_torque = self.WHEELS_TORQUE

File bin/IROS/example5_vehicle_with_user_input.py

 			time = self.sim.sim_time
 			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()
+			q1 = self.sim.get_joint('r1').joint.angle
+			q2 = self.sim.get_joint('r2').joint.angle
 
 			mv = self.get_compensation(self.sp, q2, time_step)
 			self.apply_torque_to_joints(0, mv) # torque1, torque2

File bin/VehicleWithArm.py

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

File bin/VehicleWithControlledArm.py

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