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
-
-
class
SimulatedJoint
(name=None, joint=None, actor=None)[source]¶ Bases:
ars.model.simulator.SimulatedPhysicsObject
-
joint
¶
-
-
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
-
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
-
-
class
Simulation
(FPS, STEPS_PF)[source]¶ Bases:
object
-
actors
¶ Return a dict with each object actor indexed by the object name.
-
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_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_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 addReturns: 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 betweenobj1
andobj2
.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
-
collision_space
¶
-
get_bodies
()[source]¶ Return a list with all the bodies included in the simulation.
Returns: list of SimulatedBody
objects
-
gravity
¶
-
joints
¶
-
objects
¶
-
sim_time
¶
-
time_step
¶
-
signals
Module¶
This module contains string values defining different signals related to
the ars.model.simulator
package.