code: def autodetect_robot():
      
      motor_controllers = []
  
      for port in get_available_ports():
          for DxlIOCls in (DxlIO, Dxl320IO):
              dxl_io = DxlIOCls(port)
              ids = dxl_io.scan()
  
              if not ids:
                  dxl_io.close()
                  continue
  
              models = dxl_io.get_model(ids)
  
              motorcls = {
                  'MX': DxlMXMotor,
                  'RX': DxlAXRXMotor,
                  'AX': DxlAXRXMotor,
                  'XL': DxlXL320Motor,
                  'SR': DxlSRMotor,
              }
  
              motors = [motorcls[model[:2]](id, model=model)
                        for id, model in zip(ids, models)]
  
              c = BaseDxlController(dxl_io, motors)
              motor_controllers.append(c)
              break
  
      return Robot(motor_controllers)
docs: Creates a :class:`~pypot.robot.robot.Robot` by detecting dynamixel motors on all available ports.