modular_robot_simulation
Everything for the simulation of modular robots.
Package Contents
Classes
A scene of modular robots in a terrain. |
|
The state of a modular robot at some moment in a simulation. |
|
An interface for reading a certain state of a modular robot simulation. |
|
Terrain consising of only static geometry. |
Functions
Simulate one or more scenes. |
|
|
Test a robot with a manual brain. |
- class ModularRobotScene
A scene of modular robots in a terrain.
- terrain: modular_robot_simulation._terrain.Terrain
The terrain of the scene.
- add_robot(robot: revolve2.modular_robot.ModularRobot, pose: revolve2.simulation.scene.Pose = Pose(), translate_z_aabb: bool = True) None
Add a robot to the scene.
- Parameters:
robot – The robot to add.
pose – The pose of the robot.
translate_z_aabb – Whether the robot should be translated upwards so it’s T-pose axis-aligned bounding box is exactly on the ground. I.e. if the robot should be placed exactly on the ground. The pose parameters is still added afterwards.
- add_interactive_object(objt: revolve2.simulation.scene.MultiBodySystem) None
Add an intractable object to the scene.
- Parameters:
objt – The object as a multi body system.
- to_simulation_scene() tuple[revolve2.simulation.scene.Scene, dict[revolve2.simulation.scene.UUIDKey[revolve2.modular_robot.ModularRobot], revolve2.simulation.scene.MultiBodySystem]]
Convert this to a simulation scene.
- Returns:
The created scene.
- class ModularRobotSimulationState(simulation_state: revolve2.simulation.scene.SimulationState, multi_body_system: revolve2.simulation.scene.MultiBodySystem)
The state of a modular robot at some moment in a simulation.
- get_pose() revolve2.simulation.scene.Pose
Get the pose of the modular robot.
- Returns:
The retrieved pose.
- abstract get_module_relative_pose(module: revolve2.modular_robot.body.Module) revolve2.simulation.scene.Pose
Get the pose of a module, relative to its parent module’s reference frame.
In case there is no parent(the core), this is equal to getting the absolute pose.
- Parameters:
module – The module to get the pose for.
- Returns:
The relative pose.
- Raises:
NotImplementedError – Always.
- abstract get_module_absolute_pose(module: revolve2.modular_robot.body.Module) revolve2.simulation.scene.Pose
Get the pose of this module, relative the global reference frame.
- Parameters:
module – The module to get the pose for.
- Returns:
The absolute pose.
- Raises:
NotImplementedError – Always.
- class SceneSimulationState(simulation_state: revolve2.simulation.scene.SimulationState, modular_robot_to_multi_body_system_mapping: dict[revolve2.simulation.scene.UUIDKey[revolve2.modular_robot.ModularRobot], revolve2.simulation.scene.MultiBodySystem])
An interface for reading a certain state of a modular robot simulation.
- get_modular_robot_simulation_state(modular_robot: revolve2.modular_robot.ModularRobot) modular_robot_simulation._modular_robot_simulation_state.ModularRobotSimulationState
Get the simulation state for one of the modular robots in the scene.
- Parameters:
modular_robot – The modular robot to get the state for.
- Returns:
The retrieved state.
- Raises:
ValueError – If the robot is not in the scene.
- simulate_scenes(simulator: revolve2.simulation.simulator.Simulator, batch_parameters: revolve2.simulation.simulator.BatchParameters, scenes: modular_robot_simulation._modular_robot_scene.ModularRobotScene, record_settings: revolve2.simulation.simulator.RecordSettings | None = None) list[modular_robot_simulation._scene_simulation_state.SceneSimulationState]
- simulate_scenes(simulator: revolve2.simulation.simulator.Simulator, batch_parameters: revolve2.simulation.simulator.BatchParameters, scenes: list[modular_robot_simulation._modular_robot_scene.ModularRobotScene], record_settings: revolve2.simulation.simulator.RecordSettings | None = None) list[list[modular_robot_simulation._scene_simulation_state.SceneSimulationState]]
Simulate one or more scenes.
- Parameters:
simulator – The simulator to use for simulation.
batch_parameters – The batch parameters to use for simulation.
scenes – One or more scenes to simulate.
record_settings – The optional record settings to use during simulation.
- Returns:
A list of simulation states for each scene in the provided batch.
- class Terrain
Terrain consising of only static geometry.
- static_geometry: list[revolve2.simulation.scene.geometry.Geometry]
The static geometry that defines the terrain.
- test_robot(robot: revolve2.modular_robot.ModularRobot | revolve2.modular_robot.body.base.Body, terrain: modular_robot_simulation._terrain.Terrain, simulator: revolve2.simulation.simulator.Simulator, batch_parameters: revolve2.simulation.simulator.BatchParameters) None
Test a robot with a manual brain.
- Parameters:
robot – The ModularRobot or Body instance.
terrain – The terrain to test on.
simulator – The simulator.
batch_parameters – The batch parameters.