physics Package

base Module

class Body(mass=None, density=None, pos=None, rot=None, *args, **kwargs)[source]

Bases: object

attach_geom(geom)[source]
calc_potential_energy(gravity)[source]

Calculate the potential energy of the body due to its position (x) and the gravitational acceleration (g).

E_p &= m \cdot g \cdot h = - m \cdot g^\top x

Parameters:gravity (tuple of 3 floats) – gravitational acceleration vector
Returns:potential energy
Return type:float
calc_rotation_kinetic_energy()[source]

Calculate the kinetic energy of the body due to rotational movement.

E_{kr} = \frac{1}{2} I \omega^2 =
  \frac{1}{2} \omega^\top \mathbf{I} \omega

Returns:kinetic energy
Return type:float
calc_translation_kinetic_energy()[source]

Calculate the kinetic energy of the body due to translational movement.

E_{kt} = \frac{1}{2} m v^2
  = \frac{1}{2} m \cdot v^\top v

Returns:kinetic energy
Return type:float
get_angular_velocity()[source]
get_attached_geom()[source]
get_center_of_gravity()[source]
get_inertia_tensor()[source]
get_linear_velocity()[source]
get_mass()[source]
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
get_saved_velocities()[source]

Return last saved velocities (linear and angular).

inner_object
save_velocities()[source]

Retrieve the actual velocities (linear and angular) of the body and save them.

set_position(pos)[source]

Set the position of the body.

Sends signals.BODY_PRE_SET_POSITION and signals.BODY_POST_SET_POSITION.

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

Set the orientation of the body.

Sends signals.BODY_PRE_SET_ROTATION and signals.BODY_POST_SET_ROTATION.

Parameters:rot (9-sequence of floats) – rotation matrix
class Box(size, *args, **kwargs)[source]

Bases: ars.model.physics.base.Body

size
class Capsule(length, radius, *args, **kwargs)[source]

Bases: ars.model.physics.base.Body

length
radius
class Cone(height, radius, *args, **kwargs)[source]

Bases: ars.model.physics.base.Body

height
radius
class Cylinder(length, radius, *args, **kwargs)[source]

Bases: ars.model.physics.base.Body

length
radius
class Engine[source]

Bases: object

world_class = None
class Sphere(radius, *args, **kwargs)[source]

Bases: ars.model.physics.base.Body

radius
class World(gravity, *args, **kwargs)[source]

Bases: object

gravity
inner_object
step(time_step)[source]

Subclasses implementing this method must send the corresponding signals, defined in ars.model.physics.signals.

ode_adapter Module

Classes and functions to interface the ODE physics engine with the API defined in physics.

class Body(world, space, mass=None, density=None, *args, **kwargs)[source]

Bases: object

Abstract class, sort of equivalent to ode.Body.

Constructor.

Parameters:
get_angular_velocity()[source]
get_center_of_gravity()[source]
get_inertia_tensor()[source]
get_linear_velocity()[source]
get_mass()[source]
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 position of the body.

Sends signals.BODY_PRE_SET_POSITION and signals.BODY_POST_SET_POSITION.

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

Set the orientation of the body.

Sends signals.BODY_PRE_SET_ROTATION and signals.BODY_POST_SET_ROTATION.

Parameters:rot (9-sequence of floats) – rotation matrix
class Box(world, space, size, mass=None, density=None)[source]

Bases: ars.model.physics.ode_adapter.Body, ars.model.physics.base.Box

class Capsule(world, space, length, radius, mass=None, density=None)[source]

Bases: ars.model.physics.ode_adapter.Body, ars.model.physics.base.Capsule

create capsule body (aligned along the z-axis so that it matches the Geom created below, which is aligned along the Z-axis by default)

class Cylinder(world, space, length, radius, mass=None, density=None)[source]

Bases: ars.model.physics.ode_adapter.Body, ars.model.physics.base.Cylinder

create cylinder body (aligned along the z-axis so that it matches the Geom created below, which is aligned along the Z-axis by default)

class Engine[source]

Bases: ars.model.physics.base.Engine

Adapter to the ODE physics engine

world_class

alias of World

class Sphere(world, space, radius, mass=None, density=None)[source]

Bases: ars.model.physics.ode_adapter.Body, ars.model.physics.base.Sphere

class World(gravity=(0.0, -9.81, 0.0), ERP=0.2, CFM=1e-10, *args, **kwargs)[source]

Bases: ars.model.physics.base.World

Adapter to ode.World.

See also

Read abouth ERP and CFM in ODE’s wiki http://ode-wiki.org/wiki/index.php?title=Manual:_Concepts

Constructor.

Parameters:
  • gravity (3-sequence of floats) – gravity acceleration vector
  • ERP (float) – Error Reduction Parameter
  • CFM (float) – Constraint Force Mixing
gravity
step(time_step)[source]

ode_objects_factories Module

ODE objects factories i.e. functions that create ODE objects.

create_ode_box(world, size, mass=None, density=None)[source]

Create an ODE body with box-like mass parameters.

Parameters:
  • world (ode.World) –
  • size (3-sequence of floats) –
  • mass (float or None) –
  • density (float or None) –
Returns:

box body

Return type:

ode.Body

create_ode_capsule(world, length, radius, mass=None, density=None)[source]

Create an ODE body with capsule-like mass parameters.

Parameters:
  • world (ode.World) –
  • length (float) –
  • radius (float) –
  • mass (float or None) –
  • density (float or None) –
Returns:

capsule body

Return type:

ode.Body

create_ode_cylinder(world, length, radius, mass=None, density=None)[source]

Create an ODE body with cylinder-like mass parameters.

Parameters:
  • world (ode.World) –
  • length (float) –
  • radius (float) –
  • mass (float or None) –
  • density (float or None) –
Returns:

cylinder body

Return type:

ode.Body

create_ode_sphere(world, radius, mass=None, density=None)[source]

Create an ODE body with sphere-like mass parameters.

Parameters:
  • world (ode.World) –
  • radius (float) –
  • mass (float or None) –
  • density (float or None) –
Returns:

sphere body

Return type:

ode.Body

create_ode_world(gravity=(0.0, -9.81, 0.0), ERP=0.8, CFM=1e-10)[source]

Create an ODE world object.

Parameters:
  • gravity (3-sequence of floats) – gravity acceleration vector
  • ERP (float) – Error Reduction Parameter
  • CFM (float) – Constraint Force Mixing
Returns:

world

Return type:

ode.World

signals Module

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