Physical objects#
Part#
- class pyenki.PhysicalObject.Part#
Right prism that can be composed to define the geometry of a
pyenki.PhysicalObject.- shape#
The convex 2D polygon (positively oriented) at the base of the prism [cm].
- textures#
A list of textures: each texture is a list of colors for one vertical face of the prism. Must be either empty or have contains at least one color for each face.
- __init__(*args, **kwargs)#
Overloaded function.
__init__(lx: SupportsFloat, ly: SupportsFloat, height: SupportsFloat) -> None
Creates a part with a rectangular base.
- Parameters:
__init__(shape: Sequence[Vector], height: SupportsFloat, textures: Sequence[Sequence[pyenki.Color]] = []) -> None
Creates a part with a polygonal base.
- Parameters:
shape (Sequence[Vector]) – The convex 2D polygon (positively oriented) at the base of the prism [cm].
height (float) – The height [cm]
textures (Sequence[Sequence[Color]]) – A sequence of textures: each texture is a sequence of colors for one vertical face of the prism. Must be either empty or have contains at least one color for each face.
- contains(point: Vector, tolerance: SupportsFloat = 0) bool#
PhysicalObject#
- class pyenki.PhysicalObject#
The superclass of objects that can be simulated.
- name#
The name (readonly)
- Type:
string
- parts#
the parts the object is composed of.
- Type:
- collision_elasticity#
Elasticity of collisions of this object. If 0, soft collision, 100% energy dissipation; if 1, elastic collision, 0% energy dissipation. Actual elasticity is the product of the elasticity of the two colliding objects. Walls are fully elastics
- Type:
- viscous_friction_coefficient#
The viscous friction coefficient. Premultiplied by mass. A value of k applies a force of
-k * speed * mass- Type:
- viscous_moment_friction_coefficient#
The viscous friction moment coefficient. Premultiplied by momentOfInertia. A value of k applies a force of
-k * speed * moment_of_inertia- Type:
- collision_callback#
An optional function called when the object collides
def callback(PhysicalObject: obj1, PhysicalObject: obj2) -> None: ...
where
obj1andobj2are the two objects that have just collided.- Type:
Callable[[PhysicalObject, PhysicalObject], None] | None
- control_step_callback#
An optional function called when the object perform a control step
def callback(PhysicalObject: obj, time_step: bool) -> None: ...
with the same arguments as
pyenki.PhysicalObject.control_step().- Type:
Callable[[PhysicalObject, float], None] | None
- touch_callback#
An optional function called when touch events happen
def callback(PhysicalObject: obj, state: bool, button: int, x: float, y: float, z: float) -> None: ...
with the same arguments as
pyenki.PhysicalObject.on_touch().
- __init__(*args, **kwargs)#
Overloaded function.
__init__(parts: Sequence[pyenki.PhysicalObject.Part], mass: SupportsFloat, color: pyenki.Color = Color(r=0.0, g=0.0, b=0.0, a=1.0)) -> None
Creates an object composed of parts.
- Parameters:
parts (PhysicalObject.Part) – The parts.
mass (float) – The mass in kg.
color (Color) – The color.
__init__(radius: SupportsFloat, height: SupportsFloat, mass: SupportsFloat, color: pyenki.Color = Color(r=0.0, g=0.0, b=0.0, a=1.0)) -> None
Creates a cylinder.
- Parameters:
__init__(lx: SupportsFloat, ly: SupportsFloat, height: SupportsFloat, mass: SupportsFloat, color: pyenki.Color = Color(r=0.0, g=0.0, b=0.0, a=1.0)) -> None
Creates a rectangular prism.
- Parameters:
__init__(shape: Sequence[Vector], height: SupportsFloat, mass: SupportsFloat, color: pyenki.Color = Color(r=0.0, g=0.0, b=0.0, a=1.0), textures: Sequence[Sequence[pyenki.Color]] = []) -> None
Creates an vertical prism with a convex polygonal base.
- contains(point: Vector, tolerance: SupportsFloat = 0) bool#
- control_step(time_step: SupportsFloat) None#
The controller associated with the object.
Should be overridden by sub-classes to implement controllers, in particular for robots. Alternatively, users can assign a callback
control_step_callback.- Parameters:
time_step (float) – The time step of the simulation.
- on_touch(state: bool, button: SupportsInt, x: SupportsFloat, y: SupportsFloat, z: SupportsFloat) None#
Called after a touch event.
Can be overridden by sub-classes to react to touch events. Alternatively, users can assign a callback as
touch_callback.
- touch(state: bool, button: SupportsInt, x: SupportsFloat, y: SupportsFloat, z: SupportsFloat) None#
Trigger a touch event.
Warning
Textures are used to compute the sensors (cameras) response. They are displayed by the Python-based viewer/renderer but ignored by the native viewer/renderer.