Код: Выделить всё
from controller import Robot
robot = Robot()
MAX_SPEED = 6.4
timestep = 32
leftBackMotor = robot.getDevice('back left wheel')
rightBackMotor = robot.getDevice('back right wheel')
leftFrontMotor = robot.getDevice('front left wheel')
rightFrontMotor = robot.getDevice('front right wheel')
motors = [leftBackMotor, rightBackMotor, leftFrontMotor, rightFrontMotor]
for motor in motors:
motor.setPosition(float('inf'))
motor.setVelocity(0.0)
dist_sensor = []
for i in range(16):
sensor_name = "so" + str(i)
dist_sensor.append(robot.getDevice(sensor_name))
dist_sensor[i].enable(timestep)
while robot.step(timestep) != -1:
for i in range(16):
print(f'Sensor: {i} Valor: {dist_sensor[i].getValue()}')
leftBackMotor.setVelocity(MAX_SPEED)
leftFrontMotor.setVelocity(MAX_SPEED)
rightBackMotor.setVelocity(MAX_SPEED)
rightFrontMotor.setVelocity(MAX_SPEED)
Подробнее здесь: https://stackoverflow.com/questions/793 ... alfunction