Assignment ## CS 206: Evolutionary Robotics Programming Assignment ## of ##
by user
Comments
Transcript
Assignment ## CS 206: Evolutionary Robotics Programming Assignment ## of ##
Paul Kiripolsky CS 206, Evolutionary Robotics Spring Semester, 2013 Assignment ## CS 206: Evolutionary Robotics Programming Assignment ## of ## Due: by 12:01 am Description: In this assignment, you will be constructing a hexapod alongside your quadruped and comparing which one travels further. When you are done, your python and C++/Bullet code will work together to generate a hexapod and or a quadruped. To begin, back up both your Python and Bullet code for assignment 10, then make copies of both of these and call them ‘Python_hex.py’ and ‘App_Ragdoll_Demo_hex.cpp’. The hexapod you will be making is radially Symmetric (two legs on either side and one on each end) like the one in Figure 1. 1. First, you will alter your python code so that it can handle the additional legs and motors. 2. Then, write some code in your Python that will allow the fits array to be output to a .dat file. 3. Go through your Bullet Code (in both your H and Main File) and change the parameters of the arrays, loops, etc. to match the new parameters for the hexapod. 4. Finally, in your Bullet Code you will keep all of the physical parameters for the body (length, width, etc.) and legs the same but change the orientation of the legs to that in Figure 1. 5. Finally, run your python code making sure it calls the .exe compiled code from bullet. 1) Open your python code and change the number of sensors to 6 and the number of motors to 12. Paul Kiripolsky CS 206, Evolutionary Robotics Spring Semester, 2013 2) In your main Hill climber function, right before the return parameter but after the fitness has already been evaluated and placed in the fitness array, insert these two lines of code that will export your fitness’s to a data file for graphing later: for cur_gen in range(len(fits)): fits[cur_gen] = parentFit child = MatrixPerturb_P2CPP(parent,0.05) child_fitness = Fitness_P2CPP(child) print "Generation:", cur_gen, "Parent Fitness: ", parentFit, "Child Fitness: ", child_fitness if(child_fitness > parentFit): parent = deepcopy(child) #Sending succesful synaptic weights to file success.dat succesWeight = 'C:/Users/XX/…/success.dat' Send_Synapse_Weights_ToFile(parent,succesWeight) time.sleep(0.2) parentFit = child_fitness fits[cur_gen] = parentFit fits_name = 'C:/Users/XX/…/fitness.dat' SendToFitFile(fits_name,fits) return parent 3) Save your python and minimize it. Open up your Ragdoll code. 4) Now in your H file, go through and make sure that your variables and parameters are set up to handle the hexapods specific configuration like so: btRigidBody* body[13]; // one main body, 2X6 leg segments btCollisionShape* geom[13]; ……………………………………… btHingeConstraint* joints[12]; ……………………………………… int ID[14];// one main body, 2X6 leg segments, ground ……………………………………… public: int *touches; btVector3 touchpoints[14]; double weights[6][12];//6 legs, 2 motors per leg = 12 motors ……………………………………… 5) Skip down a few lines and change the renderme() function as well: virtual void renderme() { ……………………………………… for(int i = 0; i<14; i++){ if(touches[i] == 1){ //sleep(5); gDebugDrawer.drawSphere(touchpoints[i], 0.4, ……………………………………… } Paul Kiripolsky CS 206, Evolutionary Robotics Spring Semester, 2013 6) Now move into your main file and skip down to your initPhysics() function. Go ahead and change the parameters here to ensure that they work with the hexapod (make sure your for-loops are setup correctly). Make sure to set the ID[13] = 13. This is to denote the ID of the ground. 7) Comment out the lines of code responsible for actuating your robot in the clientMoveAndDisplay() function but make sure to leave m_dynamicsWorld>stepSimulation(ms / 1000000.f ); Uncommented so that your simulation still renders properly. As before, make sure that you change the parameters of the different variables, loops, indexes, etc. to match up with a hexapod configuration. 8) In addition to commenting out the actuate joint commands, also comment out the line(s) of code responsible for exiting the simulation and run your simulation. You ought to get the same quadruped as before sans moving joints… so essentially, you end up with a ragdoll quadruped. Then, skip down to exitPhysics() and change the indexes of the loops used to delete objects and geoms there (if applicable). 9) Now, go back to initPhysics() and actually alter the physical shape of your robot so that it resembles the robot in Figure 1. You’ll have to add two extra legs to it and offset some of them slightly. 10) Go to wherever you set your hinge limits and make sure that your extra limbs are taken into account. 11) Compile your code and make sure that it runs without errors. Once you are sure there are no bugs and your bot just sits there with the correct joint limits, exit the executable and go back to your clientMoveAndDisplay() function. Uncomment out your lines responsible for actuating the joints. Compile and run the program again. You should see your new hexapod writhing around like in Figure 3. 12) Finally, after you’ve compiled your RagDollDemo save it and close it out. Now, go to your python code and run the code. Make sure that it’s calling the executable for the ragdoll demo. Paul Kiripolsky CS 206, Evolutionary Robotics Spring Semester, 2013 Figure 1 Figure 2 Paul Kiripolsky CS 206, Evolutionary Robotics Spring Semester, 2013 Figure 3