Commits

German Larrain committed 6a1a85b Merge

Comments (0)

Files changed (6)

-install
+To install the software (only "ars" is part of the installation; docs, tests and demos are not), you need to:
+
+1) check the requirements listed in README
+2) open a command window, with the current directoy set to the project main directory
+
+ANY OS:
+2) execute the standard setup script (included):
+	python setup.py install
+
+LINUX: If your OS is GNU/Linux and you have the "checkinstall" program installed, use it (it is optional but convenient)
+2) run the setup script wrapped by checkinstall, which will create a package and install it:
 	sudo checkinstall python setup.py install
-run
+
+	(if you want to uninstall, run
+	sudo dpkg -r ars)
+
+----------------------------------------
+
+To run a demo, execute any of the following:
 	python bin/FallingBall.py
-remove
-	dpkg -r ars
+	python python bin/IROS/example4_sinusoidal_terrain.py
 
+----------------------------------------
 
-documentation
-	epydoc generates API documentation for Python modules, based on their docstrings
+Documentation
+	the epydoc program generates API documentation for Python modules, based on their docstrings
 	
 	to build it, run the following command from the project main directory
 		epydoc -v --config doc/epydoc.cfg ars/
 	
-	to generate diagrams based on a python module, see "development notes.txt"
+	to generate class diagrams based on a python module, see "development notes.txt"
+
+----------------------------------------
 #
 # @author: german
 
+from ars.utilities.mathematical import mult_by_scalar3
 
 X_AXIS = (1,0,0)
 Y_AXIS = (0,1,0)
 
 RIGHTWARDS_AXIS = X_AXIS
 UPWARDS_AXIS = Y_AXIS
-OUTWARDS_AXIS = Z_AXIS
+OUTWARDS_AXIS = Z_AXIS
+
+
+def convert_color(R_int, G_int, B_int):
+	return mult_by_scalar3((R_int,G_int,B_int), 1.0 / 256)
+
+# names according to W3C Recommendation - 4.4 Recognized color keyword names
+# http://www.w3.org/TR/SVG/types.html#ColorKeywords
+
+#===============================================================================
+# COLOR_RED = convert_color(255,0,0)
+# COLOR_LIME = convert_color(0,1.0,0)
+# COLOR_BLUE = convert_color(0,0,1.0)
+# COLOR_YELLOW = convert_color(1.0,1.0,0)
+# COLOR_YELLOW = (0.835,0.9725,0)
+#===============================================================================
+
+COLOR_BLACK = 		convert_color(0,0,0)
+COLOR_BLUE = 		convert_color(0,0,255)
+COLOR_BROWN = 		convert_color(165,42,42)
+COLOR_CYAN = 		convert_color(0,255,255)
+COLOR_GOLD =		convert_color(255,215,0)
+COLOR_GRAY = 		convert_color(128,128,128)
+COLOR_GREEN = 		convert_color(0,128,0)
+COLOR_LIME = 		convert_color(0,255,0)
+COLOR_LIME_GREEN = 	convert_color(50,205,50)
+COLOR_MAROON = 		convert_color(128,0,0)
+COLOR_MAGENTA = 	convert_color(255,0,255)
+COLOR_NAVY = 		convert_color(0,0,128)
+COLOR_OLIVE = 		convert_color(128,128,0)
+COLOR_ORANGE = 		convert_color(255,165,0)
+COLOR_PINK = 		convert_color(255,192,203)
+COLOR_PURPLE = 		convert_color(128,0,128)
+COLOR_RED = 		convert_color(255,0,0)
+COLOR_SILVER = 		convert_color(192,192,192)
+COLOR_SNOW = 		convert_color(255,250,250)
+COLOR_VIOLET = 		convert_color(238,130,238)
+COLOR_YELLOW = 		convert_color(255,255,0)
+COLOR_WHITE = 		convert_color(255,255,255)

bin/ControlledSimpleArm.py

 		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 increase_sp(self):

bin/IROS/example3_speed_profile.py

 
 			sp = self.calc_desired_speed(time)
 			torque = self.compensate(sp, cv)
-			self.apply_torque_to_wheels(torque)
+			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' % 

bin/VehicleWithArm.py

 	FLOOR_BOX_SIZE = (20,0.01,20)
 	
 	WHEEL_TORQUE = 400
-	VEHICLE_OFFSET = (2,0.35,2)
+	VEHICLE_OFFSET = (2,0.35,4)
 	
 	BALL_PARAMS = ((0.3,(1,0,0)),{'density':1}) # ((radius, center), density)
 	CHASSIS_PARAMS = (((2,0.2,1.5),(0.5,0.45,0)),{'mass':6}) # ((size, center), mass)
 							self.sim.get_object(link2), 
 							r2_anchor, cts.Z_AXIS)
 		
-		# test
-		#print(self.sim.get_object(wheelR).get_actor().set_color((0.8,0,0)))
+		self.sim.get_object(chassis).get_actor().set_color(cts.COLOR_RED)
+		self.sim.get_object(link1).get_actor().set_color(cts.COLOR_YELLOW)
+		self.sim.get_object(link2).get_actor().set_color(cts.COLOR_NAVY)
+		
 		self.chassis = chassis
 		self.wheelR = wheelR
 		self.wheelL = wheelL
 		
 	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):
 # coding: utf-8
 
-# Created on Nov 2, 2011
+# Created on 2011.11.02
 #
 # @author: german
 
 
 # only name, version, url are required. Other fields are optional.
 setup(name='Autonomous Robot Simulator',
-	version='20120309', #'0.0.0', # It is recommended that versions take the form major.minor[.patch[.sub]].
+	version='20120310', #'0.0.0', # It is recommended that versions take the form major.minor[.patch[.sub]].
 	description='A great simulator', # A single line of text, not more than 200 characters
 	long_description='', # Multiple lines of plain text in reStructuredText format
 	author='German Larrain',