simulator Package

simulator Package

class SimulatedBody(name, body=None, actor=None, geom=None)[source]

Bases: ars.model.simulator.SimulatedPhysicsObject

Class encapsulating the physics, collision and graphical objects representing a body.

All the public attributes of the physics object (_body) are accessible as if they were from this class, by using a trick with __getattr__. This avoids code duplication and frequent changes to the interface.

For example, the call sim_body.get_linear_velocity() works if method sim_body._body.get_linear_velocity exists.

There are some exceptions such as the getters and setters of position and rotation because the base class SimulatedPhysicsObject defines those abstract methods (some other non-abstract methods use them) and requires its subclasses to implement them. Otherwise we get “TypeError: Can’t instantiate abstract class SimulatedBody with abstract methods”.

body
get_position()[source]

Get the position of the body.

Returns:position
Return type:3-sequence of floats
get_rotation()[source]

Get the orientation of the body.

Returns:rotation matrix
Return type:9-sequence of floats
set_position(pos)[source]

Set the orientation of the body.

Parameters:pos (3-sequence of floats) – position
set_rotation(rot)[source]

Set the orientation of the body.

Parameters:rot (9-sequence of floats) – rotation matrix
class SimulatedJoint(name=None, joint=None, actor=None)[source]

Bases: ars.model.simulator.SimulatedPhysicsObject

add_torque(torque)[source]
get_position()[source]
get_rotation()[source]
joint
set_position(pos)[source]
set_rotation(rot)[source]
class SimulatedObject(name, actor=None)[source]

Bases: object

actor
get_name()[source]
has_actor()[source]
is_updatable()[source]
set_name(name)[source]
class SimulatedPhysicsObject(name, actor=None)[source]

Bases: ars.model.simulator.SimulatedObject

get_pose()[source]

Get the pose (3D position and rotation) of the object.

Returns:pose
Return type:ars.utils.geometry.Transform
get_position()[source]

Get the position of the object.

Returns:position
Return type:3-sequence of floats
get_rotation()[source]

Get the orientation of the object.

Returns:rotation matrix
Return type:9-sequence of floats
offset_by_object(obj)[source]
offset_by_position(offset_pos)[source]
rotate(axis, angle)[source]

Rotate the object by applying a rotation matrix defined by the given axis and angle

set_pose(pose)[source]

Set the pose (3D position and rotation) of the object.

Parameters:pose (ars.utils.geometry.Transform) –
set_position(pos)[source]

Set the orientation of the object.

Parameters:pos (3-sequence of floats) – position
set_rotation(rot)[source]

Set the orientation of the object.

Parameters:rot (9-sequence of floats) – rotation matrix
update_actor()[source]

If there is no actor, it won’t do anything

class Simulation(FPS, STEPS_PF)[source]

Bases: object

actors

Return a dict with each object actor indexed by the object name.

add_axes()[source]
add_ball_socket_joint(name, obj1, obj2, anchor)[source]

Adds a “ball and socket” joint between obj1 and obj2, at the specified anchor. If anchor is None, it will be set equal to the position of obj2.

add_basic_simulation_objects(gravity=(0.0, -9.81, 0.0))[source]

Create the basic simulation objects needed for physics and collision such as a contact group (holds temporary contact joints generated during collisions), a simulation ‘world’ (where physics objects are processed) and a collision space (the same thing for geoms and their intersections).

Parameters:gravity (3 floats tuple.) – Gravity acceleration.
add_box(size, center, mass=None, density=None)[source]
add_capsule(length, radius, center, mass=None, density=None)[source]
add_cylinder(length, radius, center, mass=None, density=None)[source]
add_fixed_joint(obj1, obj2)[source]
add_floor(normal=(0, 1, 0), dist=0, box_size=(5, 0.1, 5), box_center=(0, 0, 0), color=(0.2, 0.5, 0.5))[source]

Create a plane geom to simulate a floor. It won’t be used explicitly later (space object has a reference to it)

add_joint(sim_joint)[source]
add_object(sim_object)[source]

Add sim_object to the internal dictionary of simulated objects.

If its name equals an already registered key, it will be modified using its string representation, for example:

>>> add_object(sim_object)
sphere/<ars.model.simulator.SimulatedBody object at 0x3a4bed0>
Parameters:sim_object (SimulatedObject) – object to add
Returns:name/key of the object
Return type:string
add_rotary_joint(name, obj1, obj2, anchor, axis)[source]

Adds a rotary joint between obj1 and obj2, at the specified anchor and with the given axis. If anchor is None, it will be set equal to the position of obj2

add_slider_joint(name, obj1, obj2, axis)[source]

Add a jo.Slider joint between obj1 and obj2.

The only movement allowed is translation along axis.

Returns:the name under which the slider was stored, which could be different from the given name
add_sphere(radius, center, mass=None, density=None)[source]
add_trimesh_floor(vertices, faces, center=(0, 0, 0), color=(0.2, 0.5, 0.5))[source]
add_universal_joint(obj1, obj2, anchor, axis1, axis2)[source]
collision_space
get_bodies()[source]

Return a list with all the bodies included in the simulation.

Returns:list of SimulatedBody objects
get_joint(name)[source]
get_object(name)[source]
gravity
joints
objects
on_idle()[source]
perform_sim_steps_per_frame()[source]
sim_time
time_step
update_actors()[source]

Update pose of each simulated object’s corresponding actor.

signals Module

This module contains string values defining different signals related to the ars.model.simulator package.