Commits

German Larrain committed 13bc19c Merge

-repository structure changes
-branch merging, which may not be OK

Comments (0)

Files changed (14)

INSTALL.txt

-install
-	sudo checkinstall python setup.py install
-run
-	python RagdollPyOdeVtk.py
-remove
-	dpkg -r ragdoll3
-
-
-documentation
-	epydoc 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 epydoc.cfg ars/

Notes.txt

-Rotation
-	http://en.wikipedia.org/wiki/Rotation_matrix
-	http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#Conversion_formulae_between_representations
-	http://en.wikipedia.org/wiki/Rotation_matrix#Conversions
-	-The inverse of a rotation matrix is its transpose
-	-The determinant of a rotMat (and its transpose) is always 1
-	-Euler angles present problems, singularities and also there are many conventions (2 are popular)
-	-Euler angles triples differing in many ways can give the same rotation matrix
-
-Matrix order and storage
-	http://en.wikipedia.org/wiki/Row-major_order
-	http://fgiesen.wordpress.com/2011/05/04/row-major-vs-column-major-and-gl-es/
-	http://www.ode.org/old_list_archives/2006-October/020521.html
-	http://www.ode.org/old_list_archives/2007-October/022936.html
-	http://www.mindcontrol.org/~hplus/graphics/matrix-layout.html
-	-Row-major (traditional) or Column-major order: in row-major storage, a multidimensional array in linear memory is accessed such that rows are stored one after the other
-	-ODE uses Row-major order, considering column-vector on the right convention. OpenGL uses column-major.
-	-If ODE stored a 4x4 transformation matrix, the translation would live in offsets 3,7,11. 

README.txt

-Simulation of a falling ragdoll onto an obstacle.
-Physics engine: ODE (via PyODE Python wrapper)
-Programming language: Python
-Visualization library: VTK
-IDE: Eclipse 3.7.1 (Indigo SR 1) with PyDev and MercurialEclipse
-SCM: Mercurial 1.7.5
-
-documentation:
-API documentation generation tool: epydoc 3.0.1
-Automatic graph drawings generation: graphviz 2.20.2

TODO.txt

-TODO
-
-general
--fix the conditions of ifs and loops that use None, ==, "and" and "or" inappropriately
--dBodySetFiniteRotationMode
--dBodySetFiniteRotationAxis. is it necessary to set this if dBodySetFiniteRotationMode = true?
--rename package "model" to "core"?
-
-visualization
--create a subclass of vtkInteractorStyleTrackball (http://www.vtk.org/doc/nightly/html/classvtkInteractorStyleTrackball.html)
--remove the event bindings for this class which interfere with the desired behavior
--see VTK/Tutorials/InteractorStyleSubclass (http://www.vtk.org/Wiki/VTK/Tutorials/InteractorStyleSubclass) for ideas
--save screenshot: http://www.vtk.org/Wiki/VTK/Examples/Python/Screenshot
--for a plane use a PlaneSource instead of a slim box
-	http://www.vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Plane
--add shadows
-
-http://vtk.org/doc/nightly/html/classvtkRenderWindowInteractor.html
-
-joints
--store joint rotation limits and resistive force factors
-
-GUI
--Qt integration
-	from PyQt4 import QtCore, QtGui, uic
-	'''
-	# Create a PyQt window using a .ui file generated with Qt Designer ...
-	application = QtGui.QApplication(sys.argv)
-	window = uic.loadUi("gui.ui")
-	vertex_slider = window.findChild(QtGui.QSlider, "vertexCount")
-	edge_slider = window.findChild(QtGui.QSlider, "edgeCount")
-	
-	window.show()
-	application.exec_()
-	'''
-
-packaging
--if the software is installed using by executing
-		sudo python setup.py install
-	or
-		sudo checkinstall python setup.py install
-	then files will be created in directories like this
-		/usr/local/lib/python2.6/dist-packages/RagdollPyOdeVtk.py
-	and
-		/usr/local/lib/python2.6/dist-packages/model/robot/sensors.py to sensors.pyc
-	which is not desirable because they are not under a single directory named after the project,
-	with an appropriate structure which may also prevent clashes with other projects. 

ars/CentrifugalTestPyOdeVtk.py

+'''
+Created on 2011.10.25 (copied from RagdollPyOdeVtk.py)
+Last modified on 2011.11.09
+
+@author: german
+TODO: attribute the code sections that were copied from somewhere else
+'''
+
+import sys
+
+import graphics.adapters as gp
+from model.simulator import Simulation
+
+WRITE_DATA_FILES = False
+DEBUG = False
+DO_TEST = True
+
+WINDOW_TITLE = "PyODE Centrifigal Test simulation"
+WINDOW_POSITION_X = 0
+WINDOW_POSITION_Y = 0
+WINDOW_SIZE_WIDTH = 1024 #640
+WINDOW_SIZE_HEIGHT = 768 #480
+WINDOW_ZOOM = 1.0
+
+FPS = 50
+STEPS_PER_FRAME = 100
+
+class Program():
+	
+	def __init__(self):
+		
+		self.dataFilesNames = None # TODO
+		self.dataFiles = None # TODO
+		
+		self.gAdapter = gp.VtkAdapter()
+		self.gAdapter.createWindow(WINDOW_TITLE,
+							 (WINDOW_POSITION_X, WINDOW_POSITION_Y),
+							 (WINDOW_SIZE_WIDTH, WINDOW_SIZE_HEIGHT), zoom = WINDOW_ZOOM)
+		
+		self.createSimulation()
+		
+		if WRITE_DATA_FILES: self.sim.dataFiles = self.openFiles() # TODO
+		'''
+			outputFiles = openFiles()
+			sim.dataFiles = outputFiles
+			# see Ragdoll2.ars.RagdollPyOdeVtk
+		'''
+		
+#		self.gAdapter.startWindow(self.sim.onIdle, self.createSimulation)
+		
+		# after the window is closed
+		if WRITE_DATA_FILES: self.closeFiles(self.sim.dataFiles) # TODO
+		
+	def createSimulation(self):
+		self.gAdapter.reset()
+		
+		# set up the simulation parameters
+		self.sim = Simulation(FPS, STEPS_PER_FRAME)
+		self.sim.addBasicSimulationObjects()
+		self.sim.addAxes()
+		self.sim.addFloor(normal=(0,1,0), boxSize=(20,0.01,20))
+
+		# create the objects specific to this program
+		'''
+		graphicRagdollObjects = self.sim.createRagdoll(density=500, offset=(0.0, 1.9, 0.0))
+		graphicsObstacle = self.sim.createObstacle(bodyLength=0.5, bodyradius=0.2)
+		'''
+		self.sim.addCylinder(1000, 2.0, 0.2, (0,1,0))
+		
+		#test
+		if DO_TEST:
+			graphicSphere = self.sim.addSphere(500, 0.5, (0,4,0))
+			graphicBox1 = self.sim.addBox(500, (1,1,1), (-1, 2, -1))
+			graphicBox2 = self.sim.addBox(500, (0.3,0.3,0.3), (-1, 1, -1))
+
+			self.gAdapter.addObject(graphicSphere)
+			self.gAdapter.addObject(graphicBox1)
+			self.gAdapter.addObject(graphicBox2)
+		
+		# add the graphic objects
+		self.gAdapter.addObjectsList(self.sim.getActors().values())
+		self.sim.updateActors()
+		#self.gAdapter.restartWindow()
+		self.gAdapter.startWindow(self.sim.onIdle, self.createSimulation)
+
+	def readFilenames(self):
+		# TODO
+		pass # see Ragdoll2.ars.RagdollPyOdeVtk
+	
+	def openFiles(self):
+		# TODO
+		pass # see Ragdoll2.ars.RagdollPyOdeVtk
+	
+	def closeFiles(self, files):
+		# TODO
+		for _key in files:
+			files[_key].close()
+
+class Experiment:
+
+	def __init__(self):
+		self.joint1vel_user = 0.0
+		self.poleBody = None
+
+
+
+if __name__ == '__main__':
+	print('this is CentrifugalTestPyOdeVtk.py')
+	Program()
+	sys.exit(None)
+install
+	sudo checkinstall python setup.py install
+run
+	python RagdollPyOdeVtk.py
+remove
+	dpkg -r ragdoll3
+
+
+documentation
+	epydoc 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 epydoc.cfg ars/
+Rotation
+	http://en.wikipedia.org/wiki/Rotation_matrix
+	http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#Conversion_formulae_between_representations
+	http://en.wikipedia.org/wiki/Rotation_matrix#Conversions
+	-The inverse of a rotation matrix is its transpose
+	-The determinant of a rotMat (and its transpose) is always 1
+	-Euler angles present problems, singularities and also there are many conventions (2 are popular)
+	-Euler angles triples differing in many ways can give the same rotation matrix
+
+Matrix order and storage
+	http://en.wikipedia.org/wiki/Row-major_order
+	http://fgiesen.wordpress.com/2011/05/04/row-major-vs-column-major-and-gl-es/
+	http://www.ode.org/old_list_archives/2006-October/020521.html
+	http://www.ode.org/old_list_archives/2007-October/022936.html
+	http://www.mindcontrol.org/~hplus/graphics/matrix-layout.html
+	-Row-major (traditional) or Column-major order: in row-major storage, a multidimensional array in linear memory is accessed such that rows are stored one after the other
+	-ODE uses Row-major order, considering column-vector on the right convention. OpenGL uses column-major.
+	-If ODE stored a 4x4 transformation matrix, the translation would live in offsets 3,7,11. 
+Simulation of a falling ragdoll onto an obstacle.
+Physics engine: ODE (via PyODE Python wrapper)
+Programming language: Python
+Visualization library: VTK
+IDE: Eclipse 3.7.1 (Indigo SR 1) with PyDev and MercurialEclipse
+SCM: Mercurial 1.7.5
+
+documentation:
+API documentation generation tool: epydoc 3.0.1
+Automatic graph drawings generation: graphviz 2.20.2

ars/RagdollPyOdeVtk.py

+'''
+Created on 2011.10.14
+Last modified on 2011.11.11
+
+@author: german
+TODO: attribute the code sections that were copied from somewhere else
+'''
+
+import sys
+
+import graphics.adapters as gp
+from model.simulator import Simulation
+
+WRITE_DATA_FILES = False
+DEBUG = False
+DO_TEST = True
+
+WINDOW_TITLE = "PyODE ragdoll simulation"
+WINDOW_POSITION_X = 0
+WINDOW_POSITION_Y = 0
+WINDOW_SIZE_WIDTH = 1024 #640
+WINDOW_SIZE_HEIGHT = 768 #480
+WINDOW_ZOOM = 1.0
+
+FPS = 50
+STEPS_PER_FRAME = 50
+
+class Program():
+	
+	def __init__(self):
+		
+		self.doCreateWindow = True
+		self.dataFilesNames = None # TODO
+		self.dataFiles = None # TODO
+		
+		self.gAdapter = gp.VtkAdapter()
+		self.gAdapter.createWindow(WINDOW_TITLE,
+							 (WINDOW_POSITION_X, WINDOW_POSITION_Y),
+							 (WINDOW_SIZE_WIDTH, WINDOW_SIZE_HEIGHT), zoom = WINDOW_ZOOM)
+		
+		self.createSimulation()
+		
+		if WRITE_DATA_FILES: self.sim.dataFiles = self.openFiles() # TODO
+		'''
+			outputFiles = openFiles()
+			sim.dataFiles = outputFiles
+			# see Ragdoll2.ars.RagdollPyOdeVtk
+		'''
+		
+		while self.doCreateWindow:
+			self.doCreateWindow = False
+			self.gAdapter.startWindow(self.sim.onIdle, self.resetSimulation, self.onActionSelection)
+		
+		# after the window is closed
+		if WRITE_DATA_FILES: self.closeFiles(self.sim.dataFiles) # TODO
+	
+	def resetSimulation(self):
+		self.doCreateWindow = True
+		self.gAdapter.reset()
+		self.createSimulation()
+		
+	def createSimulation(self):
+		
+		# set up the simulation parameters
+		self.sim = Simulation(FPS, STEPS_PER_FRAME)
+		self.sim.addBasicSimulationObjects()
+		self.sim.addAxes()
+		self.sim.addFloor(normal=(0,1,0), boxSize=(20,0.01,20))
+		
+		# create the objects specific to this program: ragdoll and obstacle
+		self.sim.addRagdoll(density=500, offset=(0.0,1.9,0.0))
+		self.sim.addObstacle(bodyLength=0.5, bodyradius=0.2)
+		
+		#test
+		if DO_TEST:
+			self.sim.addSphere(50, 0.5, (0,5,0))
+			box1 = self.sim.addBox(50, (1,1,1), (-1,2,-1))
+			sphere1 = self.sim.addSphere(50, 0.5, (-1,3,-1))
+			box2 = self.sim.addBox(50, (1,1,1), (-1,4,-1))
+			box3 = self.sim.addBox(50, (1,1,1), (-1,5.2,-1))
+			
+			self.sim.addBox(50, (1,1,1), (-2,0.5,0))
+			self.sim.addBox(50, (1,1,1), (-2,1.5,0))
+			self.sim.addBox(50, (1,1,1), (-2,2.5,0))
+			
+			self.sim.addBox(50, (0.3,0.3,0.3), (-0.7,1,-0.7))
+			
+			self.sim.addCylinder(100, 2, 0.3, (3,1,3))
+			self.sim.addCylinder(100, 2, 0.3, (3,1,3))
+			
+			self.sim.addBallSocketJoint(self.sim.getObject(box1), self.sim.getObject(sphere1), (-1,3,-1))
+			self.sim.addFixedJoint(self.sim.getObject(sphere1), self.sim.getObject(box2))
+			#self.sim.addRotaryJoint(self.sim.getObject(box2), self.sim.getObject(box3), (-1.5,4.6,-1), (0,0,1))
+		
+		# add the graphic objects
+		self.gAdapter.addObjectsList(self.sim.getActors().values())
+		self.sim.updateActors()
+		#self.gAdapter.restartWindow()
+#		self.gAdapter.startWindow(self.sim.onIdle, self.createSimulation)
+
+	def onActionSelection(self, key):
+		print(key)
+		
+		if key == 'r':
+			print("reset simulation")
+			self.resetSimulation()
+		elif key == 'a':
+			print("joint1vel_user increment")
+		elif key == 'z':
+			print("joint1vel_user decrement")
+		elif key == 'd':
+			print("joint2vel_user increment")
+		elif key == 'c':
+			print("joint2vel_user decrement")
+		elif key == 'q':
+			print("toggle use of QuickStep function")
+		else:
+			print("no action defined for that key")
+
+	def readFilenames(self):
+		# TODO
+		pass # see Ragdoll2.ars.RagdollPyOdeVtk
+	
+	def openFiles(self):
+		# TODO
+		pass # see Ragdoll2.ars.RagdollPyOdeVtk
+	
+	def closeFiles(self, files):
+		# TODO
+		for _key in files:
+			files[_key].close()
+
+if __name__ == '__main__':
+	print('this is RagdollPyOdeVtk.py')
+	Program()
+	sys.exit(None)
+TODO
+
+general
+-fix the conditions of ifs and loops that use None, ==, "and" and "or" inappropriately
+-dBodySetFiniteRotationMode
+-dBodySetFiniteRotationAxis. is it necessary to set this if dBodySetFiniteRotationMode = true?
+-rename package "model" to "core"?
+
+visualization
+-create a subclass of vtkInteractorStyleTrackball (http://www.vtk.org/doc/nightly/html/classvtkInteractorStyleTrackball.html)
+-remove the event bindings for this class which interfere with the desired behavior
+	http://vtk.org/doc/nightly/html/classvtkRenderWindowInteractor.html
+-see VTK/Tutorials/InteractorStyleSubclass (http://www.vtk.org/Wiki/VTK/Tutorials/InteractorStyleSubclass) for ideas
+-save screenshot: http://www.vtk.org/Wiki/VTK/Examples/Python/Screenshot
+-for a plane use a PlaneSource instead of a slim box
+	http://www.vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Plane
+-add shadows
+
+joints
+-store joint rotation limits and resistive force factors
+
+GUI
+-Qt integration
+	from PyQt4 import QtCore, QtGui, uic
+	'''
+	# Create a PyQt window using a .ui file generated with Qt Designer ...
+	application = QtGui.QApplication(sys.argv)
+	window = uic.loadUi("gui.ui")
+	vertex_slider = window.findChild(QtGui.QSlider, "vertexCount")
+	edge_slider = window.findChild(QtGui.QSlider, "edgeCount")
+	
+	window.show()
+	application.exec_()
+	'''
+
+packaging
+-if the software is installed using by executing
+		sudo python setup.py install
+	or
+		sudo checkinstall python setup.py install
+	then files will be created in directories like this
+		/usr/local/lib/python2.6/dist-packages/RagdollPyOdeVtk.py
+	and
+		/usr/local/lib/python2.6/dist-packages/model/robot/sensors.py to sensors.pyc
+	which is not desirable because they are not under a single directory named after the project,
+	with an appropriate structure which may also prevent clashes with other projects. 
+# see file:///usr/share/doc/python2.6/html/distutils/configfile.html
+# see file:///usr/share/doc/python2.6/html/install/index.html#inst-config-syntax
+[build_ext]
+inplace=1
+# coding: utf-8
+
+'''
+Created on Nov 2, 2011
+Last modified on Nov 2, 2011
+
+@author: german
+'''
+
+'''
+Sometimes things go wrong, and the setup script doesn’t do what the developer wants.
+Distutils catches any exceptions when running the setup script, and print a simple error message
+before the script is terminated.
+
+The DISTUTILS_DEBUG environment variable can be set to anything except an empty string,
+and distutils will now print detailed information what it is doing, and prints the full traceback
+in case an exception occurs.
+
+from file:///usr/share/doc/python2.6/html/distutils/setupscript.html
+'''
+
+from distutils.core import setup #, Extension
+
+# only name, version, url are required. Other fields are optional.
+setup(name='Autonomous Robot Simulator',
+	version='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',
+	author_email='gelarrai@uc.cl',
+	url='http://ral.ing.puc.cl/',
+	download_url='',
+	platforms='',
+	license='',
+	#classifiers=[], # e.g. Development Status, Environment, Intended Audience, License, Operating System, Programming Language, Topic
+	requires=[],
+	#package_dir=[] 
+	packages=['app', 'graphics', 'gui',
+			'model', 'model.contrib', 'model.geometry', 'model.robot', 'model.simulator',
+			'utilities'],
+	py_modules=['RagdollPyOdeVtk'],
+	#ext_modules=[]
+	#libraries=[]
+	#scripts=[],
+	#package_data={},
+	#data_files=[]
+)

setup.cfg

-# see file:///usr/share/doc/python2.6/html/distutils/configfile.html
-# see file:///usr/share/doc/python2.6/html/install/index.html#inst-config-syntax
-[build_ext]
-inplace=1

setup.py

-# coding: utf-8
-
-'''
-Created on Nov 2, 2011
-Last modified on Nov 2, 2011
-
-@author: german
-'''
-
-'''
-Sometimes things go wrong, and the setup script doesn’t do what the developer wants.
-Distutils catches any exceptions when running the setup script, and print a simple error message
-before the script is terminated.
-
-The DISTUTILS_DEBUG environment variable can be set to anything except an empty string,
-and distutils will now print detailed information what it is doing, and prints the full traceback
-in case an exception occurs.
-
-from file:///usr/share/doc/python2.6/html/distutils/setupscript.html
-'''
-
-from distutils.core import setup #, Extension
-
-# only name, version, url are required. Other fields are optional.
-setup(name='Autonomous Robot Simulator',
-	version='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',
-	author_email='gelarrai@uc.cl',
-	url='http://ral.ing.puc.cl/',
-	download_url='',
-	platforms='',
-	license='',
-	#classifiers=[], # e.g. Development Status, Environment, Intended Audience, License, Operating System, Programming Language, Topic
-	requires=[],
-	#package_dir=[] 
-	packages=['app', 'graphics', 'gui',
-			'model', 'model.contrib', 'model.geometry', 'model.robot', 'model.simulator',
-			'utilities'],
-	py_modules=['RagdollPyOdeVtk'],
-	#ext_modules=[]
-	#libraries=[]
-	#scripts=[],
-	#package_data={},
-	#data_files=[]
-)