Commits

German Larrain  committed c0856c5

RSS1's length2 function moved to utilities.mathematical module

  • Participants
  • Parent commits 0caa0f5

Comments (0)

Files changed (2)

File ars/utilities/mathematical.py

 	if x > 0.0: return 1.0
 	else: return -1.0
 
+def length2(vector):
+	"""Returns the length of a 2-dimensions vector."""
+	return sqrt(vector[0]**2 + vector[1]**2)
+
 def length3(vector):
-	"""Returns the length of 3-vector vector."""
+	"""Returns the length of a 3-dimensions vector."""
 	#TODO: convert it so it can handle vector of any dimension
 	return sqrt(vector[0]**2 + vector[1]**2 + vector[2]**2)
 
 from VehicleWithArm import VehicleWithArm, mut
 
 
-def length2(vector):
-	return mut.sqrt(vector[0]**2 + vector[1]**2)
-
 def output_data(time, speed_i, sp, cv, error, torque):
 	
 	print('time: %f, speed_i: %d, sp: %f, cv: %f, error: %f, torque: %f' % 
 			sp = self.calc_desired_speed(time)
 			linear_vel = self.sim.get_object(self.chassis).get_linear_velocity()
 			linear_vel_plane = (linear_vel[0], linear_vel[2])
-			cv = length2(linear_vel_plane) * mut.sign(linear_vel[0])
+			cv = mut.length2(linear_vel_plane) * mut.sign(linear_vel[0])
 			torque = self.compensate(sp, cv)
 			self.apply_torque_to_wheels(torque)