Documentos de Académico
Documentos de Profesional
Documentos de Cultura
ShanghAI Lectures
Fall Term 2011
Introduction
Remember the Puppy robot from the lecture (Lecture 4, for instance)? In this exercise, you will have the chance to improve its brain as well as body. Fig. 1 shows a picture of one of the Puppy family members that we currently have at the lab: the Minidog.
Fig. 1. Minidog
Unlike in the case of the Passive Dynamic Walker that you have witnessed in the previous exercise, the Minidog is powered by motors. The controller is, however, very simple. We applied a simple oscillatory position control of the motors. Moreover, we have used the same parameters for the front leg pair and another set for the hind pair. The target joint angle of each motor Pf(t) and Ph(t) for the fore legs and hind legs respectively was determined as:
where the oscillation can be varied by changing the amplitude A, offset B, angular frequency ( = 2** f), and phase parameters. Each pair of legs thus oscillates in synchrony, however, there can be a phase difference of between the leg pairs. If they are close to out of phase ( = 3.14), the gait is called a bounding gait. Please watch a video of the Minidog running at: or
https://files.ifi.uzh.ch/ailab/people/hoffmann/puppy/videos/minidog.WMV https://files.ifi.uzh.ch/ailab/people/hoffmann/puppy/videos/minidog.mp4.
You can see that the behavior is far from optimal. How would you improve it? Maybe change the amplitude at which the hind legs move? Or the frequency at which the motors move is not right? Or maybe the body is not the best? Is the robot too wide? Or the legs too short? There are infinitely many possibilities. To get a better grip at this complex problem, we have created a model of this robot in the Webots simulator [1] (see Fig. 2), where it is more easy to experiment with different parameter settings.
b a tte r y
body
m o to r h ip s e rv o jo in t fe m u r k n e e jo in t tib ia
Task 1 (10 points in total)- Manual manipulation of brain (controller) and body
In this task, first, you are asked to play with the controller to observe how the robot behavior changes when one parameter changes. Then you will choose a case where the robot fails and try to achieve stability by tuning the spring in the legs.
1.1 (4 points) Manipulation of brain (controller) The parameters are the following: Controller C_Amp_F C_Amp_H C_Frequency C_Offset_F C_Offset_H C_Phase_H 0.7 0.7 2.5 0 0 from 0.1 to 1 by 0.1
Table 1. First, set up the simulator see Appendix Setup for Task 1. Now you will be tuning the phase lag between front and hind legs (C_Phase_H) from 0.1 to 1 in steps of 0.1. You can proceed like this: 1. Go to individual_controller.txt under the directory controllers/helper_classes/paramOptimization and set the appropriate C_Phase_H parameter (you can start with 0.1) and save. 2. Now press the Revert button in the simulator and let the robot run (you may need to press Run). 3. Stop simulation at 104 s as shown in the console and calculate the speed by averaging the last five speeds (if you are impatient, switch to the Fast simulation mode). If the robot falls before 100s, then the speed is 0. Ignore what happens after 104 s. After you have collected all the values (10 speeds), do the following: 1. Plot the average speed over phase, i.e. make a diagram with phase on the x-axis and speed on the y-axis. 2. Describe how you interpret the chart. Take a video of the best performance (like you did in Exercise 2 on Passive Dynamic Walkers in Webots; File->Make Movie). Deliverables: Document containing the chart, a brief interpretation of the chart, a proper value for C_Phase_H which makes Minidog walk with a good performance, and a video when phase equals 0.7.
First, Change C_Phase_H to 0.7 in individual_controller.txt and save. Now you will change the spring constants in the passive knees. To do that, you need to use the Scene tree, similarly to what you did with the Passive Dynamic Walker. To change the spring constant of front legs, you will access: DEF PUPPY ROBOTDEF HIP0 ServochildrenDEF KNEE0_SERVOSpring Constant. DEF PUPPY ROBOTDEF HIP1 ServochildrenDEF KNEE1_SERVOSpring Constant. For the hind legs, it is: DEF PUPPY ROBOTDEF HIP2 ServochildrenDEF KNEE2_SERVOSpring Constant. DEF PUPPY ROBOTDEF HIP3 ServochildrenDEF KNEE3_SERVOSpring Constant. Note: Be cautious to change the Knee servo and not the Hip servo spring constant. (a) Tuning the hind legs spring constant with front legs spring constant fixed to 0.5 Keep the front legs spring constant 0.5, and tune the spring constant in the hind legs from 0.1 to 1 in steps of 0.1. The procedure is similar to task 1.1, but this time you will be changing the world (.wbt) file through the Scene tree. You will proceed like this: 1. 2. 3. Stop the simulation and Revert. Change the appropriate spring constants and save the world. Revert and Run.
In each case, you proceed like in task 1.1 you will record the speed. (b) Tuning the hind legs spring constant with front legs spring constant fixed to 0.2 Same like (a), but fix the front legs spring constants (in the knees not hips!) to 0.2. Deliverables: Document containing the charts, a brief interpretation of the charta, a proper value of spring constant which makes the puppy walk with a good performance, and the associated video.
function is the speed of the robot1. The parameters and their ranges are listed in Table 2. Parameter Controller Amplitude front Amplitude hind Offset front Offset hind Phase lag Frequency Body Length Width Front Femur Length Front Knee Spring Constant Front Tibia Length Hind Femur Length Hind Knee Spring Constant Hind Tibia Length Angle at front knee joint Angle at hind knee joint PuppyLength PuppyWidth FrontFemurLength 0.133 0.1 0.052467 0.08 0.05 0.01 0.1 0.01 0.01 0.1 0.01 0.9 0.9 0.18 0.15 0.07 1 0.07 0.07 1 0.07 1.5 1.5 C_Amp_F C_Amp_H C_Offset_F C_Offset_H C_Phase_H C_Frequency 1 1 0 0 0.5 3 0.5236 0.5236 -0.698 -0.698 0 2.5 1.57 1.57 0.698 0.698 1 3.5 Param short name Default value Min Max
Table 2. Amplitude and offset values are in radians, phase lag is normalized to <-1,1>. Frequency is in Hz. From the body paramaters, the lengths are in meters, angles at passive knee joints are in radians.
If you run your simulator now, the optimization starts. 2 You will see a new Minidog controller being tested every 10s. The evolutionary algorithm is set for 30 generations, with 80 individuals each. This will take some time (e.g. 1 hour). Therefore, make sure you press the Fast button in the simulator like this you do not see the rendering, but the simulation runs much faster. If you want to see intermediate results, just press Run (play) button again, watch for a while, and then press Fast again. Depending on your system configuration, the simulation can take about an hour. You can watch the progress in the console. If there are no more outputs from the [supervisor_controller], just the speed from [mini_dog_controller], the evolution has finished. Then you can press Stop and go the question.
paramsRange_controller.txt Go to the controllers/helper_classes/paramOptimization/parameter_ranges/ directory, and copy the files paramsRange_body.txt paramOptimization dir.3 3. 4. Go to the paramOptimization dir and rename paramsRange_controller_noController.txt to paramsRange_controller.txt Start Webots. and paramsRange_controller_noController.txt one directory up to the
You will be seing Minidogs with different morphologies being tested (not all the MiniDog look so different in the beginning they started from one common ancestor). Press Fast and let the morphology evolve.
2 Please note that we are expecting you to follow the exercise sequentially. Hence the first parameter sets that are prepared in the controllers/helper_classes/paramOptimization directory paramsRange_controller.txt and paramsRange_body.txt are prepared for the controlleronly optimization. That is they are the files paramsRange_body.txt and paramsRange_controller_noController.txt from controllers/helper_classes/ paramOptimization/parameter_ranges/, where the latter file has been renamed to paramsRange_controller.txt.
3 Note that the original paramsRange_body.txt that you deleted before was actually from
paramsRange_body_noBody.txt, because in the previous task, the body was constant. ShanghAI Lectures Fall Term 2011 Exercise 3 6
Please re-initialize your simulator. Please see the Appendix Setup for Task 2 - Re-inialization for new experiments. Then do the following: 1. Under controllers/helper_classes/paramOptimization delete paramsRange_body.txt and
paramsRange_controller.txt 2. Go to the controllers/helper_classes/paramOptimization/parameter_ranges/ directory, and copy the files paramsRange_body.txt and paramsRange_controller.txt one directory up to the paramOptimization dir.4 3. Start Webots. You will be seeing Minidogs with different morphologies and controllers being tested (not all the MiniDog look so different in the beginning they started from one common ancestor). Press Fast and let the parameters evolve.
4 Note that the original paramsRange_body.txt that you deleted before was actually from
paramsRange_body_noBody.txt, because in the previous task, the body was constant. 5 Thanks to Juan Pablo Carbajal and Konstantinos Dermiztakis. ShanghAI Lectures Fall Term 2011 Exercise 3 7
Question 2.5.
(a) (3 points) Do you think the behavior of the robot in the simulator will exactly match the behavior in reality? If not, what could be the reasons for a potential mismatch (a so-called) reality gap? (b) (3 points) The alternative is to optimize the behavior directly on the real robot. Can you list some pros and cons of this approach as opposed to the simulation and then transferring the results to the real robot?
References
[1] Webots, http://www.cyberbotics.com/ [2] Sims, K. (1994a). Evolving virtual creatures. Computer Graphics, 28:1534.
[3] Lipson, H., and Pollack, J. B. (2000). Automatic design and manufacture of artificial lifeforms. Nature, 406:974978.
Acknowledgment
We would like to thank Stefan Hutter this exercise was based on the code that he developed as part of his Master thesis at the AI Lab. We would also like to gratefully acknowledge the support from Olivier Michel and Yvan Bourquin in the preparation of this exercise.
Appendix Preparation:
for Mac user: install Xcode 4 for Apple to compile files in webots
supervisor_controller.cpp:27:35: error: ./GA/geneticAlgorithm.h: No such file or directory. then a likely source of the problem is that your operating system or file manager has changed the directory name controllers/supervisor_controller/GA to ga - lower-case. You need to make sure it is in capitals.
delete the data from the previous experiment. Make sure you copy the results from the previous experiment (mainly the controllers/supervisor_controller/GA/eaStats.csv file) to another directory before initialization. First, quit Webots. Then: For Linux /Mac users: go to controllers/supervisor_controller/ and run setupGA.sh in a terminal.6
For Windows users: ( please manually execute the commands listed in setupGA.sh.) For all the copy commands use overwrite. Copy the protos directory from controllers/helper_classes/paramOptimization/optimization_seed/ to the current directory (mini_dog_webots) Copy worlds/ Copy individual.txt and individual_controller.txt from controllers/helper_classes/paramOptimization/ optimization_seed/ to controllers/helper_classes/paramOptimization/ Delete all the files under controllers/supervisor_controller/GA/todo/ Delete all the files under controllers/supervisor_controller/GA/done/ Delete individual.txt under controllers/supervisor_controller/GA/current/ Delete supervisor_memory.txt under/mini_dog_webots/controllers/supervisor_controller Delete (actually better store somewhere else) eaStats.csvunder controllers/supervisor_controller/GA/ miniDog.wbt from controllers/helper_classes/paramOptimization/optimization_seed/ to
Collecting results
The results are summarized in the eastats.csv file in the controllers/supervisor_controller/GA directory. You can open it in MS Excel, Open Office or similar software. It is semicolon (;) separated. In MS Excel you may need to do Data From text Import and choose of the columns (S AJ). semicolon ; as the delimiter. Now the first columns (A-R) correspond to a parent of each individual, the current individual is only the second half
The results are now in chronological order starting with the individuals from the 0th generation. To simplify the 6 Note, it can happen that some of the directories that you are trying to clean are already empty. Hence a message like rm: cannot remove `./GA/todo/*': No such file or directory does not have to worry you. ShanghAI Lectures Fall Term 2011 Exercise 3 10
evaluation, you can sort them by Fitness (Column AJ). To do this, mark all columns and sort by the last column fitness descending. The best individual will then be at the top. (If for some reason there are some individuals for which the fitness was not available there is nan, just ignore those individuals.) If you want, you can save this as eaStatsSortedByFitness.csv.