Skip to content

A python library for optimization, geared towards modular robots and evolutionary computing.

License

Notifications You must be signed in to change notification settings

ci-group/revolve2

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date
Apr 3, 2024
Oct 8, 2024
Oct 22, 2024
Oct 17, 2024
Sep 13, 2024
Oct 8, 2024
Oct 22, 2024
Sep 13, 2024
Sep 13, 2024
Oct 8, 2024
Oct 8, 2024
Apr 30, 2024
Sep 13, 2024
Feb 28, 2024
Sep 11, 2023
Mar 29, 2024
Oct 8, 2024
Oct 8, 2024
Oct 8, 2024
Jan 16, 2024
Apr 3, 2024

Repository files navigation

Revolve2

Revolve2 is a collection of Python packages used for researching evolutionary algorithms and modular robotics. Its primary features are a modular robot framework, an abstraction layer around physics simulators, and evolutionary algorithms.

Documentation: ci-group.github.io/revolve2

Installation: ci-group.github.io/revolve2/installation

Get help: github.com/ci-group/revolve2/discussions/categories/ask-for-help

DOI License: LGPL v3 CI

Sample

Here we create and simulate a modular robot, and then calculate how far it moved over the xy plane. This is a shortened version of examples/evaluate_single_robot.

# (...) Omitted preamble

# Create a modular robot.
body = modular_robots_v1.gecko_v1()
brain = BrainCpgNetworkNeighborRandom(body=body, rng=rng)
robot = ModularRobot(body, brain)

# Create a scene.
scene = ModularRobotScene(terrain=terrains.flat())
scene.add_robot(robot)

# Create a simulator.
simulator = LocalSimulator(headless=False)

# Simulate the scene and obtain states sampled during the simulation.
scene_states = simulate_scenes(
    simulator=simulator,
    batch_parameters=make_standard_batch_parameters(),
    scenes=scene,
)

# Get the state at the beginning and end of the simulation.
scene_state_begin = scene_states[0]
scene_state_end = scene_states[-1]

# Retrieve the states of the modular robot.
robot_state_begin = scene_state_begin.get_modular_robot_simulation_state(robot)
robot_state_end = scene_state_end.get_modular_robot_simulation_state(robot)

# Calculate the xy displacement of the robot.
xy_displacement = fitness_functions.xy_displacement(
    robot_state_begin, robot_state_end
)