German Larrain avatar German Larrain committed a4765ec Merge

Comments (0)

Files changed (10)

Add a comment to this file

ars/model/simulator/collision.py

File contents unchanged.

Add a comment to this file

ars/model/simulator/physics.py

File contents unchanged.

bin/IROS/example1_bouncing_ball.py

+#!/usr/bin/env python
+
+# Created on 2012.03.08
+#
+# @author: german
+
+"""
+Example #1. To achieve the same results reported in the paper,
+the contact joint bounce parameter (in ars.model.simulator.collision near_callback function)
+must be set to 0.9, instead of the default 0.2 value.
+"""
+
+from ars.app import Program
+
+class Example1(Program):
+	
+	FPS = 50
+	STEPS_PER_FRAME = 80
+	
+	HEIGHT = 1
+	RADIUS = 0.01
+	CENTER = (1,HEIGHT + RADIUS,1)
+	MASS = 1
+	
+	def __init__(self):
+		Program.__init__(self)
+		self.set_pre_step_callback(self.on_pre_step)
+	
+	def create_sim_objects(self):
+		self.sphere = self.sim.add_sphere(self.RADIUS, self.CENTER, mass=self.MASS)
+	
+	def on_pre_step(self):
+		try:
+			time = self.sim.sim_time
+			sim_ball = self.sim.get_object(self.sphere)
+			pos = sim_ball.get_position()
+			vel = sim_ball.get_linear_velocity()
+			
+			#print('time: %f, pos: %f, vel: %f' % (time, pos[1], vel[1]))
+			print('%.7e\t%.7e\t%.7e' % (time, pos[1], vel[1]))
+			
+		except:
+			print('Exception when executing on_pre_step')
+
+if __name__ == '__main__':
+	sim_program = Example1()
+	sim_program.start()

bin/IROS/example1_bouncing_balls-no_data.py

+#!/usr/bin/env python
+
+# Created on 2012.03.08
+#
+# @author: german
+
+"""
+Example #1, with 3 balls (different colors) and no data output
+"""
+
+from ars.app import Program
+
+class Example1NoData(Program):
+	
+	FPS = 50
+	STEPS_PER_FRAME = 80
+	
+	def create_sim_objects(self):
+		# (radius, center, mass)
+		ball1 = self.sim.add_sphere(0.1, (1,1 + 0.1,1), 1.0)
+		ball2 = self.sim.add_sphere(0.1, (2,1.5 + 0.1,2), 1.0)
+		ball3 = self.sim.add_sphere(0.1, (3,2 + 0.1,3), 1.0)
+		
+		print(self.sim.get_object(ball1).get_actor().set_color((1,1,1)))
+		print(self.sim.get_object(ball2).get_actor().set_color((0,0.8,0.8)))
+		print(self.sim.get_object(ball3).get_actor().set_color((0.7,0.5,0)))
+
+if __name__ == '__main__':
+	sim_program = Example1NoData()
+	sim_program.start()

bin/IROS/example2_conical_pendulum.py

+#!/usr/bin/env python
+
+# Created on 2012.03.09
+#
+# @author: german
+
+"""
+Example #2
+"""
+
+from ars.app import Program
+import ars.utilities.mathematical as mut
+import ars.constants as cts
+
+class Example2(Program):	
+
+	OFFSET = (2,0.5,2)
+	BOX_PARAMS = (((10,0.5,10),(0,-0.25,0)),{'density':100}) # ((size, center), density)
+	
+	WINDOW_SIZE = (900,600)
+	# (0,-4,1) in C++ example #vp_xyz = (0.0,-4.0,1.0) # position [meters]
+	CAMERA_POSITION = (2,5,10)
+	FPS = 50
+	STEPS_PER_FRAME = 80
+
+	POLE_RADIUS = 0.141421 # 1/(5*sqrt(2))
+	POLE_HEIGHT = 1
+	POLE_INITIAL_POS = (0.0,1.0,0.0)
+	POLE_MASS = 10.0
+	
+	ARM_RADIUS = 0.141421
+	ARM_LENGTH = 1.0
+	ARM_INITIAL_POS = (0.0,1.0,0.1)
+	ARM_MASS = 10.0
+	
+	JOINT1_ANCHOR = (0.0,0.0,0.0)
+	JOINT1_AXIS = cts.Y_AXIS
+	JOINT2_ANCHOR = (0.0,1.5,0.1)
+	JOINT2_AXIS = cts.X_AXIS
+	
+	Q1_FRICTION_COEFF = (50e-3)*100
+	Q2_FRICTION_COEFF = (50e-3)*100
+
+	MAX_TORQUE = 20
+	SATURATION_TIME = 1
+
+	def __init__(self):
+		Program.__init__(self)
+		self.set_pre_step_callback(self.on_pre_step)
+		
+		self.q1p_prev = 0.0
+		self.q2p_prev = 0.0
+	
+	def create_sim_objects(self):
+		box = self.sim.add_box(*self.BOX_PARAMS[0], **self.BOX_PARAMS[1])
+		
+		pole = self.sim.add_cylinder(self.POLE_HEIGHT, self.POLE_RADIUS, 
+									self.POLE_INITIAL_POS, mass=self.POLE_MASS)
+		arm = self.sim.add_cylinder(self.ARM_LENGTH, self.ARM_RADIUS, 
+									self.ARM_INITIAL_POS, mass=self.ARM_MASS)
+		
+		# bodies are rotated before attaching themselves through joints
+		self.sim.get_object(pole).rotate(cts.X_AXIS, mut.pi/2)
+		self.sim.get_object(arm).rotate(cts.X_AXIS, mut.pi/2)
+		
+		self.sim.get_object(box).offset_by_position(self.OFFSET)
+		self.sim.get_object(pole).offset_by_position(self.OFFSET)
+		self.sim.get_object(arm).offset_by_position(self.OFFSET)
+		
+		self.sim.add_rotary_joint('r1',         # name, obj1, obj2, anchor, axis
+							self.sim.get_object(box), 
+							self.sim.get_object(pole),
+							None,
+							self.JOINT1_AXIS)
+		
+		self.sim.add_rotary_joint('r2', 
+							self.sim.get_object(pole), 
+							self.sim.get_object(arm), 
+							mut.add3(self.OFFSET, self.JOINT2_ANCHOR),
+							self.JOINT2_AXIS)
+		self.box = box
+		self.pole = pole
+		self.arm = arm
+
+	def on_pre_step(self):
+		try:
+			time = self.sim.sim_time
+			torque1 = self.get_torque_to_apply(time)
+			
+			self.apply_torque_to_joints(torque1, None)
+			self.apply_friction(self.q1p_prev, self.q2p_prev)
+			
+			q1 = self.get_q1()
+			q2 = self.get_q2()
+			q1p = self.get_q1p()
+			q2p = self.get_q2p()
+		
+			self.q1p_prev = q1p
+			self.q2p_prev = q2p
+		
+			print('%.7e\t%.7e\t%.7e\t%.7e\t%.7e' % (time,q1,q1p,q2,q2p))
+			
+		except Exception as e:
+			print('Exception when executing on_pre_step: %s' % str(e))
+	
+	def get_torque_to_apply(self, time):
+		if time < self.SATURATION_TIME:
+			torque = time * self.MAX_TORQUE
+		else:
+			torque = self.MAX_TORQUE
+		return torque
+	
+	def get_q1(self):
+		return self.sim.get_joint('r1').get_joint().get_angle()
+	
+	def get_q2(self):
+		return self.sim.get_joint('r2').get_joint().get_angle()
+	
+	def get_q1p(self):
+		return self.sim.get_joint('r1').get_joint().get_angle_rate()
+	
+	def get_q2p(self):
+		return self.sim.get_joint('r2').get_joint().get_angle_rate()
+	
+	def apply_torque_to_joints(self, torque1, torque2):
+		if torque1 is not None:
+			self.sim.get_joint('r1').add_torque(torque1)
+		if torque2 is not None:
+			self.sim.get_joint('r2').add_torque(torque2)
+	
+	def apply_friction(self, q1p, q2p):
+		self.apply_torque_to_joints(-q1p * self.Q1_FRICTION_COEFF,
+								-q2p * self.Q2_FRICTION_COEFF)
+
+if __name__ == '__main__':
+	sim_program = Example2()
+	sim_program.start()
+	
+	pole_body = sim_program.sim.get_object(sim_program.pole).get_body()
+	arm_body = sim_program.sim.get_object(sim_program.arm).get_body()
+	print(pole_body.get_inertia_tensor())
+	print(arm_body.get_inertia_tensor())

bin/IROS/example3_speed_profile.py

+#!/usr/bin/env python
+
+# Created on 2012.01.11
+#
+# @author: german
+
+"""
+Example #3
+"""
+
+import os
+import sys
+
+# we need to add the parent directory to the Python path (PYTHONPATH)
+CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.append(os.path.dirname(CURRENT_DIR))
+
+from VehicleWithArm import VehicleWithArm, mut
+
+class Example3(VehicleWithArm):
+	
+	WINDOW_SIZE = (1024,630)
+	CAMERA_POSITION = (0,8,15)
+	
+	FPS = 50
+	STEPS_PER_FRAME = 80
+
+	VEHICLE_OFFSET = (-4,0.5,4)
+
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'mass':1}) # ((length, radius, center), mass)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'mass':1})
+	
+	Q1_FRICTION_COEFF = 0.02
+	Q2_FRICTION_COEFF = 0.02
+	
+	KP = 10 # controller proportional action
+	
+	# speed profile setup
+	speeds = ((0,0), (1,0), (5,1), (9,1), (13,0), (14,0)) # (time,speed)
+	speed_i = 0
+	
+	def __init__(self):
+		""" Constructor, calls first the superclass constructor. """
+		VehicleWithArm.__init__(self)
+		self.sim.get_object(self.chassis).get_actor().set_color((0.8,0,0))
+		
+		self.r1_angle_rate_prev = 0.0
+		self.r2_angle_rate_prev = 0.0
+
+	def on_pre_step(self):
+		try:
+			time = self.sim.sim_time
+			
+			if self.speed_i < len(self.speeds) - 1:
+				if time > self.speeds[self.speed_i + 1][0]:
+					self.speed_i += 1
+			elif self.speed_i == len(self.speeds) - 1:
+				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()
+						
+			linear_vel = self.sim.get_object(self.chassis).get_linear_velocity()
+			linear_vel_XZ = (linear_vel[0], linear_vel[2])
+			cv = mut.length2(linear_vel_XZ) * mut.sign(linear_vel[0])
+
+			sp = self.calc_desired_speed(time)
+			torque = self.compensate(sp, cv)
+			self.apply_torque_to_wheels(torque, torque)
+			self.apply_friction(q1p, q2p)
+			
+			print('%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e' % 
+				(time,pos[0],cv,sp,q1,q1p,q2,q2p,torque))
+			
+		except Exception as e:
+			print('Exception when executing on_pre_step: %s' % str(e))
+	
+	def calc_desired_speed(self, time):
+		
+		if self.speed_i == len(self.speeds) - 1:
+			return float(self.speeds[self.speed_i][1])
+		
+		elif 0 <= self.speed_i < len(self.speeds) - 1:
+			time_diff = time - self.speeds[self.speed_i][0]
+			time_period = self.speeds[self.speed_i + 1][0] - self.speeds[self.speed_i][0]
+			prev_speed = float(self.speeds[self.speed_i][1])
+			next_speed = float(self.speeds[self.speed_i + 1][1] )
+			return (next_speed - prev_speed) * (time_diff / time_period) + prev_speed
+		else:
+			raise Exception('invalid speed_i value: %d' % self.speed_i)
+	
+	def compensate(self, sp, cv):
+		return (sp - cv) * self.KP
+
+if __name__ == '__main__':
+	sim_program = Example3()
+	sim_program.start()
+	
+	# print mass of bodies defined with a density value
+	ball_body = sim_program.sim.get_object(sim_program.ball).get_body()
+	chassis_body = sim_program.sim.get_object(sim_program.chassis).get_body()
+	wheelR_body = sim_program.sim.get_object(sim_program.wheelR).get_body()
+	wheelL_body = sim_program.sim.get_object(sim_program.wheelL).get_body()
+	print(ball_body.get_mass())
+	print(chassis_body.get_mass())
+	print(wheelR_body.get_mass())
+	print(wheelL_body.get_mass())

bin/IROS/example4_sinusoidal_terrain.py

+#!/usr/bin/env python
+
+# Created on 2012.01.16
+#
+# @author: german
+
+"""
+Experiment #2 for a paper submitted to the 
+2012 Robotics Science and Systems conference
+"""
+import os
+import sys
+
+# we need to add the parent directory to the Python path (PYTHONPATH)
+CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.append(os.path.dirname(CURRENT_DIR))
+
+from random import random
+from ars.model.simulator import Simulation
+from ars.model.geometry.shapes import Trimesh
+import ars.utilities.mathematical as mut
+from VehicleWithArm import VehicleWithArm
+
+def random_heightfield(num_x, num_z, scale=1.0):
+	"""
+	A height field where values are completely random.
+	"""
+	# that x and z are integers, not floats, does not matter
+	verts=[]
+	for x in range(num_x):
+		for z in range(num_z):
+			verts.append( (x,random()*scale,z) )
+	return verts
+
+def sinusoidal_heightfield(num_x, num_z, height_scale=1.0, frequency_x=1.0):
+	"""
+	Creates the vertices corresponding to a sinusoidal heightfield along the X axis.
+	The height_scale controls the amplitude of the wave, and frequency_x its frequency.
+	"""
+	# TODO: fix the frequency units
+	verts=[]
+	for x in range(num_x):
+		for z in range(num_z):
+			verts.append( (x, mut.sin(x * frequency_x)*height_scale, z) )
+	return verts
+
+def constant_heightfield(num_x, num_z, height=0.0):
+	"""
+	A height field where all the values are the same.
+	"""
+	# that x and z are integers, not floats, does not matter
+	verts=[]
+	for x in range(num_x):
+		for z in range(num_z):
+			verts.append((x, height, z))
+	return verts
+
+class Example4(VehicleWithArm):
+	
+	FPS = 50
+	STEPS_PER_FRAME = 80
+
+	VEHICLE_OFFSET = (-1.05,-0.35,5)
+	TM_X, TM_Z = (40,20)
+
+	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'mass':1}) # ((length, radius, center), mass)
+	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'mass':1})
+	
+	Q1_FRICTION_COEFF = 0.02
+	Q2_FRICTION_COEFF = 0.02
+	
+	WHEELS_TORQUE = 4.0
+	MAX_SPEED = 2.0
+	
+	q1_SP = 0.0 # set point
+	R1_KP = 20.0 # controller proportional action
+	R1_KD = 15.0 # controller derivative action
+	
+	q2_SP = 0.0
+	R2_KP = 20.0
+	R2_KD = 15.0
+	
+	def __init__(self):
+		""" Constructor, calls first the superclass constructor. """
+		VehicleWithArm.__init__(self)
+		self.set_pre_step_callback(self.on_pre_step)
+		
+		self.q1_previous_error = 0.0
+		self.q2_previous_error = 0.0
+	
+	def create_simulation(self):
+		
+		tm_x, tm_z = self.TM_X, self.TM_Z
+		vertices = sinusoidal_heightfield(tm_x, tm_z, height_scale=0.7, frequency_x=0.5)
+		faces = Trimesh.get_heightfield_faces(tm_x, tm_z)
+		#vertices = constant_heightfield(tm_x, tm_z, height=0.0)
+		#vertices = random_heightfield(tm_x, tm_z, 0.5)
+		#shrink_factor = (1.0,1.0)
+		#vertices = shrink_XZ_heightfield(vertices, shrink_factor)
+		
+		# set up the simulation parameters
+		self.sim = Simulation(self.FPS, self.STEPS_PER_FRAME)
+		self.sim.add_basic_simulation_objects()
+		self.sim.add_axes()
+		self.sim.add_trimesh_floor(vertices, faces, center=(-10,0,-10), color=(0.7,0.7,0.7))
+		
+		self.create_sim_objects()
+		
+		# add the graphic objects
+		self.gAdapter.add_objects_list(self.sim.get_actors().values())
+		self.sim.update_actors()
+
+	def on_pre_step(self):
+		try:
+			time = self.sim.sim_time
+			
+			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()
+			
+			if mut.length3(vel) < self.MAX_SPEED:
+				wheels_torque = self.WHEELS_TORQUE
+			else:
+				wheels_torque = 0.0
+			
+			self.apply_torque_to_wheels(wheels_torque, wheels_torque)	
+			self.apply_friction(q1p, q2p)
+			torque1, torque2 = self.get_arm_compensation(q1, q2)
+			self.apply_torque_to_joints(torque1, torque2)
+			
+			print('%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e\t%.7e' % 
+				(time,pos[0],pos[1],pos[2],q1,torque1,q2,torque2,wheels_torque))
+			
+		except Exception as e:
+			print('Exception when executing on_pre_step: %s' % str(e))
+	
+	def get_arm_compensation(self, q1, q2):
+		""" Calculate the control torque with a PD controller """
+		time_step = self.sim.get_time_step()
+		error_q1 = (self.q1_SP - q1)
+		error_q2 = (self.q2_SP - q2)
+		
+		error_q1_p = (error_q1 - self.q1_previous_error) / time_step
+		error_q2_p = (error_q2 - self.q2_previous_error) / time_step
+		
+		torque1 = self.R1_KP * error_q1 + self.R1_KD * error_q1_p
+		torque2 = self.R2_KP * error_q2 + self.R2_KD * error_q2_p
+		
+		self.q1_previous_error = error_q1
+		self.q2_previous_error = error_q2
+		
+		return torque1, torque2
+
+if __name__ == '__main__':
+	sim_program = Example4()
+	sim_program.start()
+
+#===============================================================================
+# def shrink_XZ_heightfield(vertices, factor=(1.0,1.0)):
+#	"""
+#	test
+#	"""
+#	new_vertices = []
+#	for vertex in vertices:
+#		new_vertices.append((vertex[0]/factor[0], vertex[1], vertex[2]/factor[1]))
+#	return new_vertices
+#===============================================================================

bin/RSS1.py

-#!/usr/bin/env python
-
-# Created on 2012.01.11
-#
-# @author: german
-
-"""
-Experiment #1 for a paper submitted to the 
-2012 Robotics Science and Systems conference
-"""
-
-from VehicleWithArm import VehicleWithArm, mut
-
-
-def output_data(time, speed_i, sp, cv, error, torque):
-	
-	print('time: %f, speed_i: %d, sp: %f, cv: %f, error: %f, torque: %f' % 
-		(time, speed_i, sp, cv, error, torque))
-
-class RSS1(VehicleWithArm):
-	
-	WINDOW_SIZE = (1024,630)
-	CAMERA_POSITION = (0,8,15)
-
-	VEHICLE_OFFSET = (-4,0.5,2)
-
-	LINK1_PARAMS = ((0.8, 0.1,(0,0,0)),{'density':1}) # ((length, radius, center), density)
-	LINK2_PARAMS = ((0.6,0.1,(0,0.7,0.2)),{'density':1})
-	
-	kp = 10
-	speeds = ((0,0), (1,0), (5,1), (9,1), (13,0), (14,0)) # (time,speed)
-	speed_i = 0
-	
-	def __init__(self):
-		""" Constructor, calls first the superclass constructor. """
-		VehicleWithArm.__init__(self)
-		self.sim.get_object(self.chassis).get_actor().set_color((0.8,0,0))
-		
-		self.r1_angle_rate_prev = 0.0
-		self.r2_angle_rate_prev = 0.0
-
-	def on_pre_step(self):
-		try:
-			time = self.sim.sim_time
-			
-			if self.speed_i < len(self.speeds) - 1:
-				if time > self.speeds[self.speed_i + 1][0]:
-					self.speed_i += 1
-			elif self.speed_i == len(self.speeds) - 1:
-				pass
-			
-			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 = mut.length2(linear_vel_plane) * mut.sign(linear_vel[0])
-			torque = self.compensate(sp, cv)
-			self.apply_torque_to_wheels(torque, torque)
-			
-			output_data(time, self.speed_i, sp, cv, sp - cv, torque)
-			#print(self.get_kinematic_data())
-			
-		except:
-			print('Exception when executing on_pre_step')
-	
-	def calc_desired_speed(self, time):
-		
-		if self.speed_i == len(self.speeds) - 1:
-			return float(self.speeds[self.speed_i][1])
-		
-		elif 0 <= self.speed_i < len(self.speeds) - 1:
-			time_diff = time - self.speeds[self.speed_i][0]
-			time_period = self.speeds[self.speed_i + 1][0] - self.speeds[self.speed_i][0]
-			prev_speed = float(self.speeds[self.speed_i][1])
-			next_speed = float(self.speeds[self.speed_i + 1][1] )
-			return (next_speed - prev_speed) * (time_diff / time_period) + prev_speed
-		else:
-			raise Exception('invalid speed_i value: %d' % self.speed_i)
-	
-	def compensate(self, sp, cv):
-		return (sp - cv) * self.kp
-	
-	def get_kinematic_data(self):
-		r1_angle = self.sim.get_joint('r1').get_joint().get_angle()
-		r1_angle_rate = self.sim.get_joint('r1').get_joint().get_angle_rate()
-		r1_angle_accel = (self.r1_angle_rate_prev - r1_angle_rate) / self.sim.get_time_step()
-		
-		r2_angle = self.sim.get_joint('r2').get_joint().get_angle()
-		r2_angle_rate = self.sim.get_joint('r2').get_joint().get_angle_rate()
-		r2_angle_accel = (self.r2_angle_rate_prev - r2_angle_rate) / self.sim.get_time_step()
-		
-		end_effector_pos = self.sim.get_object(self.link2).get_position()
-		
-		return (r1_angle, r1_angle_rate, r1_angle_accel, r2_angle, 
-			r2_angle_rate, r2_angle_accel, end_effector_pos)
-
-if __name__ == '__main__':
-	sim_program = RSS1()
-	sim_program.start()

bin/RSS2.py

-#!/usr/bin/env python
-
-# Created on 2012.01.16
-#
-# @author: german
-
-"""
-Experiment #2 for a paper submitted to the 
-2012 Robotics Science and Systems conference
-"""
-
-from random import random
-
-from ars.model.simulator import Simulation
-from ars.model.geometry.shapes import Trimesh
-import ars.utilities.mathematical as mut
-from VehicleWithArm import VehicleWithArm
-
-def random_heightfield(num_x, num_z, scale=1.0):
-	"""
-	Based on:
-	Edward Dale - Snowballs: An experiment in Winter frivolity (2006).
-	http://scompt.com/files/cg2/final.pdf
-		
-	A height field where values are completely random.
-	"""
-	# that x and z are integers, not floats, does not matter
-	verts=[]
-	for x in range(num_x):
-		for z in range(num_z):
-			verts.append( (x,random()*scale,z) )
-	return verts
-
-def sinusoidal_heightfield(num_x, num_z, height_scale=1.0, frequency_x=1.0):
-	"""
-	Creates the vertices corresponding to a sinusoidal heightfield along the X axis.
-	The height_scale controls the amplitude of the wave, and frequency_x its frequency.
-	"""
-	# TODO: fix the frequency units
-	verts=[]
-	for x in range(num_x):
-		for z in range(num_z):
-			verts.append( (x, mut.sin(x * frequency_x)*height_scale, z) )
-	return verts
-
-#===============================================================================
-# def shrink_XZ_heightfield(vertices, factor=(1.0,1.0)):
-#	"""
-#	test
-#	"""
-#	new_vertices = []
-#	for vertex in vertices:
-#		new_vertices.append((vertex[0]/factor[0], vertex[1], vertex[2]/factor[1]))
-#	return new_vertices
-#===============================================================================
-
-def constant_heightfield(num_x, num_z, height=0.0):
-	"""
-	A height field where all the values are the same.
-	"""
-	# that x and z are integers, not floats, does not matter
-	verts=[]
-	for x in range(num_x):
-		for z in range(num_z):
-			verts.append((x, height, z))
-	return verts
-
-class RSS2(VehicleWithArm):
-	
-	STEPS_PER_FRAME = 500
-	#OFFSET = (3,2,5)
-	VEHICLE_OFFSET = (0,0,5)
-	TM_X, TM_Z = (40,20)
-	
-	def __init__(self):
-		""" Constructor, calls first the superclass constructor. """
-		VehicleWithArm.__init__(self)
-	
-	def create_simulation(self):
-		
-		#tm_resolution = 1.0
-		tm_x, tm_z = self.TM_X, self.TM_Z
-		#shrink_factor = (1.0,1.0)
-		vertices = sinusoidal_heightfield(tm_x, tm_z, height_scale=0.7, frequency_x=0.5)
-		#vertices = constant_heightfield(tm_x, tm_z, height=0.0)
-		#vertices = random_heightfield(tm_x, tm_z, 0.5)
-		#vertices = shrink_XZ_heightfield(vertices, shrink_factor)
-		
-		faces = Trimesh.get_heightfield_faces(tm_x, tm_z)
-		
-		# set up the simulation parameters
-		self.sim = Simulation(self.FPS, self.STEPS_PER_FRAME)
-		self.sim.add_basic_simulation_objects()
-		self.sim.add_axes()
-		self.sim.add_trimesh_floor(vertices, faces, center=(-10,0,-10), color=(0.7,0.7,0.7))
-		
-		self.create_sim_objects()
-		
-		# add the graphic objects
-		self.gAdapter.add_objects_list(self.sim.get_actors().values())
-		self.sim.update_actors()
-
-if __name__ == '__main__':
-	sim_program = RSS2()
-	sim_program.start()

File contents unchanged.

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.