Evolving Virtual Robots

University Project on Evolutionary Robotics

November 2020

In the spring of 2020 I had the opportunity to take an Evolutionary Robotics course at the University of Vermont with Professor Josh Bongard, which involved both the history and practical application of evolutionary algorithms and virtual robotics simulations. Over the duration of the course students were expected to develop and expand on a basic evolutionary robotic model, instructions for which can be found online in the /r/ludobots subreddit., which promotes itself as a  "reddit-based online open course for crowdsourcing research in the field of Evolutionary Robotics". For the final assessment in the course, students were asked to expand on the model outlined in the ludobots subreddit, and test an original hypothesis utilizing the evolutionary robot model.

The original goal of the project was to examine whether allowing for quadrupeds to evolve the lengths of their upper and lower legs would allow for improved locomotion in difficult terrain. The first step in approaching this goal was to add functionality to enable additional collision objects to be added to the scene, in order to form varied terrain for robots to navigate. Initially, the idea was to generate a random terrain each time the simulated robot was tested, using additional boxes to simulate differences in elevation. While the method of creating difficult terrain was effective, the decision was made to test robots on uniform rough terrain rather than random terrain to ensure that fitness was not affected by the terrain variation, and rather only by the phenotype and evolved movement algorithm of the simulated robot. For the rest of the development process robots were tested on rough terrain consisting of evenly spaced boxes, which were selected as it offered the robots the option to develop various movement behaviors, such as avoiding the boxes, or climbing over them.

The second step focused on extending the genetic algorithm to alter the physical properties of the robot. After some deliberation the decision was made to only alter the length of the legs, such that the length of the upper and lower legs could evolve over time. The upper legs are the same relative to one another, as do the lower legs, such that the robot maintains rotational symmetry at 90 degrees. There was consideration on allowing the evolutionary algorithm to have control over the positioning of the legs as well, however this idea was not utilized as it would require a significant increase in the complexity of the code used to build the robot model without clear benefit. While implementing the variable leg sizes, the decision was also made to scale the ‘body’ of the robot to the size of the legs. This decision was made as a robot with shorter legs would struggle to function with a large body, and a robot with longer legs gains additional stability from a larger body from which the legs are attached.

The third and final step of the development process was aimed at testing the new evolutionary algorithm on rough terrain, and using the results to make conclusions about what body plans allowed for the greatest mobility and what factors played a significant role in the success of different evolutionary models. The final results proved that not only did the altered algorithm allow for improved fitness among the population, but that specific body plans were best suited for mobility in the tested terrain.

Implementation of the modified code was done in steps, and aimed to preserve the modularity of the existing code base for quadruped robot evolution from the ludobots subreddit. Maintaining comprehensive and well commented code was a must given the complexity of the program. Over the course of the development process several different variations were tested, which included the default quadruped, quadrupeds which started with the same leg lengths as the default quadruped that rarely had mutations to the leg lengths, quadrupeds that started with random leg lengths and had rare mutations to the leg lengths, and quadrupeds which started with random leg lengths and received frequent mutations to the leg lengths. The chart below shows the distribution of the fitness for these robots, as a cumulative average of 10 evolutionary runs each given a population of 15 and 300 generations. 

The above chart shows that the robots which started with random leg lengths on average had a higher fitness than those that did not, and that allowing for frequent mutations to the leg lengths allowed for a significant increase in the possible fitness for the robots. The speculated reason that the final test group showed such a difference from prior groups was the ability to develop very long legs, which allowed for the robots in question to achieve a high fitness with less coordination than a robot with shorter legs. Furthermore, robots were observed to evolve to a size where their legs could effectively walk between the terrain obstacles, suggesting that the robots evolved specialized body plans for the given terrains. 

Fitness curve graphs provide a further look into the differences between the default and the improved evolutionary process, as it may be observed that the default quadruped shows constant slow growth over time, whereas the quadruped utilizing evolution of the leg lengths shows greater growth, but in significant jumps rather than constant growth. It appears likely that this behavior is a result of random significant changes to the morphological properties of the robot, as a robot which evolves longer legs may see a notable change in fitness immediately, versus a robot which only changes the controller will rarely see such a spike in performance. 

The most difficult part of this process was altering the code that defines how the robot is meant to be assembled to take in variable input so as to enable a variable body plan. Changing just one length requires each part to compensate, and so ensuring that the code would not cause the robot to be assembled incorrectly was critical. Adding new environments was relatively easy, once a means of doing so was found. Adding collision entities was a positive lesson as well, and future work could potentially explore how robots navigate all sorts of terrain that was not tested in this case. Allowing for the ‘ground’ of the simulation to be altered could make this task easier, or alternatively specific terrain models could be inputted into the simulation as large 3D shapes. Furthermore, more of the physical properties of the robot could be set up to be altered by evolution, such as the thickness of the legs, the shape of the body, and the positioning of the legs. Adjusting further physical properties would likely require significant code rewrites, as each component needs to be appropriately connected to the others.

The video below summarizes the findings of this project.