larvaworld.lib.model.agents.braitenberg_robot

Classes

DifferentialDriveRobot

Two-wheeled differential drive robot with triangular body.

SensorDrivenRobot

Differential drive robot with sensorimotor control.

Module Contents

class larvaworld.lib.model.agents.braitenberg_robot.DifferentialDriveRobot(unique_id: str, model: Any, x: float, y: float, length: float, wheel_radius: float)

Bases: larvaworld.lib.model.modules.RotTriangle

Two-wheeled differential drive robot with triangular body.

Implements differential steering kinematics where left/right wheel speeds control translation and rotation. Used as base for Braitenberg vehicle simulations with sensor-motor coupling.

Attributes:

speed_left_wheel: Angular velocity of left wheel (rad/s) speed_right_wheel: Angular velocity of right wheel (rad/s) wheel_radius: Radius of drive wheels (meters) length: Robot body length (meters) deltax: X displacement in last timestep deltay: Y displacement in last timestep

Example:
>>> robot = DifferentialDriveRobot(
...     unique_id='robot_1',
...     model=sim_model,
...     x=0.5, y=0.5,
...     length=0.01,
...     wheel_radius=0.002
... )
>>> robot.speed_left_wheel = 1.0
>>> robot.speed_right_wheel = 0.8
>>> robot.step()  # Update position based on wheel speeds
model
unique_id
length
wheel_radius
speed_left_wheel = 0.0
speed_right_wheel = 0.0
deltax = None
deltay = None
step() None

Updates x, y and direction

move_duration(seconds: float) None

Moves the robot for an ‘s’ amount of seconds

print_xyd() None

Prints the x,y position and direction

delta_x() None
delta_y() None
delta_direction() None
class larvaworld.lib.model.agents.braitenberg_robot.SensorDrivenRobot(**kwargs: Any)

Bases: DifferentialDriveRobot

Differential drive robot with sensorimotor control.

Extends DifferentialDriveRobot with bilateral motor controllers and sensors, implementing reactive Braitenberg vehicle behaviors (obstacle avoidance, phototaxis, etc.) via sensor-motor coupling.

Attributes:

left_motor_controller: Left motor controller with sensor right_motor_controller: Right motor controller with sensor collision_with_object: Collision detection flag label: Optional robot label for visualization

Example:
>>> robot = SensorDrivenRobot(
...     unique_id='braitenberg_1',
...     model=sim_model,
...     x=0.5, y=0.5,
...     length=0.01,
...     wheel_radius=0.002
... )
>>> robot.set_left_motor_controller(left_motor)
>>> robot.set_right_motor_controller(right_motor)
>>> robot.step()  # Sense and act
collision_with_object = False
left_motor_controller = None
right_motor_controller = None
label = None
step() None

Updates x, y and direction

set_left_motor_controller(left_motor_controller: Any) None
set_right_motor_controller(right_motor_controller: Any) None
draw(scene: Any) None