gale.physics.joint module

This file contains Joint, RevoluteJoint, and WheelJoint: constraints between two Bodies (a hinge, and a wheel-on-a-suspension-spring, respectively), wrapping a Box2D joint without ever exposing Box2D itself. Created through World.create_revolute_joint/create_wheel_joint.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.physics.joint.Joint(b2_joint)[source]

Bases: object

Base class for a constraint between two bodies. Created through World.create_revolute_joint/create_wheel_joint, never directly.

Parameters:

b2_joint (Any)

destroy(b2_world)[source]

Internal — use World.destroy_joint instead.

Parameters:

b2_world (Any)

Return type:

None

class gale.physics.joint.RevoluteJoint(b2_joint)[source]

Bases: Joint

A pin joint: constrains two bodies to rotate around a shared point, optionally motorized and/or limited to an angle range.

Usage example:

joint = world.create_revolute_joint(anchor_body, arm, (100, 50)) joint.enable_motor = True joint.motor_speed = 2.0 joint.max_motor_torque = 500

Parameters:

b2_joint (Any)

property angle: float
property motor_speed: float
property max_motor_torque: float
property enable_motor: bool
class gale.physics.joint.WheelJoint(b2_joint)[source]

Bases: Joint

A wheel with suspension: constrains a body to move along an axis relative to another (the suspension), plus an unconstrained rotation (the wheel spinning), optionally motorized.

Usage example:

joint = world.create_wheel_joint(

chassis, wheel, wheel.position, frequencyHz=4, dampingRatio=0.7

) joint.enable_motor = True joint.motor_speed = -10 # drive forward joint.max_motor_torque = 800

Parameters:

b2_joint (Any)

property motor_speed: float
property max_motor_torque: float
property enable_motor: bool
property frequency: float
property damping_ratio: float