Commits

German Larrain committed f08f6aa

VehicleWithArm.apply_torque_to_wheels method parameters and way of proceding is now apply_torque_to_joints-like. Also, erroneus check of None values was corrected.

Comments (0)

Files changed (2)

 			linear_vel_plane = (linear_vel[0], linear_vel[2])
 			cv = mut.length2(linear_vel_plane) * mut.sign(linear_vel[0])
 			torque = self.compensate(sp, cv)
-			self.apply_torque_to_wheels(torque)
+			self.apply_torque_to_wheels(torque, torque)
 			
 			output_data(time, self.speed_i, sp, cv, sp - cv, torque)
 			#print(self.get_kinematic_data())

bin/VehicleWithArm.py

 	VEHICLE_OFFSET = (2,0.35,2)
 	
 	BALL_PARAMS = ((0.3,(1,0,0)),{'density':1}) # ((radius, center), density)
-	CHASSIS_PARAMS = (((2,0.2,1.5),(0.5,0.45,0)),{'density':10}) # ((size, center), density)
+	CHASSIS_PARAMS = (((2,0.2,1.5),(0.5,0.45,0)),{'mass':6}) # ((size, center), mass)
 		
 	WHEEL_R_PARAMS = ((0.4,0.3,(0,0,-0.5)),{'density':1}) # ((length, radius, center), density)
 	WHEEL_L_PARAMS = ((0.4,0.3,(0,0,0.5)),{'density':1})
 		
 	def go_forwards(self):
 		""" Rotate both powered wheels in the same direction, forwards """
-		self.apply_torque_to_wheels(self.WHEEL_TORQUE)
+		self.apply_torque_to_wheels(self.WHEEL_TORQUE, self.WHEEL_TORQUE)
 	
 	def go_backwards(self):
 		""" Rotate both powered wheels in the same direction, backwards """
-		self.apply_torque_to_wheels(-self.WHEEL_TORQUE)
+		self.apply_torque_to_wheels(-self.WHEEL_TORQUE, -self.WHEEL_TORQUE)
 		
 	def turn_left(self):
 		"""
 		except Exception as e:
 			print('Exception when executing on_pre_step: %s' % str(e))
 	
-	def apply_torque_to_wheels(self, torque, torque2=None):
-		self.sim.get_joint('w1').add_torque(torque)
-		if torque2:
+	def apply_torque_to_wheels(self, torque1, torque2):
+		if torque1 is not None:
+			self.sim.get_joint('w1').add_torque(torque1)
+		if torque2 is not None:
 			self.sim.get_joint('w2').add_torque(torque2)
-		else:
-			self.sim.get_joint('w2').add_torque(torque)
 	
 	def rotate_clockwise(self):
 		self.apply_torque_to_joints(self.R1_TORQUE, 0)
 		self.apply_torque_to_joints(-self.R1_TORQUE, 0)
 	
 	def apply_torque_to_joints(self, torque1, torque2):
-		if torque1:
+		if torque1 is not None:
 			self.sim.get_joint('r1').add_torque(torque1)
-		if torque2:
+		if torque2 is not None:
 			self.sim.get_joint('r2').add_torque(torque2)
 	
 	def get_q1p(self):