def __init__(self, identifier, **kargs):
        Driver.__init__(self, identifier, **kargs)
        
        # self.identifier = identifier
        # self.host = host
        # self.device = device
        # self.port = port # XML-RPC port

        if 'host' not in kargs.keys():
            raise ValueError("host is requested")

        if 'devices' not in kargs.keys():
            raise ValueError("devices is requested")

        if 'port' not in kargs.keys():
            raise ValueError("port is requested")

        self.xmlrpc = xmlrpclib.ServerProxy("http://%s:%d/" % 
                                            (self.host, self.port))

        # Available gratings
        # TODO: add resolution, blaze angle, etc...
        self.gratings_properties = { 0: {'name': 'G0',
                                         'range': [200.0, 600.0]}, 
                                     1: {'name': 'G1',
                                         'range': [600.0, 1100.0]}, 
                                     2: {'name': 'G2',
                                         'range': [1100.0, 2600.0]}
                                     }


        self.gratings = self.gratings_properties.keys()
Exemple #2
0
 def __init__(self, settings=None):
     # self.settings = settings
     Program.__init__(self, settings)
     Driver.__init__(self, settings)
     print("initializing viewer")
     self.settings = settings
     if self.settings["verbose"]:
         print()
         print("Settings:")
         print()
         print(
             pformat([f"{k}: {v}" for k, v in settings.items()
                      ]).lstrip('[').rstrip(']'))
         print()
     self.env = Environment(DEFAULT_VARS)
     # programs should be loaded from a directory located by a configuration file setting
     self.programs = list()
     self.fig = plt.figure()
     self.ax = self.fig.add_subplot(111,
                                    projection='3d',
                                    xlim=(0, 6),
                                    ylim=(0, 6))
     # self.ax.plot([0.0, 1.0], [0.2, 0.7], 0.4)
     self.current_position = Point()
     plt.show()
     self.current_program = NCProgram()
Exemple #3
0
 def __init__(self, parent, clargs):
     Tkinter.Tk.__init__(self,parent)
     Driver.__init__(self,clargs)
    
     self.geometry('%dx%d' % (512, 512))
     self.update()
     self.lsign = 1
     self.act()
Exemple #4
0
    def __init__(self, parent, clargs):
        Tkinter.Tk.__init__(self, parent)
        Driver.__init__(self, clargs)

        self.geometry('%dx%d' % (512, 512))
        self.update()
        self.lsign = 1
        self.act()
    def __init__(self, identifier, **kargs):
        Driver.__init__(self, identifier, **kargs)

        # self.identifier = identifier
        # self.host = host
        # self.device = device
        # self.port = port # XML-RPC port

        # if 'host' not in kargs.keys():
        #     raise ValueError("host is requested")

        # if 'devices' not in kargs.keys():
        #     raise ValueError("devices is requested")

        # if 'port' not in kargs.keys():
        #     raise ValueError("port is requested")

        if 'reb_id' not in kargs:
            raise ValueError("reb_id is requested")

        if 'host' not in kargs:
            self.host = None

        if 'stripe' not in kargs:
            self.stripe = 0

        if 'xmlfile' not in kargs:
            raise ValueError("XML sequencer file is requested")

        if self.hardware == 'REB1':
            self.reb = reb1.REB1(reb_id=self.reb_id, ctrl_host=self.host, stripe_id=[self.stripe])
            self.useCABAC = True
        elif self.hardware == 'WREB1':
            self.reb = wreb.WREB(rriaddress=self.reb_id, ctrl_host=self.host, stripe_id=[self.stripe])
            self.useCABAC = True
            self.reb.useCABACbias = True
        elif self.hardware in ['REB3', 'REB4']:
            self.reb = reb3.REB3(self.bcfile)
            self.useCABAC = False
        else:
            raise ValueError('Unknown type of hardware: %s' % self.hardware)

        # then check FPGA version after connecting
        checkversion = self.reb.fpga.get_version()
        if self.version != checkversion:
            raise ValueError('Wrong version of the FPGA firmware: reading %x instead of %x'
                             % (checkversion, self.version))

        self.reb.xmlfile = self.xmlfile
        self.read_sequencer_file(self.xmlfile)
        self.reb.exptime = self.reb.get_exposure_time()
        
        # CCD and test-related values (for meta)
        self.testID = { 'TESTTYPE': 'TEST', 'IMGTYPE': 'TEST', 'SEQNUM': 0}
        self.sensorID = { 'CCD_MANU': 'NONE', 'CCD_TYPE': 'NONE', 'CCD_SERN': '000-00', 'LSST_NUM': 'NONE'}

        logging.basicConfig(filename='REB-'+ time.strftime('%Y%m%d', time.gmtime()) + '.log',
                            level=logging.DEBUG, format='%(asctime)s: %(message)s')
Exemple #6
0
    def __init__(self, probe_ids, probe_names, probe_data_type, **kwargs):
        """Initializes the Json URL driver.
        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keyword (url) defining the Json URL driver parameters

        """
        Driver.__init__(self, probe_ids, probe_names, probe_data_type, kwargs)
Exemple #7
0
 def __init__(self, clargs, stream=sys.stdout):
     Driver.__init__(self, clargs)
     self.stream = stream
     
     self.monitor = self.options.pop('monitor')
     self.show = self.options.pop('show')
     
     for option in self.options:
         print("Setting %s to %s" % (option, self.options[option]) )
         setattr(self.hemelb, option, self.options[option])
Exemple #8
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the Wattsup driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keyword (device) defining the device to read (/dev/ttyUSB0)

        """
        Driver.__init__(self, probe_ids, kwargs)
Exemple #9
0
    def __init__(self, clargs, stream=sys.stdout):
        Driver.__init__(self, clargs)
        self.stream = stream

        self.monitor = self.options.pop('monitor')
        self.show = self.options.pop('show')

        for option in self.options:
            print("Setting %s to %s" % (option, self.options[option]))
            setattr(self.hemelb, option, self.options[option])
Exemple #10
0
 def __init__(self, clargs, stream=sys.stdout):
     Driver.__init__(self,clargs)
     self.stream = stream
     self.time = time()
     self.lsign = 1
     self.last_step = 0
     self.orbit = self.options.pop('orbit')
     self.framerate = self.options.get('MaxFramerate',None)
     if self.framerate:
         self.hemelb.MaxFramerate = self.framerate
Exemple #11
0
    def __init__(self, probe_ids, data_type, **kwargs):
        """Initializes the Wattsup driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keyword (device) defining the device to read (/dev/ttyUSB0)

        """
        Driver.__init__(self, probe_ids, data_type, kwargs)
Exemple #12
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the IPMI driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keywords (interface, host, username,
                  password) defining the IPMI parameters

        """
        Driver.__init__(self, probe_ids, kwargs)
Exemple #13
0
    def __init__(self, probe_ids, probe_data_type, **kwargs):
        """Initializes the IPMI driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keywords (interface, host, username,
                  password) defining the IPMI parameters

        """
        Driver.__init__(self, probe_ids, probe_data_type, kwargs)
Exemple #14
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the Eaton driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keyword (ip, user) defining the Eaton SNMP parameters

        """
        Driver.__init__(self, probe_ids, kwargs)
        self.cmd_gen = cmdgen.CommandGenerator()
Exemple #15
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the dummy driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keywords (min_value and max_value)
                  defining the random value interval

        """
        Driver.__init__(self, probe_ids, kwargs)
        self.min_value = int(kwargs.get('min', 75))
        self.max_value = int(kwargs.get('max', 100))
Exemple #16
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the dummy driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keywords (min_value and max_value)
                  defining the random value interval

        """
        Driver.__init__(self, probe_ids, kwargs)
        self.min_value = int(kwargs.get('min', 75))
        self.max_value = int(kwargs.get('max', 100))
Exemple #17
0
    def __init__(self, probe_ids, probes_names, probe_data_type, **kwargs):
        """Initializes the SNMP driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a metricmeter monitor sometimes several probes)
        kwargs -- keyword (protocol, user or community, ip, oid) defining the
                  SNMP parameters
                  Eaton OID is 1.3.6.1.4.1.534.6.6.7.6.5.1.3
                  Raritan OID is 1.3.6.1.4.1.13742.4.1.2.2.1.7

        """
        Driver.__init__(self, probe_ids, probes_names, probe_data_type, kwargs)
        self.cmd_gen = cmdgen.CommandGenerator()
Exemple #18
0
    def __init__(self, probe_ids, **kwargs):
        """Initializes the SNMP driver.

        Keyword arguments:
        probe_ids -- list containing the probes IDs
                     (a wattmeter monitor sometimes several probes)
        kwargs -- keyword (protocol, user or community, ip, oid) defining the
                  SNMP parameters
                  Eaton OID is 1.3.6.1.4.1.534.6.6.7.6.5.1.3
                  Raritan OID is 1.3.6.1.4.1.13742.4.1.2.2.1.7

        """
        Driver.__init__(self, probe_ids, kwargs)
        self.cmd_gen = cmdgen.CommandGenerator()
    def __init__(self, identifier, **kargs):
        Driver.__init__(self, identifier, **kargs)
        
        # self.identifier = identifier
        # self.host = host
        # self.device = device
        # self.port = port # XML-RPC port

        if 'host' not in kargs.keys():
            raise ValueError("host is requested")

        if 'devices' not in kargs.keys():
            raise ValueError("devices is requested")

        if 'port' not in kargs.keys():
            raise ValueError("port is requested")

        self.xmlrpc = xmlrpclib.ServerProxy("http://%s:%d/" % 
                                            (self.host, self.port))
 def __init__(self, probe_ids, **kwargs):
     Driver.__init__(self, probe_ids, kwargs)
 def __init__(self, identifier, **kargs):
     Driver.__init__(self, identifier, **kargs)
Exemple #22
0
    def __init__(self,
                 gpu_number="0",
                 experiment_name='None',
                 driver_conf=None,
                 memory_fraction=0.9,
                 gpu_perception=None,
                 perception_paths=None,
                 batch_size=1):
        Driver.__init__(self)

        conf_module = __import__(experiment_name)
        self._config = conf_module.configInput()
        self._config.train_segmentation = False

        if self._config.use_perception_stack:
            use_mode = {}
            for key in self._config.perception_num_replicates:
                if self._config.perception_num_replicates[key] > 0:
                    self._config.perception_num_replicates[key] = 1
                    use_mode[key] = True
                else:
                    use_mode[key] = False

            if gpu_perception is not None:
                self._config.perception_gpus = gpu_perception
            if perception_paths is not None:
                self._config.perception_paths = perception_paths

            all_params = use_mode.copy()
            if hasattr(self._config, "perception_other_params"):
                all_params.update(self._config.perception_other_params)

            self.perception_interface = Perceptions(
                batch_size={
                    key: batch_size
                    for key in use_mode if use_mode[key]
                },
                gpu_assignment=self._config.perception_gpus,
                compute_methods={},
                viz_methods={},
                num_replicates=self._config.perception_num_replicates,
                path_config=self._config.perception_paths,
                **all_params)
            time.sleep(self._config.perception_initialization_sleep)

        self._train_manager = load_system(conf_module.configTrain())
        config_gpu = tf.ConfigProto()
        config_gpu.gpu_options.visible_device_list = gpu_number
        config_gpu.gpu_options.per_process_gpu_memory_fraction = memory_fraction
        self._sess = tf.Session(config=config_gpu)

        self._sess.run(tf.global_variables_initializer())
        variables_to_restore = tf.global_variables()
        saver = tf.train.Saver(variables_to_restore)
        restore_session(self._sess, saver, self._config.models_path)

        self._control_function = getattr(
            machine_output_functions, self._train_manager._config.control_mode)
        self._image_cut = driver_conf.image_cut

        assert (driver_conf.use_planner == False)

        self._host = driver_conf.host
        self._port = driver_conf.port
        self._config_path = driver_conf.carla_config

        self._straight_button = False
        self._left_button = False
        self._right_button = False

        self.debug_i = 0
        self.temp_image_path = "./temp/"

        self.batch_size = batch_size

        self.waypoint_centers = None
        if hasattr(self._config, "cluster_center_file") and os.path.exists(
                self._config.cluster_center_file):
            self.waypoint_centers = pickle.load(
                open(self._config.cluster_center_file, "rb"))

        self.error_i = 0.0
        self.error_p = 0.0

        if hasattr(self._config, "map_height"):
            version = "v1"
            if hasattr(self._config, "mapping_version"):
                version = self._config.mapping_version

            self.mapping_helper = mapping_helper.mapping_helper(
                output_height_pix=self._config.map_height, version=version)
Exemple #23
0
    def __init__(self, driver_conf):
        Driver.__init__(self)
        # some behaviors
        self._autopilot = driver_conf.autopilot
        self._reset_period = driver_conf.reset_period  # those reset period are in the actual system time, not in simulation time
        self._goal_reaching_threshold = 3
        self.use_planner = driver_conf.use_planner
        # we need the planner to find a valid episode, so we initialize one no matter what

        self._world = None
        self._vehicle = None
        self._agent_autopilot = None
        self._camera_center = None
        self._spectator = None
        # (last) images store for several cameras
        self._data_buffers = dict()
        self.update_once = False
        self._collision_events = []
        self.collision_sensor = None

        if __CARLA_VERSION__ == '0.8.X':
            self.planner = Planner(driver_conf.city_name)
        else:
            self.planner = None
            self.use_planner = False

        # resources
        self._host = driver_conf.host
        self._port = driver_conf.port

        # various config files
        self._driver_conf = driver_conf
        self._config_path = driver_conf.carla_config

        # some initializations
        self._straight_button = False
        self._left_button = False
        self._right_button = False

        self._rear = False
        self._recording = False
        self._skiped_frames = 20
        self._stucked_counter = 0

        self._prev_time = datetime.now()
        self._episode_t0 = datetime.now()

        self._vehicle_prev_location = namedtuple("vehicle", "x y z")
        self._vehicle_prev_location.x = 0.0
        self._vehicle_prev_location.y = 0.0
        self._vehicle_prev_location.z = 0.0

        self._camera_left = None
        self._camera_right = None
        self._camera_center = None

        self._actor_list = []

        self._sensor_list = []
        self._weather_list = [
            'ClearNoon', 'CloudyNoon', 'WetNoon', 'WetCloudyNoon',
            'MidRainyNoon', 'HardRainNoon', 'SoftRainNoon', 'ClearSunset',
            'CloudySunset', 'WetSunset', 'WetCloudySunset', 'MidRainSunset',
            'HardRainSunset', 'SoftRainSunset'
        ]

        self._current_weather = 4

        self._current_command = 2.0

        # steering wheel
        self._steering_wheel_flag = True

        if self._steering_wheel_flag:
            self._is_on_reverse = False
            self._control = VehicleControl()
            self._parser = SafeConfigParser()
            self._parser.read('wheel_config.ini')
            self._steer_idx = int(
                self._parser.get('G29 Racing Wheel', 'steering_wheel'))
            self._throttle_idx = int(
                self._parser.get('G29 Racing Wheel', 'throttle'))
            self._brake_idx = int(self._parser.get('G29 Racing Wheel',
                                                   'brake'))
            self._reverse_idx = int(
                self._parser.get('G29 Racing Wheel', 'reverse'))
            self._handbrake_idx = int(
                self._parser.get('G29 Racing Wheel', 'handbrake'))
        self.last_timestamp = lambda x: x
        self.last_timestamp.elapsed_seconds = 0.0
        self.last_timestamp.delta_seconds = 0.2

        self.initialize_map(driver_conf.city_name)
 def __init__(self, probe_ids, **kwargs):
     Driver.__init__(self, probe_ids, kwargs)
     self.hosts = (kwargs.get('host'))
     self.temp = (kwargs.get('time'))