larvaworld.lib.model.agents.braitenberg_robot ============================================= .. py:module:: larvaworld.lib.model.agents.braitenberg_robot Classes ------- .. autoapisummary:: larvaworld.lib.model.agents.braitenberg_robot.DifferentialDriveRobot larvaworld.lib.model.agents.braitenberg_robot.SensorDrivenRobot Module Contents --------------- .. py:class:: DifferentialDriveRobot(unique_id: str, model: Any, x: float, y: float, length: float, wheel_radius: float) Bases: :py:obj:`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 .. py:attribute:: model .. py:attribute:: unique_id .. py:attribute:: length .. py:attribute:: wheel_radius .. py:attribute:: speed_left_wheel :value: 0.0 .. py:attribute:: speed_right_wheel :value: 0.0 .. py:attribute:: deltax :value: None .. py:attribute:: deltay :value: None .. py:method:: step() -> None Updates x, y and direction .. py:method:: move_duration(seconds: float) -> None Moves the robot for an 's' amount of seconds .. py:method:: print_xyd() -> None Prints the x,y position and direction .. py:method:: delta_x() -> None .. py:method:: delta_y() -> None .. py:method:: delta_direction() -> None .. py:class:: SensorDrivenRobot(**kwargs: Any) Bases: :py:obj:`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 .. py:attribute:: collision_with_object :value: False .. py:attribute:: left_motor_controller :value: None .. py:attribute:: right_motor_controller :value: None .. py:attribute:: label :value: None .. py:method:: step() -> None Updates x, y and direction .. py:method:: set_left_motor_controller(left_motor_controller: Any) -> None .. py:method:: set_right_motor_controller(right_motor_controller: Any) -> None .. py:method:: draw(scene: Any) -> None