roboball2d.robot package

Submodules

roboball2d.robot.default_robot_config module

class roboball2d.robot.default_robot_config.DefaultRobotConfig

Bases: object

Configuration required to render and compute the dynamics of 3 dof robot consisting of 2 rods and a racket (and 3 related joints). User code may change values of the attributes after instantiation.

position: x position of the robot (in meters)

max_torques: (3d tuple of floats) max torques that can be applied on joints

max_motor_speed:
(float) max motor speed. If using b2world as dynamic engine, it will be the speed the dynamic engine will try to impose on all joints at all time. User control will be achieved by limiting the maximum torque the engine will be allowed to apply on joints. If the engine can attain this maximum speed without applying the maximum torque set by the user code, then the user code looses the ability to directly control the robot
rod_diameter:
(float) in meters, will be applied for the 2 rods
rod_length:
(float) in metters, will be applied for the 2 rods
rod_density
(float) applied on the 3 rods. See b2box documentation on density
rod_joint_limit
(float) angle limit (radian) for the 2 rods (will be between - and + this value)
rods:
(2d array of Rod) each rod as a rob_joint_limit and a rod_length attribute
racket_diameter:
(float) in meters
racket_thickness:
(float) in meters
racket_density:
(float) see box2d documentation on significance of density
racket_restitution:
(float) see box2d documentation on significance of density
racket_joint_limit:
(float) racket joint limit in radian (+/- this value)
racket:
instance of Racket, which has joint_limit attribute
joint_radius:
(float) in meters
items:
Array of 3 instances : 2 Rod, 1 Racket
rod_color:
(3d tuple of float) color of rods (R,G,B), values between 0 and 1
racket_color:
(3d tuple of float) color of rods (R,G,B), values between 0 and 1
joint_color:
(3d tuple of float) color of rods (R,G,B), values between 0 and 1
linear_damping:
(float) in [0, infty), higher values cause stronger damping of linear velocity of rods and racket
angular_damping:
(float) in [0, infty), higher values cause stronger damping of angular velocity of rods and racket
__init__()

Initialize self. See help(type(self)) for accurate signature.

angular_damping
create_b2_robot(b2world, ground)

(Advanced usage)

This function is not meant to be used directly by the user code. It will be called in the constructor of tennis2d.physics.B2World to generate, based on this configuration, an instance of an object suitable for dynamic update of the robot.

b2world :
an instance of tennis2d.physics.B2World
ground (float):
y position of the robot

An instance of roboball2d.physics.default_b2_robot.DefaultB2Robot

items
joint_color
joint_radius
linear_damping
max_motor_speed
max_torques
position
racket
racket_color
racket_density
racket_diameter
racket_joint_limit
racket_restitution
racket_thickness
rod_color
rod_density
rod_diameter
rod_joint_limit
rod_length
rods

roboball2d.robot.default_robot_state module

class roboball2d.robot.default_robot_state.DefaultRobotState(robot_config, generalized_coordinates=None, generalized_velocities=None)

Bases: roboball2d.robot.robot_state.RobotState

An instance of robot state fully describes the state of a 3dof robot (2 rodes and a racket, with 3 corresponding joints). It is used for example in roboball2d.physics.world_state.WorldState.

robot_config:
configuration of the robot used to update its dynamics or for rendering it. See roboball2d.robot.default_robot_config.DefaultRobotConfig
rods:
list of two roboball2d.item.Item
racket
an instance of roboball2d.item.Item
joints
list of three instances of roboball2d.item.Item
angles
current angles in radians
angular_velocities
angular velocities in radians per second
robot_config:
configuration of the robot used to update its dynamics or for rendering it. See roboball2d.robot.default_robot_config.DefaultRobotConfig
generalized_coordinates: list of floats
angles (in radian) of the three joints. Angles will be set to 0 if None
generalized_velocities: list of floats
angular velocities of the three joints, which will be set to 0 if None
__init__(robot_config, generalized_coordinates=None, generalized_velocities=None)
robot_config:
configuration of the robot used to update its dynamics or for rendering it. See roboball2d.robot.default_robot_config.DefaultRobotConfig
generalized_coordinates: list of floats
angles (in radian) of the three joints. Angles will be set to 0 if None
generalized_velocities: list of floats
angular velocities of the three joints, which will be set to 0 if None
angles
angular_velocities
joints
racket
render(color=None, z_coordinate=None)
robot_config
rods

roboball2d.robot.pd_controller module

class roboball2d.robot.pd_controller.PDController(kp=[2.0, 1.0, 0.5], kd=[0.35, 0.2, 0.05])

Bases: object

PDController : a simple PD controller for 3dofs robot

kp (3d array of floats) :
proportional gains
kd (3d array of floats) :
derivative gains
__init__(kp=[2.0, 1.0, 0.5], kd=[0.35, 0.2, 0.05])
kp (3d array of floats) :
proportional gains
kd (3d array of floats) :
derivative gains
get(references, angles, angular_velocities)
references:
3d list of desired angle values
angles:
3d list of current angle values
angular_velocities:
3d list of current angular velocities

a 3d list of torques

roboball2d.robot.robot_config module

class roboball2d.robot.robot_config.RobotConfig

Bases: object

Interface a robot configuration must implement to be used with roboball2d.physics.b2_world.B2World and roboball2d.physics.rendering.pyglet_renderer.PygletRenderer See : :py:class:`roboball2d.robot.default_robot_config.DefaultRobotConfig

__init__()

Initialize self. See help(type(self)) for accurate signature.

create_b2_robot(world, ground)

roboball2d.robot.robot_state module

class roboball2d.robot.robot_state.RobotState(robot_config, generalized_coordinates=None, generalized_velocities=None)

Bases: object

Interface a robot state must implement to be used with roboball2d.physics.rendering.pyglet_renderer.PygletRenderer See : :py:class:`roboball2d.robot.default_robot_state.DefaultRobotState

__init__(robot_config, generalized_coordinates=None, generalized_velocities=None)

Initialize self. See help(type(self)) for accurate signature.

render()

Module contents